mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-07 07:55:47 +01:00
More Vim-like processing of partially matched key chains: reprocess remaining unmatched keys from scratch.
This commit is contained in:
@@ -61,7 +61,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
|
|
||||||
execute: function execute(result, force) {
|
execute: function execute(result, force) {
|
||||||
let processors = this.processors;
|
let processors = this.processors;
|
||||||
util.dump("execute", this._result(result), force, String(processors.map(function (p) [p.main, p.main.passUnknown])));
|
let length = 1;
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
this.processors = [];
|
this.processors = [];
|
||||||
@@ -70,15 +70,11 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
statusline.inputBuffer = this.processors.length ? this.buffer : "";
|
statusline.inputBuffer = this.processors.length ? this.buffer : "";
|
||||||
|
|
||||||
if (!processors.some(function (p) !p.extended) && this.actions.length) {
|
if (!processors.some(function (p) !p.extended) && this.actions.length) {
|
||||||
if (this._actions.length == 0) {
|
|
||||||
dactyl.beep();
|
|
||||||
events.feedingKeys = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var action in values(this.actions)) {
|
for (var action in values(this.actions)) {
|
||||||
while (callable(action)) {
|
while (callable(action)) {
|
||||||
|
length = action.eventLength;
|
||||||
action = dactyl.trapErrors(action);
|
action = dactyl.trapErrors(action);
|
||||||
events.dbg("ACTION RES: " + this._result(action));
|
events.dbg("ACTION RES: " + length + " " + this._result(action));
|
||||||
}
|
}
|
||||||
if (action !== Events.PASS)
|
if (action !== Events.PASS)
|
||||||
break;
|
break;
|
||||||
@@ -94,9 +90,8 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
this.timer = services.Timer(this, options["timeoutlen"], services.Timer.TYPE_ONE_SHOT);
|
this.timer = services.Timer(this, options["timeoutlen"], services.Timer.TYPE_ONE_SHOT);
|
||||||
}
|
}
|
||||||
else if (result !== Events.KILL && !this.actions.length &&
|
else if (result !== Events.KILL && !this.actions.length &&
|
||||||
(this.events.length > 1 ||
|
processors.some(function (p) !p.main.passUnknown)) {
|
||||||
processors.some(function (p) !p.main.passUnknown))) {
|
result = Events.ABORT;
|
||||||
result = Events.KILL;
|
|
||||||
if (!Events.isEscape(this.events.slice(-1)[0]))
|
if (!Events.isEscape(this.events.slice(-1)[0]))
|
||||||
dactyl.beep();
|
dactyl.beep();
|
||||||
events.feedingKeys = false;
|
events.feedingKeys = false;
|
||||||
@@ -104,7 +99,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
else if (result === undefined)
|
else if (result === undefined)
|
||||||
result = Events.PASS;
|
result = Events.PASS;
|
||||||
|
|
||||||
events.dbg("RESULT: " + this._result(result));
|
events.dbg("RESULT: " + length + " " + this._result(result));
|
||||||
|
|
||||||
if (result === Events.PASS || result === Events.PASS_THROUGH)
|
if (result === Events.PASS || result === Events.PASS_THROUGH)
|
||||||
if (this.events[0].originalTarget)
|
if (this.events[0].originalTarget)
|
||||||
@@ -117,11 +112,17 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
events.passing = true;
|
events.passing = true;
|
||||||
events.feedevents(null, this.keyEvents, { 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 {
|
||||||
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 (result === Events.PASS)
|
||||||
events.dbg("REFEED: " + list.map(events.closure.toString).join(""));
|
events.dbg("PASS THROUGH: " + list.slice(0, length).filter(function (e) e.type === "keypress").map(events.toString));
|
||||||
events.feedevents(null, list, { skipmap: true, isMacro: true, isReplay: true });
|
if (list.length > length)
|
||||||
|
events.dbg("REFEED: " + list.slice(length).filter(function (e) e.type === "keypress").map(events.toString));
|
||||||
|
|
||||||
|
if (result === Events.PASS)
|
||||||
|
events.feedevents(null, list.slice(0, length), { skipmap: true, isMacro: true, isReplay: true });
|
||||||
|
if (list.length > length)
|
||||||
|
events.feedevents(null, list.slice(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.processors.length === 0;
|
return this.processors.length === 0;
|
||||||
@@ -171,6 +172,10 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
this._actions = actions;
|
this._actions = actions;
|
||||||
this.actions = actions.concat(this.actions);
|
this.actions = actions.concat(this.actions);
|
||||||
|
|
||||||
|
for (let action in values(actions))
|
||||||
|
if (!("eventLength" in action))
|
||||||
|
action.eventLength = this.events.length;
|
||||||
|
|
||||||
if (result === Events.KILL)
|
if (result === Events.KILL)
|
||||||
this.actions = [];
|
this.actions = [];
|
||||||
else if (!this.actions.length && !processors.length)
|
else if (!this.actions.length && !processors.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user