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

Minor key processing tweaks.

This commit is contained in:
Kris Maglione
2011-02-15 19:51:26 -05:00
parent 5606b96957
commit 928572fa0d
5 changed files with 34 additions and 22 deletions

View File

@@ -380,8 +380,7 @@ var CommandMode = Class("CommandMode", {
keepCommand: false,
onKeyPress: function onKeyPress(event) {
let key = events.toString(event);
onKeyPress: function onKeyPress(events) {
if (this.completions)
this.completions.previewClear();

View File

@@ -27,8 +27,8 @@ var ProcessorStack = Class("ProcessorStack", {
if (params.postExecute)
input.postExecute = params.postExecute;
if (params.onKeyPress && input.hive === mappings.builtin)
input.fallthrough = function (event) {
return params.onKeyPress(event) === false ? Events.KILL : Events.PASS;
input.fallthrough = function fallthrough(events) {
return params.onKeyPress(events) === false ? Events.KILL : Events.PASS;
};
}
},
@@ -84,17 +84,7 @@ var ProcessorStack = Class("ProcessorStack", {
let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented);
if (list.length)
events.dbg("REFEED: " + list.map(events.closure.toString).join(""));
list.forEach(function (event, i) {
let elem = event.originalTarget;
if (event.originalTarget) {
let doc = elem.ownerDocument || elem.document || elem;
let evt = events.create(doc, event.type, event);
events.dispatch(elem, evt, { skipmap: true, isMacro: true, isReplay: true });
}
else if (i > 0)
events.events.keypress.call(events, event);
});
events.feedevents(null, list, { skipmap: true, isMacro: true, isReplay: true });
}
if (force && this.processors.length === 0)
@@ -153,7 +143,7 @@ var ProcessorStack = Class("ProcessorStack", {
if (input.fallthrough) {
if (result === Events.KILL)
break;
result = dactyl.trapErrors(input.fallthrough, input, event);
result = dactyl.trapErrors(input.fallthrough, input, this.events);
}
this.processors = processors;
@@ -557,6 +547,29 @@ var Events = Module("events", {
}
},
/**
* Feeds a list of events to *target* or the originalTarget member
* of each event if *target* is null.
*
* @param {EventTarget} target The destination node for the events.
* @optional
* @param {[Event]} list The events to dispatch.
* @param {object} extra Extra properties for processing by dactyl.
* @optional
*/
feedevents: function feedevents(target, list, extra) {
list.forEach(function (event, i) {
let elem = target || event.originalTarget;
if (elem) {
let doc = elem.ownerDocument || elem.document || elem;
let evt = events.create(doc, event.type, event);
events.dispatch(elem, evt, extra);
}
else if (i > 0 && event.type === "keypress")
events.events.keypress.call(events, event);
});
},
/**
* Pushes keys onto the event queue from dactyl. It is similar to
* Vim's feedkeys() method, but cannot cope with 2 partially-fed

View File

@@ -357,9 +357,9 @@ var HintSession = Class("HintSession", CommandMode, {
*
* @param {Event} event The event to handle.
*/
onKeyPress: function onKeyPress(event) {
onKeyPress: function onKeyPress(events) {
const KILL = false, PASS = true;
let key = events.toString(event);
let key = events.toString(events[0]);
this.clearTimeout();

View File

@@ -144,10 +144,10 @@ var Modes = Module("modes", {
// Fix me.
preExecute: function (map) { if (modes.main == modes.QUOTE && map.name !== "<C-v>") modes.pop(); },
postExecute: function (map) { if (modes.main == modes.QUOTE && map.name === "<C-v>") modes.pop(); },
onKeyPress: function () { if (modes.main == modes.QUOTE) modes.pop() }
onKeyPress: function (events) { if (modes.main == modes.QUOTE) modes.pop(); }
});
this.addMode("IGNORE", { hidden: true }, {
onKeyPress: function (event) Events.KILL,
onKeyPress: function (events) Events.KILL,
bases: [],
passthrough: true
});

View File

@@ -210,14 +210,14 @@ var MOW = Module("mow", {
}
},
onKeyPress: function onKeyPress(event) {
onKeyPress: function onKeyPress(eventList) {
const KILL = false, PASS = true;
if (options["more"] && mow.isScrollable(1))
this.updateMorePrompt(false, true);
else {
modes.pop();
events.feedkeys(events.toString(event));
events.feedevents(null, eventList);
return KILL;
}
return PASS;