Merge pull request #294 from shiche/292-GoToLine

292 go to line
This commit is contained in:
Vadim Lopatin 2017-09-13 17:35:33 +03:00 committed by GitHub
commit bf0e340e16
4 changed files with 33 additions and 1 deletions

View File

@ -62,6 +62,7 @@ enum IDEActions : int {
GetCompletionSuggestions,
GetDocComments,
GetParenCompletion,
GotoLine,
InsertCompletion,
FindInFiles,
@ -143,5 +144,6 @@ const Action ACTION_GET_DOC_COMMENTS = (new Action(IDEActions.GetDocComments, "
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();
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();
const Action ACTION_GET_PAREN_COMPLETION = (new Action(IDEActions.GetParenCompletion, "SHOW_PAREN_COMPLETION"c, ""c, KeyCode.SPACE, KeyFlag.Control|KeyFlag.Shift)).disableByDefault();
const Action ACTION_GO_TO_LINE = (new Action(IDEActions.GotoLine, "GO_TO_LINE"c, ""c, KeyCode.KEY_L, KeyFlag.Control|KeyFlag.Option)).disableByDefault();;
const Action ACTION_FIND_TEXT = (new Action(IDEActions.FindInFiles, "FIND_IN_FILES"c, "edit-find"c, KeyCode.KEY_F, KeyFlag.Control | KeyFlag.Shift)).disableByDefault();

View File

@ -709,7 +709,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
editItem.add(ACTION_EDIT_PREFERENCES);
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, ACTION_EDITOR_GOTO_NEXT_BOOKMARK);
navItem.add(ACTION_GO_TO_DEFINITION, ACTION_GET_COMPLETIONS, ACTION_GET_DOC_COMMENTS,
ACTION_GET_PAREN_COMPLETION, ACTION_EDITOR_GOTO_PREVIOUS_BOOKMARK,
ACTION_EDITOR_GOTO_NEXT_BOOKMARK, ACTION_GO_TO_LINE);
MenuItem projectItem = new MenuItem(new Action(21, "MENU_PROJECT"));
projectItem.add(ACTION_PROJECT_SET_STARTUP, ACTION_PROJECT_REFRESH, ACTION_PROJECT_UPDATE_DEPENDENCIES, ACTION_PROJECT_SETTINGS);
@ -1080,6 +1082,28 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
currentEditor.editorTool.goToDefinition(currentEditor(), currentEditor.caretPos);
}
return true;
case IDEActions.GotoLine:
// Go to line without editor is meaningless command
if (currentEditor) {
Log.d("Go to line");
// Ask user for line
window.showInputBox(UIString.fromId("GO_TO_LINE"c), UIString.fromId("GO_TO_LINE"c), ""d, delegate(dstring s) {
try {
auto num = to!uint(s);
// Check line existence
if (num < 1 || num > currentEditor.content.length) {
window.showMessageBox(UIString.fromId("ERROR"c), UIString.fromId("ERROR_NO_SUCH_LINE"c));
return;
}
// Go to line
currentEditor.setCaretPos(num - 1, 0);
}
catch (ConvException e) {
window.showMessageBox(UIString.fromId("ERROR"c), UIString.fromId("ERROR_INVALID_NUMBER"c));
}
});
}
return true;
case IDEActions.GetDocComments:
Log.d("Trying to get doc comments.");
currentEditor.editorTool.getDocComments(currentEditor, currentEditor.caretPos, delegate(string[] results) {

View File

@ -66,6 +66,7 @@ GO_TO_DEFINITION=Go to definition
SHOW_COMPLETIONS=Get autocompletions
SHOW_DOC_COMMENTS=Show documentation
SHOW_PAREN_COMPLETION=Call hints
GO_TO_LINE=Go to line
FIND_IN_FILES=Find in files...
@ -206,10 +207,12 @@ ERROR_CANNOT_FIND_EXEC=Cannot find executable file
ERROR_CANNOT_RUN_PROJECT=Cannot run project
ERROR_FAILED_CREATE_PROJECT=Failed to create project
ERROR_STARTUP_PROJECT_ABSENT=Startup project is not specified
ERROR_INVALID_NUMBER=Invalid number
ERROR_INVALID_PARAMETERS=Invalid parameters
ERROR_INVALID_WORKSPACE_FILE=Invalid workspace file
ERROR_INVALID_WS_OR_PROJECT_FILE=This file is not a valid workspace or project file
ERROR_NO_DEBUGGER=No debugger executable specified in settings
ERROR_NO_SUCH_LINE=No such line
ERROR_OPEN_FILE=File open error
ERROR_OPEN_PROJECT=Cannot open project
ERROR_OPEN_WORKSPACE=Cannot open workspace

View File

@ -66,6 +66,7 @@ GO_TO_DEFINITION=Перейти к определению
SHOW_COMPLETIONS=Автозавершение
SHOW_DOC_COMMENTS=Показать документацию
SHOW_PAREN_COMPLETION=Показать параметры вызова
GO_TO_LINE=Перейти к строке
FIND_IN_FILES=Найти в файлах...
@ -205,10 +206,12 @@ ERROR_CANNOT_FIND_EXEC=Не могу найти исполняемый файл
ERROR_CANNOT_RUN_PROJECT=Невозможно запустить проект
ERROR_FAILED_CREATE_PROJECT=Ошибка создания проекта
ERROR_STARTUP_PROJECT_ABSENT=Стартовый проект не указан
ERROR_INVALID_NUMBER=Неверное число
ERROR_INVALID_PARAMETERS=Неверные параметры
ERROR_INVALID_WORKSPACE_FILE=Неверный файл раб.пространства
ERROR_INVALID_WS_OR_PROJECT_FILE=Файл не является ни файлом раб.пространства, ни проектным
ERROR_NO_DEBUGGER=Отладчика нет в настройках
ERROR_NO_SUCH_LINE=Строка не существует
ERROR_OPEN_FILE=Невозможно открыть файл
ERROR_OPEN_PROJECT=Невозможно открыть проект
ERROR_OPEN_WORKSPACE=Невозможно открыть рабочее пространство