diff --git a/common/content/commandline.js b/common/content/commandline.js index 9039b7b1..0f2a6024 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -95,7 +95,7 @@ const CommandLine = Module("commandline", { this._tabTimer = Timer(0, 0, function tabTell(event) { dactyl.trapErrors(function () { if (self._completions) - self._completions.tab(event.shiftKey); + self._completions.tab(event.shiftKey, event.altKey && options.get("altwildmode").values); }); }); @@ -658,7 +658,7 @@ const CommandLine = Module("commandline", { this._history.select(/Up/.test(key), !/(Page|S-)/.test(key)); } // user pressed to get completions of a command - else if (/^<(Tab|S-Tab)>$/.test(key)) { + else if (/^<(?:A-)?(?:S-)?Tab>$/.test(key)) { // prevent tab from moving to the next field event.preventDefault(); event.stopPropagation(); @@ -682,7 +682,7 @@ const CommandLine = Module("commandline", { } else if (event.type == "keyup") { let key = events.toString(event); - if (/^<(Tab|S-Tab)>$/.test(key)) + if (/^<(?:A-)?(?:S-)?Tab>$/.test(key)) this._tabTimer.flush(); } } @@ -1120,6 +1120,7 @@ const CommandLine = Module("commandline", { this.editor = input.editor; this.selected = null; this.wildmode = options.get("wildmode"); + this.wildtypes = this.wildmode.values; this.itemList = commandline._completionList; this.itemList.setItems(this.context); this.reset(); @@ -1162,8 +1163,6 @@ const CommandLine = Module("commandline", { get wildtype() this.wildtypes[this.wildIndex] || "", - get wildtypes() this.wildmode.values, - complete: function complete(show, tabPressed) { this.context.reset(); this.context.tabPressed = tabPressed; @@ -1331,20 +1330,20 @@ const CommandLine = Module("commandline", { tabs: [], - tab: function tab(reverse) { + tab: function tab(reverse, wildmode) { commandline._autocompleteTimer.flush(); // Check if we need to run the completer. if (this.context.waitingForTab || this.wildIndex == -1) this.complete(true, true); - this.tabs.push(reverse); + this.tabs.push([reverse, wildmode || options.get("wildmode").values]); if (this.waiting) return; while (this.tabs.length) { - this.wildIndex = Math.min(this.wildIndex, this.wildtypes.length - 1); + [reverse, this.wildtypes] = this.tabs.shift(); - reverse = this.tabs.shift(); + this.wildIndex = Math.min(this.wildIndex, this.wildtypes.length - 1); switch (this.wildtype.replace(/.*:/, "")) { case "": this.select(0); diff --git a/common/content/completion.js b/common/content/completion.js index 60804046..ee53829e 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -811,6 +811,32 @@ const Completion = Module("completion", { }); }, options: function () { + let wildmode = { + completer: function (context) [ + // Why do we need ""? + // Because its description is useful during completion. --Kris + ["", "Complete only the first match"], + ["full", "Complete the next full match"], + ["longest", "Complete to longest common string"], + ["list", "If more than one match, list all matches"], + ["list:full", "List all and complete first match"], + ["list:longest", "List all and complete common string"] + ], + checkHas: function (value, val) { + let [first, second] = value.split(":", 2); + return first == val || second == val; + }, + has: function () { + test = function (val) this.values.some(function (value) this.checkHas(value, val), this); + return Array.some(arguments, test, this); + } + }; + + options.add(["altwildmode", "awim"], + "Define how command line completion works when the Alt key is pressed", + "stringlist", "list:full", + wildmode); + options.add(["autocomplete", "au"], "Automatically update the completion list on any key press", "regexlist", ".*"); @@ -836,26 +862,7 @@ const Completion = Module("completion", { options.add(["wildmode", "wim"], "Define how command line completion works", "stringlist", "list:full", - { - completer: function (context) [ - // Why do we need ""? - // Because its description is useful during completion. --Kris - ["", "Complete only the first match"], - ["full", "Complete the next full match"], - ["longest", "Complete to longest common string"], - ["list", "If more than one match, list all matches"], - ["list:full", "List all and complete first match"], - ["list:longest", "List all and complete common string"] - ], - checkHas: function (value, val) { - let [first, second] = value.split(":", 2); - return first == val || second == val; - }, - has: function () { - test = function (val) this.values.some(function (value) this.checkHas(value, val), this); - return Array.some(arguments, test, this); - } - }); + wildmode); options.add(["wildsort", "wis"], "Regexp list of which contexts to sort", diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml index 23753848..856a161f 100644 --- a/common/locale/en-US/options.xml +++ b/common/locale/en-US/options.xml @@ -321,6 +321,18 @@ + + 'awim' 'altwildmode' + 'altwildmode' 'awim' + stringlist + list:full + +

+ Like wildmode, but when the key is pressed. +

+
+
+ 'au' 'autocomplete' 'autocomplete' 'au' @@ -1418,6 +1430,10 @@ +

+ See also altwildmode. +

+
diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index b6089a40..cf870dce 100755 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -19,6 +19,7 @@ backspace. - Supports reverse incremental search. * Replaced 'focuscontent' with 'strictfocus' + * Added 'altwildmode' and commandline key binding * Added 'banghist' option * gf now toggles between source and content view. The | key binding has been removed.