mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-07 22:34:18 +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);
|
||||
|
||||
contexts.flush();
|
||||
options.get("passkeys").flush();
|
||||
|
||||
statusline.updateUrl();
|
||||
statusline.progress = "";
|
||||
|
||||
@@ -9,13 +9,19 @@
|
||||
/** @scope modules */
|
||||
|
||||
var ProcessorStack = Class("ProcessorStack", {
|
||||
init: function (mode, hives, keyModes) {
|
||||
init: function (mode, hives, builtin) {
|
||||
this.main = mode.main;
|
||||
this._actions = [];
|
||||
this.actions = [];
|
||||
this.buffer = "";
|
||||
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)))
|
||||
.flatten().array;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
if (!builtin && (!dactyl.focusedElement || events.isContentNode(dactyl.focusedElement)))
|
||||
this.processors.unshift(KeyProcessor(modes.BASE, options.get("passkeys").hive));
|
||||
},
|
||||
|
||||
notify: function () {
|
||||
@@ -1207,12 +1216,7 @@ var Events = Module("events", {
|
||||
if (config.ignoreKeys[key] & mode.main)
|
||||
return null;
|
||||
|
||||
let hives = mappings.hives.slice(event.noremap ? -1 : 0);
|
||||
|
||||
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 = ProcessorStack(mode, mappings.hives.array, event.noremap);
|
||||
this.processor.allEvents = this.keyEvents;
|
||||
}
|
||||
|
||||
@@ -1392,7 +1396,7 @@ var Events = Module("events", {
|
||||
},
|
||||
|
||||
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))
|
||||
}, {
|
||||
ABORT: {},
|
||||
@@ -1460,6 +1464,14 @@ var Events = Module("events", {
|
||||
};
|
||||
},
|
||||
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,
|
||||
["<C-z>", "<pass-all-keys>"], "Temporarily ignore all " + config.appName + " key bindings",
|
||||
function () { modes.push(modes.PASS_THROUGH); });
|
||||
@@ -1518,18 +1530,35 @@ var Events = Module("events", {
|
||||
options.add(["passkeys", "pk"],
|
||||
"Pass certain keys through directly for the given URLs",
|
||||
"sitemap", "", {
|
||||
has: function (key) {
|
||||
let uri = buffer.documentURI;
|
||||
for (let filter in values(this.value))
|
||||
if (filter(uri) && filter.result.some(function (k) k === key))
|
||||
return true;
|
||||
return false;
|
||||
flush: function flush() {
|
||||
memoize(this, "hive", function hive()
|
||||
let (values = this.value.filter(function (f) f(buffer.documentURI))) {
|
||||
get: function get(mode, key) this.stack.mappings[key],
|
||||
|
||||
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) {
|
||||
values.forEach(function (filter) {
|
||||
filter.result = events.fromString(filter.result).map(events.closure.toString);
|
||||
filter.result.toString = bind(filter.result.join, filter.result);
|
||||
let vals = Option.splitList(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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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:
|
||||
|
||||
<item>
|
||||
<tags><![CDATA[pass-through <pass-all-keys> <C-z> CTRL-Z]]></tags>
|
||||
<spec><C-z></spec>
|
||||
<tags><![CDATA[<A-b>]]></tags>
|
||||
<spec><![CDATA[<A-b>]]></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.
|
||||
Process the next key as a builtin mapping, ignoring any user defined
|
||||
mappings and <o>passkeys</o> settings.
|
||||
</p>
|
||||
</description>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<tags><![CDATA[send-key <pass-next-key> <C-v> CTRL-V]]></tags>
|
||||
<spec><C-v></spec>
|
||||
<spec><![CDATA[<C-v>]]></spec>
|
||||
<description>
|
||||
<p>
|
||||
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>
|
||||
</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>
|
||||
|
||||
<item>
|
||||
|
||||
@@ -1122,9 +1122,12 @@
|
||||
For any page with a URL matching a given regexp, all key
|
||||
events for keys listed in that regexp's value are passed
|
||||
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>
|
||||
<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>
|
||||
</item>
|
||||
|
||||
|
||||
@@ -525,12 +525,17 @@ function memoize(obj, key, getter) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
obj.__defineGetter__(key, function g_replaceProperty() (
|
||||
Class.replaceProperty(this.instance || this, key, null),
|
||||
Class.replaceProperty(this.instance || this, key, getter.call(this, key))));
|
||||
Object.defineProperty(obj, key, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
|
||||
obj.__defineSetter__(key, function s_replaceProperty(val)
|
||||
Class.replaceProperty(this.instance || this, key, val));
|
||||
get: function g_replaceProperty() (
|
||||
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
|
||||
changes. [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
|
||||
macros. [b6]
|
||||
- Removed the implicit page load delays during macro playback. [b6]
|
||||
|
||||
Reference in New Issue
Block a user