From 223c56291311632c8b6f2b9fb2b1445b5023f3d2 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 9 Feb 2015 09:44:36 +0300 Subject: [PATCH] add popup menu --- src/dlangide/ui/commands.d | 4 ++-- src/dlangide/ui/dsourceedit.d | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index 67b514b..6c16df7 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -67,8 +67,8 @@ const Action ACTION_EDIT_PASTE = (new Action(EditorActions.Paste, "MENU_EDIT_PAS const Action ACTION_EDIT_CUT = (new Action(EditorActions.Cut, "MENU_EDIT_CUT"c, "edit-cut"c, KeyCode.KEY_X, KeyFlag.Control)).disableByDefault(); const Action ACTION_EDIT_UNDO = (new Action(EditorActions.Undo, "MENU_EDIT_UNDO"c, "edit-undo"c, KeyCode.KEY_Z, KeyFlag.Control)).disableByDefault(); const Action ACTION_EDIT_REDO = (new Action(EditorActions.Redo, "MENU_EDIT_REDO"c, "edit-redo"c, KeyCode.KEY_Z, KeyFlag.Control|KeyFlag.Shift)).disableByDefault(); -const Action ACTION_EDIT_INDENT = (new Action(EditorActions.Tab, "MENU_EDIT_INDENT"c, "edit-indent"c, KeyCode.TAB, 0)).disableByDefault(); -const Action ACTION_EDIT_UNINDENT = (new Action(EditorActions.BackTab, "MENU_EDIT_UNINDENT"c, "edit-unindent", KeyCode.TAB, KeyFlag.Shift)).disableByDefault(); +const Action ACTION_EDIT_INDENT = (new Action(EditorActions.Indent, "MENU_EDIT_INDENT"c, "edit-indent"c, KeyCode.TAB, 0)).disableByDefault(); +const Action ACTION_EDIT_UNINDENT = (new Action(EditorActions.Unindent, "MENU_EDIT_UNINDENT"c, "edit-unindent", KeyCode.TAB, KeyFlag.Shift)).disableByDefault(); const Action ACTION_EDIT_TOGGLE_LINE_COMMENT = (new Action(EditorActions.Redo, "MENU_EDIT_TOGGLE_LINE_COMMENT"c, null, KeyCode.KEY_DIVIDE, KeyFlag.Control)).disableByDefault(); const Action ACTION_EDIT_TOGGLE_BLOCK_COMMENT = (new Action(EditorActions.Redo, "MENU_EDIT_TOGGLE_BLOCK_COMMENT"c, null, KeyCode.KEY_DIVIDE, KeyFlag.Control|KeyFlag.Shift)).disableByDefault(); const Action ACTION_EDIT_PREFERENCES = (new Action(EditorActions.Redo, "MENU_EDIT_PREFERENCES"c, null)); diff --git a/src/dlangide/ui/dsourceedit.d b/src/dlangide/ui/dsourceedit.d index 4deaecf..6ecd7b8 100644 --- a/src/dlangide/ui/dsourceedit.d +++ b/src/dlangide/ui/dsourceedit.d @@ -3,6 +3,7 @@ module dlangide.ui.dsourceedit; import dlangui.core.logger; import dlangui.widgets.editors; import dlangui.widgets.srcedit; +import dlangui.widgets.menu; import ddc.lexer.textsource; import ddc.lexer.exceptions; @@ -28,6 +29,9 @@ class DSourceEdit : SourceEdit { setTokenHightlightColor(TokenCategory.Error, 0xFF0000); // red setTokenHightlightColor(TokenCategory.Comment_Documentation, 0x206000); //setTokenHightlightColor(TokenCategory.Identifier, 0x206000); // no colors + MenuItem editPopupItem = new MenuItem(null); + editPopupItem.add(ACTION_EDIT_COPY, ACTION_EDIT_PASTE, ACTION_EDIT_CUT, ACTION_EDIT_UNDO, ACTION_EDIT_REDO, ACTION_EDIT_INDENT, ACTION_EDIT_UNINDENT, ACTION_EDIT_TOGGLE_LINE_COMMENT); + popupMenu = editPopupItem; } this() { this("SRCEDIT");