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

@ -206,7 +206,10 @@ class AppGui {
};
consoleWidget.hide();
const statusBar = new StatusBarWidget();
const statusBar = new StatusBarWidget();
this.app().commandNames().then((names)=>{
statusBar.setAutoComplete(names);
});
statusBar.hStretch = true;
const noteLayout = new VLayoutWidget();
@ -826,4 +829,4 @@ class AppGui {
AppGui.INPUT_MODE_NORMAL = 1;
AppGui.INPUT_MODE_META = 2;
module.exports = AppGui;
module.exports = AppGui;

View File

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