mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-02 16:15:45 +01:00
Fix processing of fake input events in the command line.
This commit is contained in:
@@ -379,7 +379,6 @@ var CommandMode = Class("CommandMode", {
|
|||||||
if (waiting)
|
if (waiting)
|
||||||
this.completions.onComplete = bind("onSubmit", this);
|
this.completions.onComplete = bind("onSubmit", this);
|
||||||
|
|
||||||
this.resetCompletions();
|
|
||||||
commandline.hideCompletions();
|
commandline.hideCompletions();
|
||||||
|
|
||||||
modes.delay(function () {
|
modes.delay(function () {
|
||||||
@@ -395,6 +394,7 @@ var CommandMode = Class("CommandMode", {
|
|||||||
|
|
||||||
events: {
|
events: {
|
||||||
input: function CM_onInput(event) {
|
input: function CM_onInput(event) {
|
||||||
|
util.dumpStack();
|
||||||
if (this.completions) {
|
if (this.completions) {
|
||||||
this.resetCompletions();
|
this.resetCompletions();
|
||||||
|
|
||||||
@@ -428,7 +428,7 @@ var CommandMode = Class("CommandMode", {
|
|||||||
|
|
||||||
resetCompletions: function CM_resetCompletions() {
|
resetCompletions: function CM_resetCompletions() {
|
||||||
if (this.completions)
|
if (this.completions)
|
||||||
this.completions.quit();
|
this.completions.clear();
|
||||||
if (this.history)
|
if (this.history)
|
||||||
this.history.reset();
|
this.history.reset();
|
||||||
},
|
},
|
||||||
@@ -1040,8 +1040,10 @@ var CommandLine = Module("commandline", {
|
|||||||
this.input = input;
|
this.input = input;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
|
|
||||||
this.wildmode = options.get("wildmode");
|
this.wildmode = options.get("wildmode");
|
||||||
this.wildtypes = this.wildmode.value;
|
this.wildtypes = this.wildmode.value;
|
||||||
|
|
||||||
this.itemList = commandline.completionList;
|
this.itemList = commandline.completionList;
|
||||||
this.itemList.open(this.context);
|
this.itemList.open(this.context);
|
||||||
|
|
||||||
@@ -1055,6 +1057,7 @@ var CommandLine = Module("commandline", {
|
|||||||
this.complete(true, false);
|
this.complete(true, false);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.tabTimer = Timer(0, 0, function tabTell(event) {
|
this.tabTimer = Timer(0, 0, function tabTell(event) {
|
||||||
let tabCount = this.tabCount;
|
let tabCount = this.tabCount;
|
||||||
this.tabCount = 0;
|
this.tabCount = 0;
|
||||||
@@ -1064,23 +1067,6 @@ var CommandLine = Module("commandline", {
|
|||||||
|
|
||||||
tabCount: 0,
|
tabCount: 0,
|
||||||
|
|
||||||
cleanup: function () {
|
|
||||||
dactyl.unregisterObserver("events.doneFeeding", this.closure.onDoneFeeding);
|
|
||||||
this.previewClear();
|
|
||||||
this.tabTimer.reset();
|
|
||||||
this.autocompleteTimer.reset();
|
|
||||||
this.itemList.visible = false;
|
|
||||||
this.input.dactylKeyPress = undefined;
|
|
||||||
this.hasQuit = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
quit: function quit() {
|
|
||||||
if (!this.onComplete)
|
|
||||||
this.context.cancelAll();
|
|
||||||
this.wildIndex = -1;
|
|
||||||
this.previewClear();
|
|
||||||
},
|
|
||||||
|
|
||||||
ignoredCount: 0,
|
ignoredCount: 0,
|
||||||
onDoneFeeding: function onDoneFeeding() {
|
onDoneFeeding: function onDoneFeeding() {
|
||||||
if (this.ignoredCount)
|
if (this.ignoredCount)
|
||||||
@@ -1144,17 +1130,96 @@ var CommandLine = Module("commandline", {
|
|||||||
|
|
||||||
complete: function complete(show, tabPressed) {
|
complete: function complete(show, tabPressed) {
|
||||||
this.session.ignoredCount = 0;
|
this.session.ignoredCount = 0;
|
||||||
|
|
||||||
this.context.reset();
|
this.context.reset();
|
||||||
this.context.tabPressed = tabPressed;
|
this.context.tabPressed = tabPressed;
|
||||||
|
|
||||||
this.session.complete(this.context);
|
this.session.complete(this.context);
|
||||||
if (!this.session.active)
|
if (!this.session.active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.context.updateAsync = true;
|
this.context.updateAsync = true;
|
||||||
this.reset(show, tabPressed);
|
this.reset(show, tabPressed);
|
||||||
this.wildIndex = 0;
|
this.wildIndex = 0;
|
||||||
this._caret = this.caret;
|
this._caret = this.caret;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanup: function () {
|
||||||
|
dactyl.unregisterObserver("events.doneFeeding", this.closure.onDoneFeeding);
|
||||||
|
this.previewClear();
|
||||||
|
|
||||||
|
this.tabTimer.reset();
|
||||||
|
this.autocompleteTimer.reset();
|
||||||
|
if (!this.onComplete)
|
||||||
|
this.context.cancelAll();
|
||||||
|
|
||||||
|
this.itemList.visible = false;
|
||||||
|
this.input.dactylKeyPress = undefined;
|
||||||
|
this.hasQuit = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
saveInput: function saveInput() {
|
||||||
|
this.prefix = this.context.value.substring(0, this.start);
|
||||||
|
this.value = this.context.value.substring(this.start, this.caret);
|
||||||
|
this.suffix = this.context.value.substring(this.caret);
|
||||||
|
},
|
||||||
|
|
||||||
|
clear: function clear() {
|
||||||
|
this.context.cancelAll();
|
||||||
|
this.wildIndex = -1;
|
||||||
|
this.previewClear();
|
||||||
|
},
|
||||||
|
|
||||||
|
reset: function reset(show) {
|
||||||
|
this.waiting = null;
|
||||||
|
this.wildIndex = -1;
|
||||||
|
|
||||||
|
this.saveInput();
|
||||||
|
|
||||||
|
if (show) {
|
||||||
|
this.itemList.update();
|
||||||
|
if (this.haveType("list"))
|
||||||
|
this.itemList.visible = true;
|
||||||
|
this.selected = null;
|
||||||
|
this.wildIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.preview();
|
||||||
|
},
|
||||||
|
|
||||||
|
asyncUpdate: function asyncUpdate(context) {
|
||||||
|
if (this.hasQuit) {
|
||||||
|
let item = this.getItem(this.waiting);
|
||||||
|
if (item && this.waiting && this.onComplete) {
|
||||||
|
this.onComplete(this.prefix + item.result + this.suffix);
|
||||||
|
this.waiting = null;
|
||||||
|
this.context.cancelAll();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let value = this.editor.selection.focusNode.textContent;
|
||||||
|
this.saveInput();
|
||||||
|
|
||||||
|
this.itemList.updateContext(context);
|
||||||
|
|
||||||
|
if (this.waiting && this.waiting[0] == context)
|
||||||
|
this.select(this.waiting);
|
||||||
|
else if (!this.waiting) {
|
||||||
|
let group = this.itemList.selectedGroup;
|
||||||
|
if (group && group.context == context && this.completion) {
|
||||||
|
this.selected = null;
|
||||||
|
if (group.selectedIdx != null)
|
||||||
|
this.selected = [group.context, group.selectedIdx];
|
||||||
|
|
||||||
|
this.completion = this.selected ? this.getItem().result
|
||||||
|
: this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.preview();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
haveType: function haveType(type)
|
haveType: function haveType(type)
|
||||||
this.wildmode.checkHas(this.wildtype, type == "first" ? "" : type),
|
this.wildmode.checkHas(this.wildtype, type == "first" ? "" : type),
|
||||||
|
|
||||||
@@ -1236,60 +1301,6 @@ var CommandLine = Module("commandline", {
|
|||||||
delete this.removeSubstring;
|
delete this.removeSubstring;
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function reset(show) {
|
|
||||||
this.waiting = null;
|
|
||||||
this.wildIndex = -1;
|
|
||||||
|
|
||||||
this.prefix = this.context.value.substring(0, this.start);
|
|
||||||
this.value = this.context.value.substring(this.start, this.caret);
|
|
||||||
this.suffix = this.context.value.substring(this.caret);
|
|
||||||
|
|
||||||
if (show) {
|
|
||||||
this.itemList.update();
|
|
||||||
if (this.haveType("list"))
|
|
||||||
this.itemList.visible = true;
|
|
||||||
this.selected = null;
|
|
||||||
this.wildIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.preview();
|
|
||||||
},
|
|
||||||
|
|
||||||
asyncUpdate: function asyncUpdate(context) {
|
|
||||||
if (this.hasQuit) {
|
|
||||||
let item = this.getItem(this.waiting);
|
|
||||||
if (item && this.waiting && this.onComplete) {
|
|
||||||
this.onComplete(this.prefix + item.result + this.suffix);
|
|
||||||
this.waiting = null;
|
|
||||||
this.context.cancelAll();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let value = this.editor.selection.focusNode.textContent;
|
|
||||||
this.prefix = value.substring(0, this.start);
|
|
||||||
this.value = value.substring(this.start, this.caret);
|
|
||||||
this.suffix = value.substring(this.caret);
|
|
||||||
|
|
||||||
this.itemList.updateContext(context);
|
|
||||||
|
|
||||||
if (this.waiting && this.waiting[0] == context)
|
|
||||||
this.select(this.waiting);
|
|
||||||
else if (!this.waiting) {
|
|
||||||
let group = this.itemList.selectedGroup;
|
|
||||||
if (group && group.context == context && this.completion) {
|
|
||||||
this.selected = null;
|
|
||||||
if (group.selectedIdx != null)
|
|
||||||
this.selected = [group.context, group.selectedIdx];
|
|
||||||
|
|
||||||
this.completion = this.selected ? this.getItem().result
|
|
||||||
: this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.preview();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
select: function select(idx, count, fromTab) {
|
select: function select(idx, count, fromTab) {
|
||||||
count = count || 1;
|
count = count || 1;
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,8 @@ var Template = Module("Template", {
|
|||||||
|
|
||||||
let obj = params.eventTarget;
|
let obj = params.eventTarget;
|
||||||
let events = obj[this.getAttribute("events") || "events"];
|
let events = obj[this.getAttribute("events") || "events"];
|
||||||
|
if (Set.has(events, "input"))
|
||||||
|
events["dactyl-input"] = events["input"];
|
||||||
|
|
||||||
for (let [event, handler] in Iterator(events))
|
for (let [event, handler] in Iterator(events))
|
||||||
node.addEventListener(event, obj.closure(handler), false);
|
node.addEventListener(event, obj.closure(handler), false);
|
||||||
|
|||||||
Reference in New Issue
Block a user