1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Added command auto complete

File based autocompletion is not yet implemented. This will require knowledge of
the command, and it's parameters. The autocomplete feture is pretty powerful
however, so this should not be very difficult to add.
This commit is contained in:
Gabe Cohen 2017-12-09 23:08:28 -06:00
parent 0f343bccda
commit cda623a95c
2 changed files with 15 additions and 5 deletions

View File

@ -207,6 +207,9 @@ class AppGui {
consoleWidget.hide(); consoleWidget.hide();
const statusBar = new StatusBarWidget(); const statusBar = new StatusBarWidget();
this.app().commandNames().then((names)=>{
statusBar.setAutoComplete(names);
});
statusBar.hStretch = true; statusBar.hStretch = true;
const noteLayout = new VLayoutWidget(); const noteLayout = new VLayoutWidget();

View File

@ -5,13 +5,14 @@ const stripAnsi = require('strip-ansi');
class StatusBarWidget extends BaseWidget { class StatusBarWidget extends BaseWidget {
constructor() { constructor(autoComplete = null) {
super(); super();
this.promptState_ = null; this.promptState_ = null;
this.inputEventEmitter_ = null; this.inputEventEmitter_ = null;
this.history_ = []; this.history_ = [];
this.items_ = []; this.items_ = [];
this.autoComplete = autoComplete;
} }
get name() { get name() {
@ -22,6 +23,9 @@ class StatusBarWidget extends BaseWidget {
return false; return false;
} }
setAutoComplete(auto) {
this.autoComplete = auto;
}
setItemAt(index, text) { setItemAt(index, text) {
this.items_[index] = stripAnsi(text).trim(); this.items_[index] = stripAnsi(text).trim();
this.invalidate(); this.invalidate();
@ -108,6 +112,9 @@ class StatusBarWidget extends BaseWidget {
cancelable: true, cancelable: true,
history: this.history, history: this.history,
default: this.promptState_.initialText, default: this.promptState_.initialText,
autoComplete: this.autoComplete,
autoCompleteMenu: true,
autoCompleteHint : true,
}; };
if ('cursorPosition' in this.promptState_) options.cursorPosition = this.promptState_.cursorPosition; if ('cursorPosition' in this.promptState_) options.cursorPosition = this.promptState_.cursorPosition;