From db88a0286343aacc1c20c5901b9a54e14bca5b39 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 18 Sep 2017 10:50:56 +0300 Subject: [PATCH] View menu itmes; check items for whitespace and tab marks settings - #302 --- dub.json | 2 +- src/dlangide/ui/commands.d | 7 +++++++ src/dlangide/ui/frame.d | 27 ++++++++++++++++++++++++--- src/dlangide/workspace/idesettings.d | 1 + views/res/i18n/en.ini | 4 ++++ views/res/i18n/ru.ini | 4 ++++ 6 files changed, 41 insertions(+), 4 deletions(-) diff --git a/dub.json b/dub.json index 9eef4cf..b8fdf4b 100644 --- a/dub.json +++ b/dub.json @@ -12,7 +12,7 @@ "stringImportPaths": ["views"], "dependencies": { - "dlangui": "==0.9.137", + "dlangui": "==0.9.138", "dsymbol": "~>0.2.9", "dcd": "~>0.9.1" }, diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index 060de7f..2248628 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -70,6 +70,9 @@ enum IDEActions : int { InsertCompletion, FindInFiles, CloseWorkspace, + + ViewToggleWhitespaceMarks, + ViewToggleTabPositionMarks, } __gshared static this() { @@ -133,6 +136,10 @@ const Action ACTION_EDIT_UNINDENT = (new Action(EditorActions.Unindent, "MENU_ED const Action ACTION_EDIT_TOGGLE_LINE_COMMENT = (new Action(EditorActions.ToggleLineComment, "MENU_EDIT_TOGGLE_LINE_COMMENT"c, null, KeyCode.KEY_DIVIDE, KeyFlag.Control)).disableByDefault(); 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_VIEW_TOGGLE_SHOW_WHITESPACES = (new Action(IDEActions.ViewToggleWhitespaceMarks, "MENU_VIEW_SHOW_WHITESPACE_MARKS"c, null)); +const Action ACTION_VIEW_TOGGLE_TAB_POSITIONS = (new Action(IDEActions.ViewToggleTabPositionMarks, "MENU_VIEW_SHOW_TAB_POSITIONS"c, null)); + const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABOUT"c); const Action ACTION_HELP_VIEW_HELP = new Action(IDEActions.HelpViewHelp, "MENU_HELP_VIEW_HELP"c); const Action ACTION_HELP_DONATE = new Action(IDEActions.HelpDonate, "MENU_HELP_DONATE"c); diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index ae34559..ac8a8f6 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -709,9 +709,14 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL MenuItem editItemAdvanced = new MenuItem(new Action(221, "MENU_EDIT_ADVANCED")); editItemAdvanced.add(ACTION_EDIT_INDENT, ACTION_EDIT_UNINDENT, ACTION_EDIT_TOGGLE_LINE_COMMENT, ACTION_EDIT_TOGGLE_BLOCK_COMMENT); editItem.add(editItemAdvanced); - editItem.add(ACTION_EDIT_PREFERENCES); + MenuItem viewItem = new MenuItem(new Action(3, "MENU_VIEW")); + viewItem.add(ACTION_WINDOW_SHOW_HOME_SCREEN, ACTION_WINDOW_SHOW_WORKSPACE_EXPLORER, ACTION_WINDOW_SHOW_LOG_WINDOW); + viewItem.addSeparator(); + viewItem.addCheck(ACTION_VIEW_TOGGLE_SHOW_WHITESPACES); + viewItem.addCheck(ACTION_VIEW_TOGGLE_TAB_POSITIONS); + MenuItem navItem = new MenuItem(new Action(21, "MENU_NAVIGATE")); navItem.add(ACTION_GO_TO_DEFINITION, ACTION_GET_COMPLETIONS, ACTION_GET_DOC_COMMENTS, ACTION_GET_PAREN_COMPLETION, ACTION_EDITOR_GOTO_PREVIOUS_BOOKMARK, @@ -739,12 +744,12 @@ 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, ACTION_WINDOW_CLOSE_ALL_DOCUMENTS); - windowItem.addSeparator(); - windowItem.add(ACTION_WINDOW_SHOW_HOME_SCREEN, ACTION_WINDOW_SHOW_WORKSPACE_EXPLORER, ACTION_WINDOW_SHOW_LOG_WINDOW); + MenuItem helpItem = new MenuItem(new Action(4, "MENU_HELP"c)); helpItem.add(ACTION_HELP_VIEW_HELP, ACTION_HELP_ABOUT, ACTION_HELP_DONATE); mainMenuItems.add(fileItem); mainMenuItems.add(editItem); + mainMenuItems.add(viewItem); mainMenuItems.add(projectItem); mainMenuItems.add(navItem); mainMenuItems.add(buildItem); @@ -910,6 +915,12 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL case IDEActions.GotoLine: a.state = (currentEditor !is null && !_currentBackgroundOperation) ? ACTION_STATE_ENABLED : ACTION_STATE_DISABLE; return true; + case IDEActions.ViewToggleWhitespaceMarks: + a.state = _settings.showWhiteSpaceMarks ? ACTION_STATE_CHECKED : ACTION_STATE_ENABLED; + return true; + case IDEActions.ViewToggleTabPositionMarks: + a.state = _settings.showTabPositionMarks ? ACTION_STATE_CHECKED : ACTION_STATE_ENABLED; + return true; default: return super.handleActionStateRequest(a); } @@ -1070,6 +1081,16 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL case IDEActions.WindowShowLogWindow: _logPanel.activateLogTab(); return true; + case IDEActions.ViewToggleWhitespaceMarks: + _settings.showWhiteSpaceMarks = !_settings.showWhiteSpaceMarks; + _settings.save(); + applySettings(_settings); + return true; + case IDEActions.ViewToggleTabPositionMarks: + _settings.showTabPositionMarks = !_settings.showTabPositionMarks; + _settings.save(); + applySettings(_settings); + return true; case IDEActions.FileOpenWorkspace: // Already specified workspace if (!a.stringParam.empty) { diff --git a/src/dlangide/workspace/idesettings.d b/src/dlangide/workspace/idesettings.d index 59be402..4cbe7c5 100644 --- a/src/dlangide/workspace/idesettings.d +++ b/src/dlangide/workspace/idesettings.d @@ -172,6 +172,7 @@ class IDESettings : SettingsFile { /// set tab position marks enabled flag @property IDESettings showTabPositionMarks(bool enabled) { editorSettings.setBoolean("showTabPositionMarks", enabled); return this; } /// string value of font face in text editors + @property string editorFontFace() { return editorSettings.getString("fontFace", "Default"); } /// int value of font size in text editors @property int editorFontSize() { return cast(int)editorSettings.getInteger("fontSize", 11); } diff --git a/views/res/i18n/en.ini b/views/res/i18n/en.ini index bd7ec20..0ecec66 100644 --- a/views/res/i18n/en.ini +++ b/views/res/i18n/en.ini @@ -54,6 +54,10 @@ MENU_EDIT_TOGGLE_BLOCK_COMMENT=Toggle block comment MENU_EDIT_ADVANCED=Advanced... MENU_EDIT_PREFERENCES=&Preferences +MENU_VIEW=&View +MENU_VIEW_SHOW_WHITESPACE_MARKS=Show whitespace marks +MENU_VIEW_SHOW_TAB_POSITIONS=Tab position marks + MENU_PROJECT=&Project MENU_PROJECT_CONFIGURATIONS=Project configurations MENU_PROJECT_SET_AS_STARTUP=Set as startup project diff --git a/views/res/i18n/ru.ini b/views/res/i18n/ru.ini index f44b3e7..9ed278b 100644 --- a/views/res/i18n/ru.ini +++ b/views/res/i18n/ru.ini @@ -54,6 +54,10 @@ MENU_EDIT_TOGGLE_BLOCK_COMMENT=Закомментировать блок MENU_EDIT_ADVANCED=Продвинутые... MENU_EDIT_PREFERENCES=&Настройки +MENU_VIEW=&Вид +MENU_VIEW_SHOW_WHITESPACE_MARKS=Видимые пробелы и табы +MENU_VIEW_SHOW_TAB_POSITIONS=Метки отступов + MENU_PROJECT=&Проект MENU_PROJECT_CONFIGURATIONS=Конфигурации проекта MENU_PROJECT_SET_AS_STARTUP=Установить как начальный проект