mirror of https://github.com/buggins/dlangide.git
Add autocomplete to editor popup and added Show Completions translation
This commit is contained in:
parent
2b438dd653
commit
0ebdc67c96
|
@ -96,4 +96,4 @@ const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowClo
|
||||||
const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "Create new workspace"d);
|
const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "Create new workspace"d);
|
||||||
const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "Add to current workspace"d);
|
const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "Add to current workspace"d);
|
||||||
const Action ACTION_GO_TO_DEFINITION = new Action(IDEActions.GoToDefinition, "GO_TO_DEFINITION"c, ""c, KeyCode.KEY_G, KeyFlag.Control);
|
const Action ACTION_GO_TO_DEFINITION = new Action(IDEActions.GoToDefinition, "GO_TO_DEFINITION"c, ""c, KeyCode.KEY_G, KeyFlag.Control);
|
||||||
const Action ACTION_GET_COMPLETIONS = new Action(IDEActions.GetCompletionSuggestions, "GO_TO_DEFINITION"c, ""c, KeyCode.KEY_G, KeyFlag.Control|KeyFlag.Shift);
|
const Action ACTION_GET_COMPLETIONS = new Action(IDEActions.GetCompletionSuggestions, "SHOW_COMPLETIONS"c, ""c, KeyCode.KEY_G, KeyFlag.Control|KeyFlag.Shift);
|
|
@ -31,7 +31,7 @@ class DSourceEdit : SourceEdit {
|
||||||
setTokenHightlightColor(TokenCategory.Comment_Documentation, 0x206000);
|
setTokenHightlightColor(TokenCategory.Comment_Documentation, 0x206000);
|
||||||
//setTokenHightlightColor(TokenCategory.Identifier, 0x206000); // no colors
|
//setTokenHightlightColor(TokenCategory.Identifier, 0x206000); // no colors
|
||||||
MenuItem editPopupItem = new MenuItem(null);
|
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);
|
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, ACTION_GET_COMPLETIONS);
|
||||||
popupMenu = editPopupItem;
|
popupMenu = editPopupItem;
|
||||||
showIcons = true;
|
showIcons = true;
|
||||||
showFolding = true;
|
showFolding = true;
|
||||||
|
@ -95,20 +95,28 @@ class DSourceEdit : SourceEdit {
|
||||||
|
|
||||||
|
|
||||||
void showCompletionPopup(dstring[] suggestions) {
|
void showCompletionPopup(dstring[] suggestions) {
|
||||||
MenuItem completionPopupItem = new MenuItem(null);
|
|
||||||
//Create popup menu
|
if(suggestions.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem completionPopupItems = new MenuItem(null);
|
||||||
|
//Add all the suggestions.
|
||||||
foreach(int i, dstring suggestion ; suggestions) {
|
foreach(int i, dstring suggestion ; suggestions) {
|
||||||
auto action = new Action(IDEActions.InsertCompletion, suggestion);
|
auto action = new Action(IDEActions.InsertCompletion, suggestion);
|
||||||
completionPopupItem.add(action);
|
completionPopupItems.add(action);
|
||||||
}
|
}
|
||||||
completionPopupItem.updateActionState(this);
|
completionPopupItems.updateActionState(this);
|
||||||
PopupMenu popupMenu = new PopupMenu(completionPopupItem);
|
|
||||||
|
PopupMenu popupMenu = new PopupMenu(completionPopupItems);
|
||||||
popupMenu.onMenuItemActionListener = this;
|
popupMenu.onMenuItemActionListener = this;
|
||||||
popupMenu.maxHeight(400);
|
popupMenu.maxHeight(400);
|
||||||
popupMenu.selectItem(0);
|
popupMenu.selectItem(0);
|
||||||
|
|
||||||
PopupWidget popup = window.showPopup(popupMenu, this, PopupAlign.Point | PopupAlign.Right, textPosToClient(_caretPos).left + left + _leftPaneWidth, textPosToClient(_caretPos).top + top + margins.top);
|
PopupWidget popup = window.showPopup(popupMenu, this, PopupAlign.Point | PopupAlign.Right, textPosToClient(_caretPos).left + left + _leftPaneWidth, textPosToClient(_caretPos).top + top + margins.top);
|
||||||
popup.setFocus();
|
popup.setFocus();
|
||||||
popup.flags = PopupFlags.CloseOnClickOutside;
|
popup.flags = PopupFlags.CloseOnClickOutside;
|
||||||
|
|
||||||
Log.d("Showing popup at ", textPosToClient(_caretPos).left, " ", textPosToClient(_caretPos).top);
|
Log.d("Showing popup at ", textPosToClient(_caretPos).left, " ", textPosToClient(_caretPos).top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,10 @@ MENU_HELP=&HELP
|
||||||
MENU_HELP_VIEW_HELP=&View help
|
MENU_HELP_VIEW_HELP=&View help
|
||||||
MENU_HELP_ABOUT=&About
|
MENU_HELP_ABOUT=&About
|
||||||
GO_TO_DEFINITION=Go To Definition
|
GO_TO_DEFINITION=Go To Definition
|
||||||
|
SHOW_COMPLETIONS=Get Autocompletions
|
||||||
MENU_NAVIGATE=NAVIGATE
|
MENU_NAVIGATE=NAVIGATE
|
||||||
|
|
||||||
|
|
||||||
TAB_LONG_LIST=Long list
|
TAB_LONG_LIST=Long list
|
||||||
TAB_BUTTONS=Buttons
|
TAB_BUTTONS=Buttons
|
||||||
TAB_ANIMATION=Animation
|
TAB_ANIMATION=Animation
|
||||||
|
|
Loading…
Reference in New Issue