mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 01:37:58 +01:00
Minor key processing tweaks.
This commit is contained in:
@@ -380,8 +380,7 @@ var CommandMode = Class("CommandMode", {
|
|||||||
|
|
||||||
keepCommand: false,
|
keepCommand: false,
|
||||||
|
|
||||||
onKeyPress: function onKeyPress(event) {
|
onKeyPress: function onKeyPress(events) {
|
||||||
let key = events.toString(event);
|
|
||||||
if (this.completions)
|
if (this.completions)
|
||||||
this.completions.previewClear();
|
this.completions.previewClear();
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
if (params.postExecute)
|
if (params.postExecute)
|
||||||
input.postExecute = params.postExecute;
|
input.postExecute = params.postExecute;
|
||||||
if (params.onKeyPress && input.hive === mappings.builtin)
|
if (params.onKeyPress && input.hive === mappings.builtin)
|
||||||
input.fallthrough = function (event) {
|
input.fallthrough = function fallthrough(events) {
|
||||||
return params.onKeyPress(event) === false ? Events.KILL : Events.PASS;
|
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);
|
let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented);
|
||||||
if (list.length)
|
if (list.length)
|
||||||
events.dbg("REFEED: " + list.map(events.closure.toString).join(""));
|
events.dbg("REFEED: " + list.map(events.closure.toString).join(""));
|
||||||
|
events.feedevents(null, list, { skipmap: true, isMacro: true, isReplay: true });
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force && this.processors.length === 0)
|
if (force && this.processors.length === 0)
|
||||||
@@ -153,7 +143,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
if (input.fallthrough) {
|
if (input.fallthrough) {
|
||||||
if (result === Events.KILL)
|
if (result === Events.KILL)
|
||||||
break;
|
break;
|
||||||
result = dactyl.trapErrors(input.fallthrough, input, event);
|
result = dactyl.trapErrors(input.fallthrough, input, this.events);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.processors = processors;
|
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
|
* Pushes keys onto the event queue from dactyl. It is similar to
|
||||||
* Vim's feedkeys() method, but cannot cope with 2 partially-fed
|
* Vim's feedkeys() method, but cannot cope with 2 partially-fed
|
||||||
|
|||||||
@@ -357,9 +357,9 @@ var HintSession = Class("HintSession", CommandMode, {
|
|||||||
*
|
*
|
||||||
* @param {Event} event The event to handle.
|
* @param {Event} event The event to handle.
|
||||||
*/
|
*/
|
||||||
onKeyPress: function onKeyPress(event) {
|
onKeyPress: function onKeyPress(events) {
|
||||||
const KILL = false, PASS = true;
|
const KILL = false, PASS = true;
|
||||||
let key = events.toString(event);
|
let key = events.toString(events[0]);
|
||||||
|
|
||||||
this.clearTimeout();
|
this.clearTimeout();
|
||||||
|
|
||||||
|
|||||||
@@ -144,10 +144,10 @@ var Modes = Module("modes", {
|
|||||||
// Fix me.
|
// Fix me.
|
||||||
preExecute: function (map) { if (modes.main == modes.QUOTE && map.name !== "<C-v>") modes.pop(); },
|
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(); },
|
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 }, {
|
this.addMode("IGNORE", { hidden: true }, {
|
||||||
onKeyPress: function (event) Events.KILL,
|
onKeyPress: function (events) Events.KILL,
|
||||||
bases: [],
|
bases: [],
|
||||||
passthrough: true
|
passthrough: true
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -210,14 +210,14 @@ var MOW = Module("mow", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyPress: function onKeyPress(event) {
|
onKeyPress: function onKeyPress(eventList) {
|
||||||
const KILL = false, PASS = true;
|
const KILL = false, PASS = true;
|
||||||
|
|
||||||
if (options["more"] && mow.isScrollable(1))
|
if (options["more"] && mow.isScrollable(1))
|
||||||
this.updateMorePrompt(false, true);
|
this.updateMorePrompt(false, true);
|
||||||
else {
|
else {
|
||||||
modes.pop();
|
modes.pop();
|
||||||
events.feedkeys(events.toString(event));
|
events.feedevents(null, eventList);
|
||||||
return KILL;
|
return KILL;
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
|
|||||||
Reference in New Issue
Block a user