mirror of https://github.com/buggins/dlangide.git
Add autocompletion on each key press
This commit is contained in:
parent
daeb6f58af
commit
0dee6cb1f1
|
@ -641,7 +641,8 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener {
|
|||
return;
|
||||
}
|
||||
|
||||
if (suggestions.length == 1) {
|
||||
// Only insert singular autocompletion if automatic autocomplete is turned off!
|
||||
if (!_settings.autoAutoComplete && suggestions.length == 1) {
|
||||
insertCompletion(suggestions[0]);
|
||||
return;
|
||||
}
|
||||
|
@ -721,13 +722,23 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener {
|
|||
super.handleFocusChange(focused, receivedFocusFromKeyboard);
|
||||
}
|
||||
|
||||
private bool isAutoCompleteKey(ref KeyEvent event) {
|
||||
if((event.keyCode >= KeyCode.KEY_0 && event.keyCode <= KeyCode.KEY_Z) ||
|
||||
event.keyCode == KeyCode.KEY_PERIOD)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected uint _lastKeyDownCode;
|
||||
protected uint _periodKeyCode;
|
||||
/// handle keys: support autocompletion after . press with delay
|
||||
override bool onKeyEvent(KeyEvent event) {
|
||||
if (event.action == KeyAction.KeyDown)
|
||||
_lastKeyDownCode = event.keyCode;
|
||||
if (event.action == KeyAction.Text && event.noModifiers && event.text==".") {
|
||||
if(_settings.autoAutoComplete && !_completionPopup) {
|
||||
window.dispatchAction(ACTION_GET_COMPLETIONS, this);
|
||||
}
|
||||
else if (event.action == KeyAction.Text && event.noModifiers && event.text==".") {
|
||||
_periodKeyCode = _lastKeyDownCode;
|
||||
startCompletionTimer();
|
||||
} else {
|
||||
|
|
|
@ -76,7 +76,7 @@ SettingsPage createSettingsPages() {
|
|||
StringListValue("ru", "MENU_VIEW_LANGUAGE_RU"c),
|
||||
StringListValue("es", "MENU_VIEW_LANGUAGE_ES"c),
|
||||
StringListValue("de", "MENU_VIEW_LANGUAGE_DE"c),
|
||||
StringListValue("cs", "MENU_VIEW_LANGUAGE_CS"c)]);
|
||||
StringListValue("cs", "MENU_VIEW_LANGUAGE_CS"c)]);
|
||||
|
||||
// UI font faces
|
||||
ui.addStringComboBox("interface/uiFontFace", UIString.fromId("OPTION_FONT_FACE"c),
|
||||
|
@ -144,6 +144,7 @@ SettingsPage createSettingsPages() {
|
|||
texted.addCheckbox("editors/textEditor/smartIndentsAfterPaste", UIString.fromId("OPTION_SMART_INDENTS_PASTE"c));
|
||||
texted.addCheckbox("editors/textEditor/showWhiteSpaceMarks", UIString.fromId("OPTION_SHOW_SPACES"c));
|
||||
texted.addCheckbox("editors/textEditor/showTabPositionMarks", UIString.fromId("OPTION_SHOW_TABS"c));
|
||||
texted.addCheckbox("editors/textEditor/autoAutoComplete", UIString.fromId("OPTION_AUTO_AUTOCOMPLETE"c));
|
||||
|
||||
// Common page
|
||||
SettingsPage common = res.addChild("common", UIString.fromId("OPTION_COMMON"c));
|
||||
|
|
|
@ -23,6 +23,7 @@ class IDESettings : SettingsFile {
|
|||
ed.setBooleanDef("smartIndentsAfterPaste", true);
|
||||
ed.setBooleanDef("showWhiteSpaceMarks", true);
|
||||
ed.setBooleanDef("showTabPositionMarks", true);
|
||||
ed.setBooleanDef("autoAutoComplete", true);
|
||||
ed.setStringDef("fontFace", "Default");
|
||||
ed.setIntegerDef("fontSize", 11);
|
||||
Setting ui = uiSettings();
|
||||
|
@ -171,6 +172,16 @@ class IDESettings : SettingsFile {
|
|||
return this;
|
||||
}
|
||||
|
||||
/// Text editor setting, true if auto-complete is triggered on each key press
|
||||
@property bool autoAutoComplete() {
|
||||
return editorSettings.getBoolean("autoAutoComplete", true);
|
||||
}
|
||||
///
|
||||
@property IDESettings autoAutoComplete(bool v) {
|
||||
editorSettings.setBoolean("autoAutoComplete", v);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// true if smart indents are enabled
|
||||
@property bool smartIndents() { return editorSettings.getBoolean("smartIndents", true); }
|
||||
/// set smart indents enabled flag
|
||||
|
|
|
@ -227,6 +227,7 @@ OPTION_VERBOSE=Verbose
|
|||
OPTION_WORKING_DIR=Working directory
|
||||
OPTION_WORKSPACE_NAME=Workspace name
|
||||
OPTION_USE_SPACES=Use spaces for tabs
|
||||
OPTION_AUTO_AUTOCOMPLETE=Automatically suggest auto completion
|
||||
|
||||
ERROR=Error
|
||||
ERROR_CANNOT_CREATE_PROJECT=Cannot create project
|
||||
|
|
|
@ -221,6 +221,7 @@ OPTION_VERBOSE=Показать подробности
|
|||
OPTION_WORKING_DIR=Рабочий каталог
|
||||
OPTION_WORKSPACE_NAME=Имя рабочего пространства
|
||||
OPTION_USE_SPACES=Использовать пробелы вместо табуляции
|
||||
OPTION_AUTO_AUTOCOMPLETE=Автоматически предлагать дополнение кода
|
||||
|
||||
ERROR=Ошибка
|
||||
ERROR_CANNOT_CREATE_PROJECT=Не могу создать проект
|
||||
|
|
Loading…
Reference in New Issue