diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-02-20 18:05:45 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-02-20 18:05:45 -0500 |
commit | 211091d79dc2b26c5343ee5e82138e55675878a9 (patch) | |
tree | 64cf56a007acdef98d40d1b260d6105a49f9d819 | |
parent | db14f1335327a13df9874bbbc89caef8a09ee704 (diff) | |
download | pentadactyl-211091d79dc2b26c5343ee5e82138e55675878a9.tar.gz |
Add <Pass> pseudo-key.
--HG--
extra : rebase_source : e1d27c1fd04a598a25cd0c0c8c266834e80b2320
-rw-r--r-- | common/content/events.js | 57 | ||||
-rw-r--r-- | common/content/mappings.js | 4 | ||||
-rw-r--r-- | common/locale/en-US/map.xml | 16 | ||||
-rw-r--r-- | pentadactyl/NEWS | 1 |
4 files changed, 55 insertions, 23 deletions
diff --git a/common/content/events.js b/common/content/events.js index a0ed5286..d4c796ad 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -44,9 +44,12 @@ var ProcessorStack = Class("ProcessorStack", { }, notify: function () { + events.keyEvents = []; events.processor = null; - if (!this.execute(Events.KILL, true)) + if (!this.execute(Events.KILL, true)) { events.processor = this; + events.keyEvents = this.keyEvents; + } }, execute: function execute(result, force) { @@ -101,7 +104,7 @@ var ProcessorStack = Class("ProcessorStack", { Events.kill(this.events[this.events.length - 1]); if (result === Events.PASS_THROUGH) - events.feedevents(null, this.allEvents, { skipmap: true, isMacro: true, isReplay: true }); + events.feedevents(null, this.keyEvents, { skipmap: true, isMacro: true, isReplay: true }); else if (result === Events.PASS || result === Events.ABORT) { let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented); if (list.length) @@ -118,8 +121,8 @@ var ProcessorStack = Class("ProcessorStack", { let key = events.toString(event); this.events.push(event); - if (this.allEvents) - this.allEvents.push(event); + if (this.keyEvents) + this.keyEvents.push(event); this.buffer += key; @@ -233,7 +236,7 @@ var KeyProcessor = Class("KeyProcessor", { return KeyArgProcessor(this, map, true, "motion"); return this.execute(map, { - allEvents: this.allEvents, + keyEvents: this.keyEvents, command: this.command, count: this.count, keypressEvents: this.events @@ -389,13 +392,14 @@ var Events = Module("events", { leader: ["Leader"], left_shift: ["LT", "<"], nop: ["Nop"], + pass: ["Pass"], return: ["Return", "CR", "Enter"], right_shift: [">"], space: ["Space", " "], subtract: ["Minus", "Subtract"] }; - this._pseudoKeys = set(["count", "leader", "nop"]); + this._pseudoKeys = set(["count", "leader", "nop", "pass"]); this._key_key = {}; this._code_key = {}; @@ -616,6 +620,8 @@ var Events = Module("events", { */ feedkeys: function (keys, noremap, quiet, mode) { try { + var savedEvents = this._processor && this._processor.keyEvents; + var wasFeeding = this.feedingKeys; this.feedingKeys = true; @@ -634,6 +640,7 @@ var Events = Module("events", { evt.noremap = !!noremap; evt.isMacro = true; evt.dactylMode = mode; + evt.dactylSavedEvents = savedEvents; this.feedingEvent = evt; let event = events.create(document.commandDispatcher.focusedWindow.document, type, evt); @@ -1218,16 +1225,18 @@ var Events = Module("events", { return null; this.processor = ProcessorStack(mode, mappings.hives.array, event.noremap); - this.processor.allEvents = this.keyEvents; + this.processor.keyEvents = this.keyEvents; } - let processor = this.processor; + let { keyEvents, processor } = this; + this._processor = processor; this.processor = null; + this.keyEvents = []; - if (!processor.process(event)) + if (!processor.process(event)) { + this.keyEvents = keyEvents; this.processor = processor; - else - this.keyEvents = []; + } } catch (e) { @@ -1333,6 +1342,8 @@ var Events = Module("events", { return; } + let haveInput = modes.stack.some(function (m) m.main.input); + if (elem instanceof HTMLTextAreaElement || elem instanceof Element && util.computedStyle(elem).MozUserModify === "read-write" || elem == null && win && Editor.getEditor(win)) { @@ -1340,7 +1351,7 @@ var Events = Module("events", { if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart) modes.pop(); - if (!modes.main.input) + if (!haveInput) if (options["insertmode"]) modes.push(modes.INSERT); else { @@ -1355,7 +1366,7 @@ var Events = Module("events", { } if (Events.isInputElement(elem)) { - if (!modes.main.input) + if (!haveInput) modes.push(modes.INSERT); if (hasHTMLDocument(win)) @@ -1466,18 +1477,18 @@ var Events = Module("events", { }, mappings: function () { - mappings.add(modes.MAIN, + 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; + events.processor.keyEvents = events.keyEvents; }); - mappings.add(modes.MAIN, + mappings.add([modes.MAIN], ["<C-z>", "<pass-all-keys>"], "Temporarily ignore all " + config.appName + " key bindings", function () { modes.push(modes.PASS_THROUGH); }); - mappings.add(modes.MAIN, + mappings.add([modes.MAIN], ["<C-v>", "<pass-next-key>"], "Pass through next key", function () { if (modes.main == modes.QUOTE) @@ -1485,10 +1496,20 @@ var Events = Module("events", { modes.push(modes.QUOTE); }); - mappings.add(modes.BASE, + mappings.add([modes.BASE], ["<Nop>"], "Do nothing", function () {}); + mappings.add([modes.BASE], + ["<Pass>"], "Pass the events consumed by the last executed mapping", + function ({ keypressEvents: [event] }) { + dactyl.assert(event.dactylSavedEvents, "No events to pass"); + return function () { + events.feedevents(null, event.dactylSavedEvents, + { skipmap: true, isMacro: true, isReplay: true }); + }; + }); + // macros mappings.add([modes.COMMAND], ["q", "<record-macro>"], "Record a key sequence into a macro", diff --git a/common/content/mappings.js b/common/content/mappings.js index 305ffc6c..26d67a23 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -50,7 +50,7 @@ var Map = Class("Map", { name: Class.memoize(function () this.names[0]), /** @property {string[]} All of this mapping's names (key sequences). */ - names: Class.memoize(function () this._keys.map(events.closure.canonicalKeys)), + names: Class.memoize(function () this._keys.map(function (k) events.canonicalKeys(k))), get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)], @@ -393,7 +393,7 @@ var Mappings = Module("mappings", { modeSign = modeSign.replace(/^ /, ""); hives = (hives || mappings.userHives).map(function (h) [h, maps(h)]) - .filter(function ([h, m]) !filter || m.length); + .filter(function ([h, m]) m.length); function maps(hive) { let maps = iter.toArray(hive.iterate(modes)); diff --git a/common/locale/en-US/map.xml b/common/locale/en-US/map.xml index 0fb46370..6bc6f7a0 100644 --- a/common/locale/en-US/map.xml +++ b/common/locale/en-US/map.xml @@ -352,7 +352,7 @@ <item> <tags><![CDATA[<Nop>]]></tags> <strut/> - <spec><Nop></spec> + <spec><![CDATA[<Nop>]]></spec> <description> <p> Do nothing. This pseudo-key is useful for disabling a @@ -364,9 +364,19 @@ </item> <item> + <tags><![CDATA[<Pass>]]></tags> + <spec><![CDATA[<Pass>]]></spec> + <description short="true"> + <p> + Pass the events consumed by the last executed mapping through to &dactyl.host;. + </p> + </description> +</item> + +<item> <tags><![CDATA[<CR> map_return]]></tags> <strut/> - <spec><CR></spec> + <spec><![CDATA[<CR>]]></spec> <description> <p> Expand to a line terminator in a key mapping. An Ex command in the <a>rhs</a> of a @@ -379,7 +389,7 @@ <item> <tags><![CDATA[<Leader> \]]></tags> <strut/> - <spec><Leader></spec> + <spec><![CDATA[<Leader>]]></spec> <description> <p> A pseudo-key which expands to the value of the <o>mapleader</o> diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index 8beee832..b7c7806a 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -78,6 +78,7 @@ - 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] + - Added <Pass> pseudo-key. [b6] - Removed the implicit page load delays during macro playback. [b6] - Added the base modes Base, Main, and Command which other modes inherit key bindings from. [b6] |