mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-28 15:15:46 +01:00
Give up and add key chains to 'passkeys'. Also add <A-b> to execute a builtin mapping. Closes issue #189.
This commit is contained in:
@@ -148,6 +148,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
|||||||
onLocationChange.superapply(this, arguments);
|
onLocationChange.superapply(this, arguments);
|
||||||
|
|
||||||
contexts.flush();
|
contexts.flush();
|
||||||
|
options.get("passkeys").flush();
|
||||||
|
|
||||||
statusline.updateUrl();
|
statusline.updateUrl();
|
||||||
statusline.progress = "";
|
statusline.progress = "";
|
||||||
|
|||||||
@@ -9,13 +9,19 @@
|
|||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
var ProcessorStack = Class("ProcessorStack", {
|
var ProcessorStack = Class("ProcessorStack", {
|
||||||
init: function (mode, hives, keyModes) {
|
init: function (mode, hives, builtin) {
|
||||||
this.main = mode.main;
|
this.main = mode.main;
|
||||||
this._actions = [];
|
this._actions = [];
|
||||||
this.actions = [];
|
this.actions = [];
|
||||||
this.buffer = "";
|
this.buffer = "";
|
||||||
this.events = [];
|
this.events = [];
|
||||||
|
|
||||||
|
let main = { __proto__: mode.main, params: mode.params };
|
||||||
|
let keyModes = array([mode.params.keyModes, main, mode.main.allBases]).flatten().compact();
|
||||||
|
|
||||||
|
if (builtin)
|
||||||
|
hives = hives.filter(function (h) h.name === "builtin");
|
||||||
|
|
||||||
this.processors = keyModes.map(function (m) hives.map(function (h) KeyProcessor(m, h)))
|
this.processors = keyModes.map(function (m) hives.map(function (h) KeyProcessor(m, h)))
|
||||||
.flatten().array;
|
.flatten().array;
|
||||||
this.ownsBuffer = !this.processors.some(function (p) p.main.ownsBuffer);
|
this.ownsBuffer = !this.processors.some(function (p) p.main.ownsBuffer);
|
||||||
@@ -31,6 +37,9 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
return params.onKeyPress(events) === false ? Events.KILL : Events.PASS;
|
return params.onKeyPress(events) === false ? Events.KILL : Events.PASS;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!builtin && (!dactyl.focusedElement || events.isContentNode(dactyl.focusedElement)))
|
||||||
|
this.processors.unshift(KeyProcessor(modes.BASE, options.get("passkeys").hive));
|
||||||
},
|
},
|
||||||
|
|
||||||
notify: function () {
|
notify: function () {
|
||||||
@@ -1207,12 +1216,7 @@ var Events = Module("events", {
|
|||||||
if (config.ignoreKeys[key] & mode.main)
|
if (config.ignoreKeys[key] & mode.main)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
let hives = mappings.hives.slice(event.noremap ? -1 : 0);
|
this.processor = ProcessorStack(mode, mappings.hives.array, event.noremap);
|
||||||
|
|
||||||
let main = { __proto__: mode.main, params: mode.params };
|
|
||||||
let keyModes = array([mode.params.keyModes, main, mode.main.allBases]).flatten().compact();
|
|
||||||
|
|
||||||
this.processor = ProcessorStack(mode, hives, keyModes);
|
|
||||||
this.processor.allEvents = this.keyEvents;
|
this.processor.allEvents = this.keyEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1392,7 +1396,7 @@ var Events = Module("events", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
shouldPass: function shouldPass(event)
|
shouldPass: function shouldPass(event)
|
||||||
(!dactyl.focusedElement || events.isContentNode(dactyl.focusedElement)) &&
|
!event.noremap && (!dactyl.focusedElement || events.isContentNode(dactyl.focusedElement)) &&
|
||||||
options.get("passkeys").has(events.toString(event))
|
options.get("passkeys").has(events.toString(event))
|
||||||
}, {
|
}, {
|
||||||
ABORT: {},
|
ABORT: {},
|
||||||
@@ -1460,6 +1464,14 @@ var Events = Module("events", {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mappings: function () {
|
mappings: function () {
|
||||||
|
|
||||||
|
mappings.add(modes.MAIN,
|
||||||
|
["<A-b>"], "Process the next key as a builtin mapping",
|
||||||
|
function () {
|
||||||
|
events.processor = ProcessorStack(modes.getStack(0), mappings.hives.array, true);
|
||||||
|
events.processor.allEvents = events.keyEvents;
|
||||||
|
});
|
||||||
|
|
||||||
mappings.add(modes.MAIN,
|
mappings.add(modes.MAIN,
|
||||||
["<C-z>", "<pass-all-keys>"], "Temporarily ignore all " + config.appName + " key bindings",
|
["<C-z>", "<pass-all-keys>"], "Temporarily ignore all " + config.appName + " key bindings",
|
||||||
function () { modes.push(modes.PASS_THROUGH); });
|
function () { modes.push(modes.PASS_THROUGH); });
|
||||||
@@ -1518,18 +1530,35 @@ var Events = Module("events", {
|
|||||||
options.add(["passkeys", "pk"],
|
options.add(["passkeys", "pk"],
|
||||||
"Pass certain keys through directly for the given URLs",
|
"Pass certain keys through directly for the given URLs",
|
||||||
"sitemap", "", {
|
"sitemap", "", {
|
||||||
has: function (key) {
|
flush: function flush() {
|
||||||
let uri = buffer.documentURI;
|
memoize(this, "hive", function hive()
|
||||||
for (let filter in values(this.value))
|
let (values = this.value.filter(function (f) f(buffer.documentURI))) {
|
||||||
if (filter(uri) && filter.result.some(function (k) k === key))
|
get: function get(mode, key) this.stack.mappings[key],
|
||||||
return true;
|
|
||||||
return false;
|
getCandidates: function getCandidates(mode, key) this.stack.candidates[key],
|
||||||
|
|
||||||
|
pass: set(array.flatten(values.map(function (v) v.keys))),
|
||||||
|
|
||||||
|
stack: MapHive.Stack(values.map(function (v) v.map))
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
has: function (key) set.has(this.hive.pass, key),
|
||||||
|
|
||||||
|
get hive() (this.flush(), this.hive),
|
||||||
|
|
||||||
|
keepQuotes: true,
|
||||||
|
|
||||||
setter: function (values) {
|
setter: function (values) {
|
||||||
values.forEach(function (filter) {
|
values.forEach(function (filter) {
|
||||||
filter.result = events.fromString(filter.result).map(events.closure.toString);
|
let vals = Option.splitList(filter.result);
|
||||||
filter.result.toString = bind(filter.result.join, filter.result);
|
filter.keys = events.fromString(vals[0]).map(events.closure.toString);
|
||||||
|
filter.map = {
|
||||||
|
execute: function () Events.PASS_THROUGH,
|
||||||
|
keys: vals.slice(1).map(events.closure.canonicalKeys)
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
this.flush();
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,21 +20,19 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
&dactyl.host; or to a web page, you have two options:
|
&dactyl.host; or to a web page, you have two options:
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[pass-through <pass-all-keys> <C-z> CTRL-Z]]></tags>
|
<tags><![CDATA[<A-b>]]></tags>
|
||||||
<spec><C-z></spec>
|
<spec><![CDATA[<A-b>]]></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Pass all keys except for <k name="Esc"/> directly to
|
Process the next key as a builtin mapping, ignoring any user defined
|
||||||
&dactyl.host;. When <k name="Esc"/> is pressed,
|
mappings and <o>passkeys</o> settings.
|
||||||
resume normal key handling. This is especially useful
|
|
||||||
for web sites which make heavy use of key bindings.
|
|
||||||
</p>
|
</p>
|
||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[send-key <pass-next-key> <C-v> CTRL-V]]></tags>
|
<tags><![CDATA[send-key <pass-next-key> <C-v> CTRL-V]]></tags>
|
||||||
<spec><C-v></spec>
|
<spec><![CDATA[<C-v>]]></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Pass the next key press directly to &dactyl.host;.
|
Pass the next key press directly to &dactyl.host;.
|
||||||
@@ -42,6 +40,19 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags><![CDATA[pass-through <pass-all-keys> <C-z> CTRL-Z]]></tags>
|
||||||
|
<spec><![CDATA[<C-z>]]></spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Pass all keys except for <k name="Esc"/> directly to
|
||||||
|
&dactyl.host;. When <k name="Esc"/> is pressed,
|
||||||
|
resume normal key handling. This is especially useful
|
||||||
|
for web sites which make heavy use of key bindings.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<h2 tag="opening">Opening web pages</h2>
|
<h2 tag="opening">Opening web pages</h2>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -1122,9 +1122,12 @@
|
|||||||
For any page with a URL matching a given regexp, all key
|
For any page with a URL matching a given regexp, all key
|
||||||
events for keys listed in that regexp's value are passed
|
events for keys listed in that regexp's value are passed
|
||||||
through directly to &dactyl.host;, and are not processed
|
through directly to &dactyl.host;, and are not processed
|
||||||
by &dactyl.appName; in any way.
|
by &dactyl.appName; in any way. Key names are separated
|
||||||
|
by commas, where the first key name is treated as a list
|
||||||
|
of individual keys and each subsequent key is treated as
|
||||||
|
a key chain.
|
||||||
</p>
|
</p>
|
||||||
<example><set opt="passkeys" op="+="><str delim="'">https://mail\.google\.com/</str>:<str delim="">jk<k name="Return"/></str></set></example>
|
<example><set opt="passkeys" op="+="><str delim="">mail.google.com</str>:<str delim="">jk<Return></str>,<str delim="">gi</str></set></example>
|
||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
|||||||
@@ -525,12 +525,17 @@ function memoize(obj, key, getter) {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.__defineGetter__(key, function g_replaceProperty() (
|
Object.defineProperty(obj, key, {
|
||||||
Class.replaceProperty(this.instance || this, key, null),
|
configurable: true,
|
||||||
Class.replaceProperty(this.instance || this, key, getter.call(this, key))));
|
enumerable: true,
|
||||||
|
|
||||||
obj.__defineSetter__(key, function s_replaceProperty(val)
|
get: function g_replaceProperty() (
|
||||||
Class.replaceProperty(this.instance || this, key, val));
|
Class.replaceProperty(this.instance || this, key, null),
|
||||||
|
Class.replaceProperty(this.instance || this, key, getter.call(this, key))),
|
||||||
|
|
||||||
|
set: function s_replaceProperty(val)
|
||||||
|
Class.replaceProperty(this.instance || this, key, val)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
- Added site-specific mapping groups and related command
|
- Added site-specific mapping groups and related command
|
||||||
changes. [b6]
|
changes. [b6]
|
||||||
- Added 'timeout' and 'timeoutlen' options. [b6]
|
- Added 'timeout' and 'timeoutlen' options. [b6]
|
||||||
|
- Added <A-b> to execute a builtin mapping. [b6]
|
||||||
- Added <A-m>l and <A-m>s to aid in the construction of
|
- Added <A-m>l and <A-m>s to aid in the construction of
|
||||||
macros. [b6]
|
macros. [b6]
|
||||||
- Removed the implicit page load delays during macro playback. [b6]
|
- Removed the implicit page load delays during macro playback. [b6]
|
||||||
|
|||||||
Reference in New Issue
Block a user