mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-24 23:45:47 +01:00
Fix key chains with stacked handlers, but needs work.
--HG-- extra : rebase_source : c1ce8c574e67d3254e32e902dd4ff31f37715363
This commit is contained in:
@@ -973,11 +973,13 @@ var Events = Module("events", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let refeed, buffer, waiting = 0;
|
let refeed, buffer, waiting = 0, action;
|
||||||
for (let input in values(processors)) {
|
for (let input in values(processors)) {
|
||||||
var res = input.process(event);
|
var res = input.process(event);
|
||||||
waiting += res == Events.WAIT;
|
waiting += res == Events.WAIT;
|
||||||
buffer = buffer || input.inputBuffer;
|
buffer = buffer || input.inputBuffer;
|
||||||
|
if (callable(res))
|
||||||
|
action = action || res;
|
||||||
|
|
||||||
if (isArray(res) && !waiting)
|
if (isArray(res) && !waiting)
|
||||||
refeed = res;
|
refeed = res;
|
||||||
@@ -1000,6 +1002,9 @@ var Events = Module("events", {
|
|||||||
res = Events.KILL;
|
res = Events.KILL;
|
||||||
this._processors = processors;
|
this._processors = processors;
|
||||||
}
|
}
|
||||||
|
else if (action)
|
||||||
|
res = action(res) === Events.PASS ? Events.PASS : Events.KILL;
|
||||||
|
|
||||||
if (res !== Events.KILL && (mode.main & (modes.TEXT_EDIT | modes.VISUAL))) {
|
if (res !== Events.KILL && (mode.main & (modes.TEXT_EDIT | modes.VISUAL))) {
|
||||||
res = Events.KILL;
|
res = Events.KILL;
|
||||||
dactyl.beep();
|
dactyl.beep();
|
||||||
@@ -1140,8 +1145,6 @@ var Events = Module("events", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let res = this.onKeyPress(event);
|
let res = this.onKeyPress(event);
|
||||||
if (res === Events.KILL)
|
|
||||||
kill(event);
|
|
||||||
|
|
||||||
if (res != Events.WAIT)
|
if (res != Events.WAIT)
|
||||||
this.inputBuffer = "";
|
this.inputBuffer = "";
|
||||||
@@ -1153,25 +1156,25 @@ var Events = Module("events", {
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
execute: function execute(map)
|
||||||
|
let (self = this, args = arguments)
|
||||||
|
function execute() {
|
||||||
|
if (self.preExecute)
|
||||||
|
self.preExecute.apply(self, args);
|
||||||
|
let res = map.execute.apply(map, Array.slice(args, 1));
|
||||||
|
if (self.postExecute) // To do: get rid of self.
|
||||||
|
self.postExecute.apply(self, args);
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
|
||||||
onKeyPress: function onKeyPress(event) {
|
onKeyPress: function onKeyPress(event) {
|
||||||
// This all needs to go. It's horrible. --Kris
|
// This all needs to go. It's horrible. --Kris
|
||||||
|
|
||||||
const self = this;
|
|
||||||
|
|
||||||
let key = events.toString(event);
|
let key = events.toString(event);
|
||||||
let [, countStr, command] = /^((?:[1-9][0-9]*)?)(.*)/.exec(this.buffer + key);
|
let [, countStr, command] = /^((?:[1-9][0-9]*)?)(.*)/.exec(this.buffer + key);
|
||||||
|
|
||||||
var map = this.hive.get(this.main, command);
|
var map = this.hive.get(this.main, command);
|
||||||
|
|
||||||
function execute(map) {
|
|
||||||
if (self.preExecute)
|
|
||||||
self.preExecute.apply(self, arguments);
|
|
||||||
let res = map.execute.apply(map, Array.slice(arguments, 1));
|
|
||||||
if (self.postExecute) // To do: get rid of this.
|
|
||||||
self.postExecute.apply(self, arguments);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
let candidates = this.hive.getCandidates(this.main, command);
|
let candidates = this.hive.getCandidates(this.main, command);
|
||||||
if (candidates == 0 && !map) {
|
if (candidates == 0 && !map) {
|
||||||
[map] = this.pendingMap || [];
|
[map] = this.pendingMap || [];
|
||||||
@@ -1193,7 +1196,7 @@ var Events = Module("events", {
|
|||||||
else if (this.pendingArgMap) {
|
else if (this.pendingArgMap) {
|
||||||
let [map, command] = this.pendingArgMap;
|
let [map, command] = this.pendingArgMap;
|
||||||
if (!Events.isEscape(key))
|
if (!Events.isEscape(key))
|
||||||
execute(map, null, this.count, key, command);
|
return this.execute(map, null, this.count, key, command);
|
||||||
return Events.KILL;
|
return Events.KILL;
|
||||||
}
|
}
|
||||||
else if (!event.skipmap && map && candidates == 0) {
|
else if (!event.skipmap && map && candidates == 0) {
|
||||||
@@ -1212,7 +1215,7 @@ var Events = Module("events", {
|
|||||||
else if (this.pendingMotionMap) {
|
else if (this.pendingMotionMap) {
|
||||||
let [map, command] = this.pendingMotionMap;
|
let [map, command] = this.pendingMotionMap;
|
||||||
if (!Events.isEscape(key))
|
if (!Events.isEscape(key))
|
||||||
execute(map, command, this.motionCount || this.count, null, command);
|
return this.execute(map, command, this.motionCount || this.count, null, command);
|
||||||
return Events.KILL;
|
return Events.KILL;
|
||||||
}
|
}
|
||||||
else if (map.motion) {
|
else if (map.motion) {
|
||||||
@@ -1223,7 +1226,7 @@ var Events = Module("events", {
|
|||||||
if (modes.replaying && !events.waitForPageLoad())
|
if (modes.replaying && !events.waitForPageLoad())
|
||||||
return Events.KILL;
|
return Events.KILL;
|
||||||
|
|
||||||
return execute(map, null, this.count, null, command) === Events.PASS ? Events.PASS : Events.KILL;
|
return this.execute(map, null, this.count, null, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!event.skipmap && this.hive.getCandidates(this.main, command) > 0) {
|
else if (!event.skipmap && this.hive.getCandidates(this.main, command) > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user