1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 15:48:00 +01:00

Add 'altwildmode'.

This commit is contained in:
Kris Maglione
2010-09-18 01:48:46 -04:00
parent 3fe0b9238f
commit bda1e1c260
4 changed files with 52 additions and 29 deletions

View File

@@ -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 <Tab> 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);

View File

@@ -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",

View File

@@ -321,6 +321,18 @@
</description>
</item>
<item>
<tags>'awim' 'altwildmode'</tags>
<spec>'altwildmode' 'awim'</spec>
<type>stringlist</type>
<default>list:full</default>
<description>
<p>
Like <o>wildmode</o>, but when the <k name="Alt"/> key is pressed.
</p>
</description>
</item>
<item>
<tags>'au' 'autocomplete'</tags>
<spec>'autocomplete' 'au'</spec>
@@ -1418,6 +1430,10 @@
</dd>
</dl>
<p>
See also <o>altwildmode</o>.
</p>
</description>
</item>

View File

@@ -19,6 +19,7 @@
backspace.
- Supports reverse incremental search.
* Replaced 'focuscontent' with 'strictfocus'
* Added 'altwildmode' and <A-Tab> commandline key binding
* Added 'banghist' option
* gf now toggles between source and content view.
The | key binding has been removed.