From cda623a95c6d360afd72d07b38dfdc582843107f Mon Sep 17 00:00:00 2001 From: Gabe Cohen Date: Sat, 9 Dec 2017 23:08:28 -0600 Subject: [PATCH] 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. --- CliClient/app/app-gui.js | 7 +++++-- CliClient/app/gui/StatusBarWidget.js | 13 ++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CliClient/app/app-gui.js b/CliClient/app/app-gui.js index 39ec44a8b..019694f0d 100644 --- a/CliClient/app/app-gui.js +++ b/CliClient/app/app-gui.js @@ -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; \ No newline at end of file +module.exports = AppGui; diff --git a/CliClient/app/gui/StatusBarWidget.js b/CliClient/app/gui/StatusBarWidget.js index 9b339a5a9..4e51881ef 100644 --- a/CliClient/app/gui/StatusBarWidget.js +++ b/CliClient/app/gui/StatusBarWidget.js @@ -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; \ No newline at end of file +module.exports = StatusBarWidget;