1 module dlangide.ui.commands;
2 
3 public import dlangui.core.events;
4 import dlangui.widgets.editors;
5 
6 enum IDEActions : int {
7     //ProjectOpen = 1010000,
8     FileNew = 1010000,
9     FileNewDirectory,
10     FileNewWorkspace,
11     FileNewProject,
12     FileOpen,
13     FileOpenWorkspace,
14     FileSave,
15     FileSaveAs,
16     FileSaveAll,
17     FileClose,
18     FileExit,
19     EditPreferences,
20     ProjectConfigurations,
21     BuildConfigurations,
22     BuildWorkspace,
23     RebuildWorkspace,
24     CleanWorkspace,
25     BuildProject,
26     RebuildProject,
27     CleanProject,
28     RefreshProject,
29     UpdateProjectDependencies,
30     SetStartupProject,
31     RevealProjectInExplorer,
32     ProjectSettings,
33     RunWithRdmd,
34 
35     BuildSetConfiguration,
36     ProjectSetConfiguration,
37 
38     DebugStart,
39     DebugRestart,
40     DebugStartNoDebug,
41     DebugContinue,
42     DebugStop,
43     DebugPause,
44     DebugToggleBreakpoint,
45     DebugEnableBreakpoint,
46     DebugDisableBreakpoint,
47     DebugStepInto,
48     DebugStepOver,
49     DebugStepOut,
50 
51     HelpAbout,
52     HelpViewHelp,
53     HelpDonate,
54     WindowCloseDocument,
55     WindowCloseAllDocuments,
56     WindowShowHomeScreen,
57     WindowShowWorkspaceExplorer,
58     WindowShowLogWindow,
59 
60     CreateNewWorkspace,
61     AddToCurrentWorkspace,
62     //ProjectFolderAddItem,
63     ProjectFolderRemoveItem,
64     ProjectFolderOpenItem,
65     ProjectFolderRenameItem,
66     ProjectFolderRefresh,
67     ProjectFolderExpandAll,
68     ProjectFolderCollapseAll,
69 
70     GoToDefinition,
71     GetCompletionSuggestions,
72     GetDocComments,
73     GetParenCompletion,
74     GotoLine,
75     GotoNextPosition,
76     GotoPrevPosition,
77 
78     InsertCompletion,
79     FindInFiles,
80     CloseWorkspace,
81 
82     ViewToggleWhitespaceMarks,
83     ViewToggleTabPositionMarks,
84     ViewToggleToolbar,
85     ViewToggleStatusbar,
86 
87     ToolsOpenDMDTraceLog,
88 }
89 
90 __gshared static this() {
91     // register editor action names and ids
92     registerActionEnum!IDEActions();
93 }
94 
95 
96 //const Action ACTION_PROJECT_FOLDER_ADD_ITEM = new Action(IDEActions.ProjectFolderAddItem, "MENU_PROJECT_FOLDER_ADD_ITEM"c);
97 const Action ACTION_PROJECT_FOLDER_OPEN_ITEM = new Action(IDEActions.ProjectFolderOpenItem, "MENU_PROJECT_FOLDER_OPEN_ITEM"c);
98 const Action ACTION_PROJECT_FOLDER_REMOVE_ITEM = new Action(IDEActions.ProjectFolderRemoveItem, "MENU_PROJECT_FOLDER_REMOVE_ITEM"c);
99 const Action ACTION_PROJECT_FOLDER_RENAME_ITEM = new Action(IDEActions.ProjectFolderRenameItem, "MENU_PROJECT_FOLDER_RENAME_ITEM"c);
100 const Action ACTION_PROJECT_FOLDER_REFRESH = new Action(IDEActions.ProjectFolderRefresh, "MENU_PROJECT_FOLDER_REFRESH"c);
101 const Action ACTION_PROJECT_FOLDER_EXPAND_ALL = new Action(IDEActions.ProjectFolderExpandAll, "MENU_PROJECT_FOLDER_EXPAND_ALL"c, null, KeyCode.KEY_ADD, KeyFlag.Control);
102 const Action ACTION_PROJECT_FOLDER_COLLAPSE_ALL = new Action(IDEActions.ProjectFolderCollapseAll, "MENU_PROJECT_FOLDER_COLLAPSE_ALL"c, null, KeyCode.KEY_SUBTRACT, KeyFlag.Control);
103 
104 const Action ACTION_FILE_WORKSPACE_CLOSE = new Action(IDEActions.CloseWorkspace, "MENU_FILE_WORKSPACE_CLOSE"c).disableByDefault();
105 
106 const Action ACTION_FILE_NEW_DIRECTORY = new Action(IDEActions.FileNewDirectory, "MENU_FILE_NEW_DIRECTORY"c);
107 const Action ACTION_FILE_NEW_SOURCE_FILE = new Action(IDEActions.FileNew, "MENU_FILE_NEW_SOURCE_FILE"c, "document-new", KeyCode.KEY_N, KeyFlag.Control);
108 const Action ACTION_FILE_NEW_PROJECT = new Action(IDEActions.FileNewProject, "MENU_FILE_NEW_PROJECT"c);
109 const Action ACTION_FILE_NEW_WORKSPACE = new Action(IDEActions.FileNewWorkspace, "MENU_FILE_NEW_WORKSPACE"c);
110 const Action ACTION_FILE_OPEN = new Action(IDEActions.FileOpen, "MENU_FILE_OPEN"c, "document-open", KeyCode.KEY_O, KeyFlag.Control);
111 const Action ACTION_FILE_OPEN_WORKSPACE = new Action(IDEActions.FileOpenWorkspace, "MENU_FILE_OPEN_WORKSPACE"c, null, KeyCode.KEY_O, KeyFlag.Control | KeyFlag.Shift);
112 const Action ACTION_FILE_SAVE = (new Action(IDEActions.FileSave, "MENU_FILE_SAVE"c, "document-save", KeyCode.KEY_S, KeyFlag.Control)).disableByDefault();
113 const Action ACTION_FILE_SAVE_AS = (new Action(IDEActions.FileSaveAs, "MENU_FILE_SAVE_AS"c)).disableByDefault().disableByDefault();
114 const Action ACTION_FILE_SAVE_ALL = (new Action(IDEActions.FileSaveAll, "MENU_FILE_SAVE_ALL"c, null, KeyCode.KEY_S, KeyFlag.Control | KeyFlag.Shift)).disableByDefault();
115 const Action ACTION_FILE_EXIT = new Action(IDEActions.FileExit, "MENU_FILE_EXIT"c, "document-close"c, KeyCode.KEY_X, KeyFlag.Alt);
116 const Action ACTION_WORKSPACE_BUILD = new Action(IDEActions.BuildWorkspace, "MENU_BUILD_WORKSPACE_BUILD"c);
117 const Action ACTION_WORKSPACE_REBUILD = new Action(IDEActions.RebuildWorkspace, "MENU_BUILD_WORKSPACE_REBUILD"c);
118 const Action ACTION_WORKSPACE_CLEAN = new Action(IDEActions.CleanWorkspace, "MENU_BUILD_WORKSPACE_CLEAN"c);
119 const Action ACTION_PROJECT_CONFIGURATIONS = new Action(IDEActions.ProjectConfigurations, "MENU_PROJECT_CONFIGURATIONS"c);
120 const Action ACTION_BUILD_CONFIGURATIONS = new Action(IDEActions.BuildConfigurations, "MENU_BUILD_CONFIGURATIONS"c);
121 const Action ACTION_PROJECT_BUILD = new Action(IDEActions.BuildProject, "MENU_BUILD_PROJECT_BUILD"c, "run-build", KeyCode.F7, 0);
122 const Action ACTION_PROJECT_REBUILD = new Action(IDEActions.RebuildProject, "MENU_BUILD_PROJECT_REBUILD"c, "run-build-clean", KeyCode.F7, KeyFlag.Control);
123 const Action ACTION_PROJECT_CLEAN = new Action(IDEActions.CleanProject, "MENU_BUILD_PROJECT_CLEAN"c, null);
124 const Action ACTION_PROJECT_SET_STARTUP = new Action(IDEActions.SetStartupProject, "MENU_PROJECT_SET_AS_STARTUP"c, null);
125 const Action ACTION_PROJECT_REVEAL_IN_EXPLORER = new Action(IDEActions.RevealProjectInExplorer, "MENU_PROJECT_REVEAL_IN_EXPLORER"c);
126 const Action ACTION_PROJECT_SETTINGS = (new Action(IDEActions.ProjectSettings, "MENU_PROJECT_SETTINGS"c, null)).disableByDefault();
127 const Action ACTION_PROJECT_REFRESH = new Action(IDEActions.RefreshProject, "MENU_PROJECT_REFRESH"c);
128 const Action ACTION_PROJECT_UPDATE_DEPENDENCIES = new Action(IDEActions.UpdateProjectDependencies, "MENU_PROJECT_UPDATE_DEPENDENCIES"c);
129 const Action ACTION_RUN_WITH_RDMD = new Action(IDEActions.RunWithRdmd, "MENU_BUILD_RUN_WITH_RDMD"c, "run-rdmd").disableByDefault();
130 
131 const Action ACTION_PROJECT_BUILD_CONFIGURATION = new Action(IDEActions.BuildSetConfiguration, "MENU_BUILD_CONFIGURATION"c).disableByDefault();
132 const Action ACTION_PROJECT_CONFIGURATION = new Action(IDEActions.ProjectSetConfiguration, "MENU_PROJECT_CONFIGURATION"c).disableByDefault();
133 
134 const Action ACTION_DEBUG_START = new Action(IDEActions.DebugStart, "MENU_DEBUG_START_DEBUGGING"c, "debug-run"c, KeyCode.F5, KeyFlag.Control | KeyFlag.Shift);
135 const Action ACTION_DEBUG_START_NO_DEBUG = new Action(IDEActions.DebugStartNoDebug, "MENU_DEBUG_START_NO_DEBUGGING"c, null, KeyCode.F5, KeyFlag.Control);
136 const Action ACTION_DEBUG_CONTINUE = new Action(IDEActions.DebugContinue, "MENU_DEBUG_CONTINUE"c, "debug-run");
137 const Action ACTION_DEBUG_STOP = (new Action(IDEActions.DebugStop, "MENU_DEBUG_STOP"c, "debug-stop")).disableByDefault();
138 const Action ACTION_DEBUG_PAUSE = (new Action(IDEActions.DebugPause, "MENU_DEBUG_PAUSE"c, "debug-pause")).disableByDefault();
139 const Action ACTION_DEBUG_RESTART = new Action(IDEActions.DebugRestart, "MENU_DEBUG_RESTART"c, "debug-restart"c, KeyCode.F5, 0);
140 const Action ACTION_DEBUG_STEP_INTO = (new Action(IDEActions.DebugStepInto, "MENU_DEBUG_STEP_INTO"c, "debug-step-into"c, KeyCode.F11, 0)).disableByDefault();
141 const Action ACTION_DEBUG_STEP_OVER = (new Action(IDEActions.DebugStepOver, "MENU_DEBUG_STEP_OVER"c, "debug-step-over"c, KeyCode.F10, 0)).disableByDefault();
142 const Action ACTION_DEBUG_STEP_OUT = (new Action(IDEActions.DebugStepOut, "MENU_DEBUG_STEP_OUT"c, "debug-step-out"c, KeyCode.F11, KeyFlag.Shift)).disableByDefault();
143 
144 const Action ACTION_DEBUG_TOGGLE_BREAKPOINT = (new Action(IDEActions.DebugToggleBreakpoint, "MENU_DEBUG_BREAKPOINT_TOGGLE"c, null, KeyCode.F9, 0)).disableByDefault();
145 const Action ACTION_DEBUG_ENABLE_BREAKPOINT = (new Action(IDEActions.DebugEnableBreakpoint, "MENU_DEBUG_BREAKPOINT_ENABLE"c, null, KeyCode.F9, KeyFlag.Shift)).disableByDefault();
146 const Action ACTION_DEBUG_DISABLE_BREAKPOINT = (new Action(IDEActions.DebugDisableBreakpoint, "MENU_DEBUG_BREAKPOINT_DISABLE"c, null, KeyCode.F9, KeyFlag.Control)).disableByDefault();
147 
148 const Action ACTION_EDIT_COPY = (new Action(EditorActions.Copy, "MENU_EDIT_COPY"c, "edit-copy"c, KeyCode.KEY_C, KeyFlag.Control)).addAccelerator(KeyCode.INS, KeyFlag.Control).disableByDefault();
149 const Action ACTION_EDIT_PASTE = (new Action(EditorActions.Paste, "MENU_EDIT_PASTE"c, "edit-paste"c, KeyCode.KEY_V, KeyFlag.Control)).addAccelerator(KeyCode.INS, KeyFlag.Shift).disableByDefault();
150 const Action ACTION_EDIT_CUT = (new Action(EditorActions.Cut, "MENU_EDIT_CUT"c, "edit-cut"c, KeyCode.KEY_X, KeyFlag.Control)).addAccelerator(KeyCode.DEL, KeyFlag.Shift).disableByDefault();
151 const Action ACTION_EDIT_UNDO = (new Action(EditorActions.Undo, "MENU_EDIT_UNDO"c, "edit-undo"c, KeyCode.KEY_Z, KeyFlag.Control)).disableByDefault();
152 const Action ACTION_EDIT_REDO = (new Action(EditorActions.Redo, "MENU_EDIT_REDO"c, "edit-redo"c, KeyCode.KEY_Y, KeyFlag.Control)).addAccelerator(KeyCode.KEY_Z, KeyFlag.Control|KeyFlag.Shift).disableByDefault();
153 const Action ACTION_EDIT_INDENT = (new Action(EditorActions.Indent, "MENU_EDIT_INDENT"c, "edit-indent"c, KeyCode.TAB, 0)).addAccelerator(KeyCode.KEY_BRACKETCLOSE, KeyFlag.Control).disableByDefault();
154 const Action ACTION_EDIT_UNINDENT = (new Action(EditorActions.Unindent, "MENU_EDIT_UNINDENT"c, "edit-unindent", KeyCode.TAB, KeyFlag.Shift)).addAccelerator(KeyCode.KEY_BRACKETOPEN, KeyFlag.Control).disableByDefault();
155 const Action ACTION_EDIT_TOGGLE_LINE_COMMENT = (new Action(EditorActions.ToggleLineComment, "MENU_EDIT_TOGGLE_LINE_COMMENT"c, null, KeyCode.KEY_DIVIDE, KeyFlag.Control)).disableByDefault();
156 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();
157 const Action ACTION_EDIT_PREFERENCES = (new Action(IDEActions.EditPreferences, "MENU_EDIT_PREFERENCES"c, null)).disableByDefault();
158 
159 const Action ACTION_VIEW_TOGGLE_SHOW_WHITESPACES = (new Action(IDEActions.ViewToggleWhitespaceMarks, "MENU_VIEW_SHOW_WHITESPACE_MARKS"c, null));
160 const Action ACTION_VIEW_TOGGLE_TAB_POSITIONS = (new Action(IDEActions.ViewToggleTabPositionMarks, "MENU_VIEW_SHOW_TAB_POSITIONS"c, null));
161 const Action ACTION_VIEW_TOGGLE_TOOLBAR = (new Action(IDEActions.ViewToggleToolbar, "MENU_VIEW_SHOW_TOOLBAR"c, null)).disableByDefault();
162 const Action ACTION_VIEW_TOGGLE_STATUSBAR = (new Action(IDEActions.ViewToggleStatusbar, "MENU_VIEW_SHOW_STATUSBAR"c, null)).disableByDefault();
163 
164 const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABOUT"c);
165 const Action ACTION_HELP_VIEW_HELP = new Action(IDEActions.HelpViewHelp, "MENU_HELP_VIEW_HELP"c);
166 const Action ACTION_HELP_DONATE = new Action(IDEActions.HelpDonate, "MENU_HELP_DONATE"c);
167 
168 const Action ACTION_WINDOW_CLOSE_DOCUMENT = new Action(IDEActions.WindowCloseDocument, "MENU_WINDOW_CLOSE_DOCUMENT"c, null, KeyCode.KEY_W, KeyFlag.Control).disableByDefault();
169 const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c).disableByDefault();
170 const Action ACTION_WINDOW_SHOW_HOME_SCREEN = new Action(IDEActions.WindowShowHomeScreen, "MENU_WINDOW_SHOW_HOME_SCREEN"c);
171 const Action ACTION_WINDOW_SHOW_WORKSPACE_EXPLORER = new Action(IDEActions.WindowShowWorkspaceExplorer, "MENU_WINDOW_SHOW_WORKSPACE_EXPLORER"c).disableByDefault();
172 const Action ACTION_WINDOW_SHOW_LOG_WINDOW = new Action(IDEActions.WindowShowLogWindow, "MENU_WINDOW_SHOW_LOG_WINDOW"c);
173 
174 const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "OPTION_CREATE_NEW_WORKSPACE"c);
175 const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "OPTION_ADD_TO_CURRENT_WORKSPACE"c);
176 
177 const Action ACTION_GET_DOC_COMMENTS = (new Action(IDEActions.GetDocComments,  "SHOW_DOC_COMMENTS"c, ""c, KeyCode.KEY_D, KeyFlag.Control|KeyFlag.Shift)).addAccelerator(KeyCode.F12, KeyFlag.Control).disableByDefault();
178 const Action ACTION_GO_TO_DEFINITION = (new Action(IDEActions.GoToDefinition,  "GO_TO_DEFINITION"c, ""c, KeyCode.KEY_G, KeyFlag.Control)).addAccelerator(KeyCode.F12, 0).disableByDefault();
179 const Action ACTION_GET_COMPLETIONS = (new Action(IDEActions.GetCompletionSuggestions,  "SHOW_COMPLETIONS"c, ""c, KeyCode.KEY_G, KeyFlag.Control|KeyFlag.Shift)).addAccelerator(KeyCode.SPACE, KeyFlag.Control).disableByDefault();
180 const Action ACTION_GET_PAREN_COMPLETION = (new Action(IDEActions.GetParenCompletion,  "SHOW_PAREN_COMPLETION"c, ""c, KeyCode.SPACE, KeyFlag.Control|KeyFlag.Shift)).disableByDefault();
181 const Action ACTION_GO_TO_LINE = (new Action(IDEActions.GotoLine,  "GO_TO_LINE"c, ""c, KeyCode.KEY_L,  KeyFlag.Control|KeyFlag.Option)).disableByDefault();
182 const Action ACTION_GO_TO_PREV_POSITION = (new Action(IDEActions.GotoPrevPosition,  "GO_TO_PREV_POSITION"c, ""c, KeyCode.LEFT,  KeyFlag.Alt)).disableByDefault();
183 const Action ACTION_GO_TO_NEXT_POSITION = (new Action(IDEActions.GotoNextPosition,  "GO_TO_NEXT_POSITION"c, ""c, KeyCode.RIGHT,  KeyFlag.Alt)).disableByDefault();
184 
185 const Action ACTION_FIND_TEXT = (new Action(IDEActions.FindInFiles,  "FIND_IN_FILES"c, "edit-find"c, KeyCode.KEY_F, KeyFlag.Control | KeyFlag.Shift)).disableByDefault();
186 const Action ACTION_TOOLS_OPEN_DMD_TRACE_LOG = (new Action(IDEActions.ToolsOpenDMDTraceLog,  "OPEN_DMD_TRACE_LOG"c));
187 
188 
189 const Action[] STD_IDE_ACTIONS = [
190     ACTION_EDIT_COPY, ACTION_EDIT_PASTE, ACTION_EDIT_CUT,
191     ACTION_EDIT_UNDO, ACTION_EDIT_REDO,
192     ACTION_EDIT_INDENT, ACTION_EDIT_UNINDENT,
193     ACTION_EDIT_TOGGLE_LINE_COMMENT, ACTION_EDIT_TOGGLE_BLOCK_COMMENT,
194     ACTION_EDIT_PREFERENCES, 
195     ACTION_FILE_NEW_SOURCE_FILE, ACTION_FILE_NEW_WORKSPACE, ACTION_FILE_NEW_PROJECT, ACTION_FILE_OPEN_WORKSPACE, ACTION_FILE_OPEN,
196     ACTION_FILE_SAVE, ACTION_FILE_SAVE_AS, ACTION_FILE_SAVE_ALL, ACTION_FILE_EXIT,
197     ACTION_PROJECT_SET_STARTUP, ACTION_PROJECT_REFRESH, ACTION_PROJECT_UPDATE_DEPENDENCIES,
198     ACTION_PROJECT_SETTINGS, ACTION_WORKSPACE_BUILD, ACTION_WORKSPACE_REBUILD, ACTION_WORKSPACE_CLEAN,
199     ACTION_PROJECT_BUILD, ACTION_PROJECT_REBUILD, ACTION_PROJECT_CLEAN, ACTION_RUN_WITH_RDMD,
200     ACTION_DEBUG_START, ACTION_DEBUG_START_NO_DEBUG, ACTION_DEBUG_CONTINUE, ACTION_DEBUG_STOP, ACTION_DEBUG_PAUSE,
201     ACTION_DEBUG_RESTART,
202     ACTION_DEBUG_STEP_INTO,
203     ACTION_DEBUG_STEP_OVER,
204     ACTION_DEBUG_STEP_OUT,
205     ACTION_WINDOW_CLOSE_DOCUMENT, ACTION_WINDOW_CLOSE_ALL_DOCUMENTS, ACTION_HELP_ABOUT,
206     ACTION_GET_DOC_COMMENTS,
207     ACTION_GO_TO_DEFINITION,
208     ACTION_GET_COMPLETIONS,
209     ACTION_GET_PAREN_COMPLETION,
210     ACTION_GO_TO_LINE,
211     ACTION_GO_TO_PREV_POSITION,
212     ACTION_GO_TO_NEXT_POSITION,
213     ACTION_FIND_TEXT,
214 ];