mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-18 08:23:32 +01:00
Add <Pass> pseudo-key.
--HG-- extra : rebase_source : e1d27c1fd04a598a25cd0c0c8c266834e80b2320
This commit is contained in:
@@ -44,9 +44,12 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
notify: function () {
|
notify: function () {
|
||||||
|
events.keyEvents = [];
|
||||||
events.processor = null;
|
events.processor = null;
|
||||||
if (!this.execute(Events.KILL, true))
|
if (!this.execute(Events.KILL, true)) {
|
||||||
events.processor = this;
|
events.processor = this;
|
||||||
|
events.keyEvents = this.keyEvents;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: function execute(result, force) {
|
execute: function execute(result, force) {
|
||||||
@@ -101,7 +104,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
Events.kill(this.events[this.events.length - 1]);
|
Events.kill(this.events[this.events.length - 1]);
|
||||||
|
|
||||||
if (result === Events.PASS_THROUGH)
|
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) {
|
else if (result === Events.PASS || result === Events.ABORT) {
|
||||||
let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented);
|
let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented);
|
||||||
if (list.length)
|
if (list.length)
|
||||||
@@ -118,8 +121,8 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
|
|
||||||
let key = events.toString(event);
|
let key = events.toString(event);
|
||||||
this.events.push(event);
|
this.events.push(event);
|
||||||
if (this.allEvents)
|
if (this.keyEvents)
|
||||||
this.allEvents.push(event);
|
this.keyEvents.push(event);
|
||||||
|
|
||||||
this.buffer += key;
|
this.buffer += key;
|
||||||
|
|
||||||
@@ -233,7 +236,7 @@ var KeyProcessor = Class("KeyProcessor", {
|
|||||||
return KeyArgProcessor(this, map, true, "motion");
|
return KeyArgProcessor(this, map, true, "motion");
|
||||||
|
|
||||||
return this.execute(map, {
|
return this.execute(map, {
|
||||||
allEvents: this.allEvents,
|
keyEvents: this.keyEvents,
|
||||||
command: this.command,
|
command: this.command,
|
||||||
count: this.count,
|
count: this.count,
|
||||||
keypressEvents: this.events
|
keypressEvents: this.events
|
||||||
@@ -389,13 +392,14 @@ var Events = Module("events", {
|
|||||||
leader: ["Leader"],
|
leader: ["Leader"],
|
||||||
left_shift: ["LT", "<"],
|
left_shift: ["LT", "<"],
|
||||||
nop: ["Nop"],
|
nop: ["Nop"],
|
||||||
|
pass: ["Pass"],
|
||||||
return: ["Return", "CR", "Enter"],
|
return: ["Return", "CR", "Enter"],
|
||||||
right_shift: [">"],
|
right_shift: [">"],
|
||||||
space: ["Space", " "],
|
space: ["Space", " "],
|
||||||
subtract: ["Minus", "Subtract"]
|
subtract: ["Minus", "Subtract"]
|
||||||
};
|
};
|
||||||
|
|
||||||
this._pseudoKeys = set(["count", "leader", "nop"]);
|
this._pseudoKeys = set(["count", "leader", "nop", "pass"]);
|
||||||
|
|
||||||
this._key_key = {};
|
this._key_key = {};
|
||||||
this._code_key = {};
|
this._code_key = {};
|
||||||
@@ -616,6 +620,8 @@ var Events = Module("events", {
|
|||||||
*/
|
*/
|
||||||
feedkeys: function (keys, noremap, quiet, mode) {
|
feedkeys: function (keys, noremap, quiet, mode) {
|
||||||
try {
|
try {
|
||||||
|
var savedEvents = this._processor && this._processor.keyEvents;
|
||||||
|
|
||||||
var wasFeeding = this.feedingKeys;
|
var wasFeeding = this.feedingKeys;
|
||||||
this.feedingKeys = true;
|
this.feedingKeys = true;
|
||||||
|
|
||||||
@@ -634,6 +640,7 @@ var Events = Module("events", {
|
|||||||
evt.noremap = !!noremap;
|
evt.noremap = !!noremap;
|
||||||
evt.isMacro = true;
|
evt.isMacro = true;
|
||||||
evt.dactylMode = mode;
|
evt.dactylMode = mode;
|
||||||
|
evt.dactylSavedEvents = savedEvents;
|
||||||
this.feedingEvent = evt;
|
this.feedingEvent = evt;
|
||||||
|
|
||||||
let event = events.create(document.commandDispatcher.focusedWindow.document, type, evt);
|
let event = events.create(document.commandDispatcher.focusedWindow.document, type, evt);
|
||||||
@@ -1218,16 +1225,18 @@ var Events = Module("events", {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
this.processor = ProcessorStack(mode, mappings.hives.array, event.noremap);
|
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.processor = null;
|
||||||
|
this.keyEvents = [];
|
||||||
|
|
||||||
if (!processor.process(event))
|
if (!processor.process(event)) {
|
||||||
|
this.keyEvents = keyEvents;
|
||||||
this.processor = processor;
|
this.processor = processor;
|
||||||
else
|
}
|
||||||
this.keyEvents = [];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@@ -1333,6 +1342,8 @@ var Events = Module("events", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let haveInput = modes.stack.some(function (m) m.main.input);
|
||||||
|
|
||||||
if (elem instanceof HTMLTextAreaElement
|
if (elem instanceof HTMLTextAreaElement
|
||||||
|| elem instanceof Element && util.computedStyle(elem).MozUserModify === "read-write"
|
|| elem instanceof Element && util.computedStyle(elem).MozUserModify === "read-write"
|
||||||
|| elem == null && win && Editor.getEditor(win)) {
|
|| elem == null && win && Editor.getEditor(win)) {
|
||||||
@@ -1340,7 +1351,7 @@ var Events = Module("events", {
|
|||||||
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
|
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
|
||||||
modes.pop();
|
modes.pop();
|
||||||
|
|
||||||
if (!modes.main.input)
|
if (!haveInput)
|
||||||
if (options["insertmode"])
|
if (options["insertmode"])
|
||||||
modes.push(modes.INSERT);
|
modes.push(modes.INSERT);
|
||||||
else {
|
else {
|
||||||
@@ -1355,7 +1366,7 @@ var Events = Module("events", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Events.isInputElement(elem)) {
|
if (Events.isInputElement(elem)) {
|
||||||
if (!modes.main.input)
|
if (!haveInput)
|
||||||
modes.push(modes.INSERT);
|
modes.push(modes.INSERT);
|
||||||
|
|
||||||
if (hasHTMLDocument(win))
|
if (hasHTMLDocument(win))
|
||||||
@@ -1466,18 +1477,18 @@ var Events = Module("events", {
|
|||||||
},
|
},
|
||||||
mappings: function () {
|
mappings: function () {
|
||||||
|
|
||||||
mappings.add(modes.MAIN,
|
mappings.add([modes.MAIN],
|
||||||
["<A-b>"], "Process the next key as a builtin mapping",
|
["<A-b>"], "Process the next key as a builtin mapping",
|
||||||
function () {
|
function () {
|
||||||
events.processor = ProcessorStack(modes.getStack(0), mappings.hives.array, true);
|
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",
|
["<C-z>", "<pass-all-keys>"], "Temporarily ignore all " + config.appName + " key bindings",
|
||||||
function () { modes.push(modes.PASS_THROUGH); });
|
function () { modes.push(modes.PASS_THROUGH); });
|
||||||
|
|
||||||
mappings.add(modes.MAIN,
|
mappings.add([modes.MAIN],
|
||||||
["<C-v>", "<pass-next-key>"], "Pass through next key",
|
["<C-v>", "<pass-next-key>"], "Pass through next key",
|
||||||
function () {
|
function () {
|
||||||
if (modes.main == modes.QUOTE)
|
if (modes.main == modes.QUOTE)
|
||||||
@@ -1485,10 +1496,20 @@ var Events = Module("events", {
|
|||||||
modes.push(modes.QUOTE);
|
modes.push(modes.QUOTE);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add(modes.BASE,
|
mappings.add([modes.BASE],
|
||||||
["<Nop>"], "Do nothing",
|
["<Nop>"], "Do nothing",
|
||||||
function () {});
|
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
|
// macros
|
||||||
mappings.add([modes.COMMAND],
|
mappings.add([modes.COMMAND],
|
||||||
["q", "<record-macro>"], "Record a key sequence into a macro",
|
["q", "<record-macro>"], "Record a key sequence into a macro",
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ var Map = Class("Map", {
|
|||||||
name: Class.memoize(function () this.names[0]),
|
name: Class.memoize(function () this.names[0]),
|
||||||
|
|
||||||
/** @property {string[]} All of this mapping's names (key sequences). */
|
/** @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)],
|
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(/^ /, "");
|
modeSign = modeSign.replace(/^ /, "");
|
||||||
|
|
||||||
hives = (hives || mappings.userHives).map(function (h) [h, maps(h)])
|
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) {
|
function maps(hive) {
|
||||||
let maps = iter.toArray(hive.iterate(modes));
|
let maps = iter.toArray(hive.iterate(modes));
|
||||||
|
|||||||
@@ -352,7 +352,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<Nop>]]></tags>
|
<tags><![CDATA[<Nop>]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><Nop></spec>
|
<spec><![CDATA[<Nop>]]></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Do nothing. This pseudo-key is useful for disabling a
|
Do nothing. This pseudo-key is useful for disabling a
|
||||||
@@ -363,10 +363,20 @@
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<tags><![CDATA[<CR> map_return]]></tags>
|
<tags><![CDATA[<CR> map_return]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><CR></spec>
|
<spec><![CDATA[<CR>]]></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Expand to a line terminator in a key mapping. An Ex command in the <a>rhs</a> of a
|
Expand to a line terminator in a key mapping. An Ex command in the <a>rhs</a> of a
|
||||||
@@ -379,7 +389,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<Leader> \]]></tags>
|
<tags><![CDATA[<Leader> \]]></tags>
|
||||||
<strut/>
|
<strut/>
|
||||||
<spec><Leader></spec>
|
<spec><![CDATA[<Leader>]]></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
A pseudo-key which expands to the value of the <o>mapleader</o>
|
A pseudo-key which expands to the value of the <o>mapleader</o>
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
- Added <A-b> to execute a builtin mapping. [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]
|
||||||
|
- Added <Pass> pseudo-key. [b6]
|
||||||
- Removed the implicit page load delays during macro playback. [b6]
|
- Removed the implicit page load delays during macro playback. [b6]
|
||||||
- Added the base modes Base, Main, and Command which other
|
- Added the base modes Base, Main, and Command which other
|
||||||
modes inherit key bindings from. [b6]
|
modes inherit key bindings from. [b6]
|
||||||
|
|||||||
Reference in New Issue
Block a user