diff --git a/common/content/commandline.js b/common/content/commandline.js index a838e4bd..faf2104c 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1008,41 +1008,7 @@ var CommandLine = Module("commandline", { let key = events.toString(event); if (this._completions) this._completions.previewClear(); - if (!this.currentExtendedMode) - return PASS; - // user pressed to carry out a command - // user pressing is handled in the global onEscape - // FIXME: should trigger "cancel" event - if (events.isAcceptKey(key)) { - this._keepCommand = userContext.hidden_option_command_afterimage; - let mode = this.currentExtendedMode; - this.currentExtendedMode = null; // Don't let modes.pop trigger "cancel" - modes.pop(); - commandline.triggerCallback("submit", mode, command); - } - // user pressed or arrow to cycle history completion - else if (/^<(Up|Down|S-Up|S-Down)>$/.test(key)) { - dactyl.assert(this._history); - this._history.select(/Up/.test(key), !/S-/.test(key)); - return KILL; - } - // user pressed to get completions of a command - else if (/^<(?:A-)?(?:S-)?Tab>$/.test(key)) { - this._tabTimer.tell(event); - return KILL; - } - else if (key == "") { - // reset the tab completion - //this.resetCompletions(); - - // and blur the command line if there is no text left - if (command.length == 0) { - commandline.triggerCallback("cancel", this.currentExtendedMode); - modes.pop(); - } - } - // allow this event to be handled by the host app return PASS; } else if (event.type == "keyup") { @@ -1717,6 +1683,47 @@ var CommandLine = Module("commandline", { return Events.PASS; }); + mappings.add([modes.COMMAND_LINE], + ["", "", ""], "Accept the current input", + function (args) { + commandline._keepCommand = userContext.hidden_option_command_afterimage; + let mode = commandline.currentExtendedMode; + commandline.currentExtendedMode = null; // Don't let modes.pop trigger "cancel" + modes.pop(); + commandline.triggerCallback("submit", mode, commandline.command); + }); + + [ + [["", ""], "previous matching", true, true], + [["", "", ""], "previous", true, false], + [["", ""], "next matching", false, true], + [["", "", ""], "next", false, false] + ].forEach(function ([keys, desc, up, search]) { + mappings.add([modes.COMMAND_LINE], + keys, "Recall the " + desc + " command line from the history list", + function (args) { + dactyl.assert(commandline._history); + commandline._history.select(up, search); + }); + }); + + mappings.add([modes.COMMAND_LINE], + ["", ""], "Select the next matching completion item", + function ({ events }) { commandline._tabTimer.tell(events[0]); }); + + mappings.add([modes.COMMAND_LINE], + ["", ""], "Select the previous matching completion item", + function ({ events }) { commandline._tabTimer.tell(events[0]); }); + + mappings.add([modes.COMMAND_LINE], + ["", ""], "Delete the previous character", + function () { + if (!commandline.command) + modes.pop(); + else + return Events.PASS; + }); + mappings.add([modes.COMMAND_LINE], ["", ""], "Expand command line abbreviation", function () { editor.expandAbbreviation(modes.COMMAND_LINE); }); @@ -1728,14 +1735,6 @@ var CommandLine = Module("commandline", { commandline._echoMultiline(commandline._lastMowOutput, commandline.HL_NORMAL); }); - mappings.add([modes.COMMAND_LINE], - ["", ""], "Recall the previous command line from the history list", - function () { events.feedkeys(""); }); - - mappings.add([modes.COMMAND_LINE], - ["", ""], "Recall the next command line from the history list", - function () { events.feedkeys(""); }); - // add the ":" mapping in all but insert mode mappings mappings.add(modes.COMMAND, [":"], "Enter command-line mode",