From 72b02b82981a75c2a3751a4ae384c61c18e839ed Mon Sep 17 00:00:00 2001 From: gazer Date: Wed, 27 Jan 2016 22:01:49 +0300 Subject: [PATCH] close tab with ctrl+W --- src/dlangide/ui/commands.d | 2 ++ src/dlangide/ui/frame.d | 7 ++++++- views/res/i18n/en.ini | 1 + views/res/i18n/ru.ini | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index 01bb4bd..524c8af 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -43,6 +43,7 @@ enum IDEActions : int { DebugStepOut, HelpAbout, + WindowCloseDocument, WindowCloseAllDocuments, CreateNewWorkspace, AddToCurrentWorkspace, @@ -122,6 +123,7 @@ const Action ACTION_EDIT_TOGGLE_LINE_COMMENT = (new Action(EditorActions.ToggleL const Action ACTION_EDIT_TOGGLE_BLOCK_COMMENT = (new Action(EditorActions.ToggleBlockComment, "MENU_EDIT_TOGGLE_BLOCK_COMMENT"c, null, KeyCode.KEY_DIVIDE, KeyFlag.Control|KeyFlag.Shift)).disableByDefault(); const Action ACTION_EDIT_PREFERENCES = (new Action(IDEActions.EditPreferences, "MENU_EDIT_PREFERENCES"c, null)).disableByDefault(); const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABOUT"c); +const Action ACTION_WINDOW_CLOSE_DOCUMENT = new Action(IDEActions.WindowCloseDocument, "MENU_WINDOW_CLOSE_DOCUMENT"c, null, KeyCode.KEY_W, KeyFlag.Control); const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c); const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "Create new workspace"d); diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index f9e74be..b48b6e4 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -616,6 +616,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL MenuItem windowItem = new MenuItem(new Action(3, "MENU_WINDOW"c)); windowItem.add(new Action(30, "MENU_WINDOW_PREFERENCES")); + windowItem.add(ACTION_WINDOW_CLOSE_DOCUMENT); windowItem.add(ACTION_WINDOW_CLOSE_ALL_DOCUMENTS); MenuItem helpItem = new MenuItem(new Action(4, "MENU_HELP"c)); helpItem.add(new Action(40, "MENU_HELP_VIEW_HELP")); @@ -657,7 +658,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL ACTION_DEBUG_STEP_INTO, ACTION_DEBUG_STEP_OVER, ACTION_DEBUG_STEP_OUT, - ACTION_WINDOW_CLOSE_ALL_DOCUMENTS, ACTION_HELP_ABOUT]; + ACTION_WINDOW_CLOSE_DOCUMENT, ACTION_WINDOW_CLOSE_ALL_DOCUMENTS, ACTION_HELP_ABOUT]; actions ~= STD_EDITOR_ACTIONS; saveShortcutsSettings(actions); } @@ -713,6 +714,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL return true; case IDEActions.FileExit: case IDEActions.FileOpen: + case IDEActions.WindowCloseDocument: case IDEActions.WindowCloseAllDocuments: case IDEActions.FileOpenWorkspace: // disable when background operation in progress @@ -850,6 +852,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL case IDEActions.RefreshProject: refreshWorkspace(); return true; + case IDEActions.WindowCloseDocument: + onTabClose(_tabs.selectedTabId); + return true; case IDEActions.WindowCloseAllDocuments: askForUnsavedEdits(delegate() { closeAllDocuments(); diff --git a/views/res/i18n/en.ini b/views/res/i18n/en.ini index 2b11a87..e6529c6 100644 --- a/views/res/i18n/en.ini +++ b/views/res/i18n/en.ini @@ -66,6 +66,7 @@ MENU_DEBUG_BREAKPOINT_DISABLE=Disable breakpoint MENU_WINDOW=&Window MENU_WINDOW_PREFERENCES=&Preferences +MENU_WINDOW_CLOSE_DOCUMENT=Close document MENU_WINDOW_CLOSE_ALL_DOCUMENTS=Close all documents MENU_HELP=&Help diff --git a/views/res/i18n/ru.ini b/views/res/i18n/ru.ini index 0359f0d..407615d 100644 --- a/views/res/i18n/ru.ini +++ b/views/res/i18n/ru.ini @@ -50,6 +50,7 @@ MENU_DEBUG=&Отладка MENU_WINDOW=&Окно MENU_WINDOW_PREFERENCES=&Настройки +MENU_WINDOW_CLOSE_DOCUMENT=Закрыть документ MENU_WINDOW_CLOSE_ALL_DOCUMENTS=Закрыть все документы MENU_HELP=&Справка