mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 10:17:59 +01:00
Fix the MIW.
--HG-- branch : key-processing
This commit is contained in:
@@ -427,23 +427,17 @@ var CommandLine = Module("commandline", {
|
|||||||
// way of calling "open"
|
// way of calling "open"
|
||||||
this.currentExtendedMode = null; // the extended mode which we last opened the command line for
|
this.currentExtendedMode = null; // the extended mode which we last opened the command line for
|
||||||
|
|
||||||
// save the arguments for the inputMultiline method which are needed in the event handler
|
|
||||||
this._multilineEnd = null;
|
|
||||||
this._multilineCallback = null;
|
|
||||||
|
|
||||||
this._input = {};
|
this._input = {};
|
||||||
|
|
||||||
this.registerCallback("submit", modes.EX, function (command) {
|
this.registerCallback("submit", modes.EX, function (command) {
|
||||||
try {
|
io.withSavedValues(["readHeredoc", "sourcing"], function () {
|
||||||
var readHeredoc = io.readHeredoc;
|
this.sourcing = { file: "[Command Line]", line: 1 };
|
||||||
io.readHeredoc = commandline.readHeredoc;
|
this.readHeredoc = commandline.readHeredoc;
|
||||||
commands.repeat = command;
|
commands.repeat = command;
|
||||||
commands.execute(command);
|
dactyl.execute(command);
|
||||||
}
|
|
||||||
finally {
|
|
||||||
io.readHeredoc = readHeredoc;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.registerCallback("complete", modes.EX, function (context) {
|
this.registerCallback("complete", modes.EX, function (context) {
|
||||||
context.fork("ex", 0, completion, "ex");
|
context.fork("ex", 0, completion, "ex");
|
||||||
});
|
});
|
||||||
@@ -572,6 +566,9 @@ var CommandLine = Module("commandline", {
|
|||||||
nodeSet.commandline._completionList.hide();
|
nodeSet.commandline._completionList.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_multilineEnd: Modes.boundProperty(),
|
||||||
|
_multilineCallback: Modes.boundProperty(),
|
||||||
|
|
||||||
currentExtendedMode: Modes.boundProperty(),
|
currentExtendedMode: Modes.boundProperty(),
|
||||||
_completions: Modes.boundProperty(),
|
_completions: Modes.boundProperty(),
|
||||||
_history: Modes.boundProperty(),
|
_history: Modes.boundProperty(),
|
||||||
@@ -929,10 +926,8 @@ var CommandLine = Module("commandline", {
|
|||||||
|
|
||||||
readHeredoc: function readHeredoc(end) {
|
readHeredoc: function readHeredoc(end) {
|
||||||
let args;
|
let args;
|
||||||
commandline.inputMultiline(end,
|
commandline.inputMultiline(end, function (res) { args = res; });
|
||||||
function (res) { args = res; });
|
util.waitFor(function () args !== undefined);
|
||||||
while (args === undefined)
|
|
||||||
util.threadYield(true);
|
|
||||||
return args;
|
return args;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -947,7 +942,9 @@ var CommandLine = Module("commandline", {
|
|||||||
// FIXME: Buggy, especially when pasting.
|
// FIXME: Buggy, especially when pasting.
|
||||||
inputMultiline: function inputMultiline(end, callbackFunc) {
|
inputMultiline: function inputMultiline(end, callbackFunc) {
|
||||||
let cmd = this.command;
|
let cmd = this.command;
|
||||||
modes.push(modes.COMMAND_LINE, modes.INPUT_MULTILINE);
|
modes.push(modes.COMMAND_LINE, modes.INPUT_MULTILINE, {
|
||||||
|
keyModes: [modes.INPUT_MULTILINE]
|
||||||
|
});
|
||||||
if (cmd != false)
|
if (cmd != false)
|
||||||
this._echoLine(cmd, this.HL_NORMAL);
|
this._echoLine(cmd, this.HL_NORMAL);
|
||||||
|
|
||||||
@@ -1028,22 +1025,6 @@ var CommandLine = Module("commandline", {
|
|||||||
},
|
},
|
||||||
input: function onInput(event) {
|
input: function onInput(event) {
|
||||||
this._autosizeMultilineInputWidget();
|
this._autosizeMultilineInputWidget();
|
||||||
},
|
|
||||||
keypress: function onKeyPress(event) {
|
|
||||||
let key = events.toString(event);
|
|
||||||
if (events.isAcceptKey(key)) {
|
|
||||||
let text = "\n" + this.widgets.multilineInput.value.substr(0, this.widgets.multilineInput.selectionStart) + "\n";
|
|
||||||
let index = text.indexOf(this._multilineEnd);
|
|
||||||
if (index >= 0) {
|
|
||||||
text = text.substring(1, index);
|
|
||||||
let callback = this._multilineCallback;
|
|
||||||
modes.pop();
|
|
||||||
callback.call(this, text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (events.isCancelKey(key)) {
|
|
||||||
modes.pop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1085,7 +1066,7 @@ var CommandLine = Module("commandline", {
|
|||||||
onMOWKeyPress: function onMOWKeyPress(event) {
|
onMOWKeyPress: function onMOWKeyPress(event) {
|
||||||
const KILL = false, PASS = true;
|
const KILL = false, PASS = true;
|
||||||
|
|
||||||
if (options["more"] && mos.isScrollable(1))
|
if (options["more"] && mow.isScrollable(1))
|
||||||
commandline.updateMorePrompt(false, true);
|
commandline.updateMorePrompt(false, true);
|
||||||
else {
|
else {
|
||||||
modes.pop();
|
modes.pop();
|
||||||
@@ -1655,6 +1636,25 @@ var CommandLine = Module("commandline", {
|
|||||||
commandline._echoMultiline(commandline._lastMowOutput, commandline.HL_NORMAL);
|
commandline._echoMultiline(commandline._lastMowOutput, commandline.HL_NORMAL);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
mappings.add([modes.INPUT_MULTILINE],
|
||||||
|
["<Return>", "<C-j>", "<C-m>"], "Begin a new line",
|
||||||
|
function (args) {
|
||||||
|
let text = "\n" + commandline.widgets.multilineInput
|
||||||
|
.value.substr(0, commandline.widgets.multilineInput.selectionStart)
|
||||||
|
+ "\n";
|
||||||
|
|
||||||
|
let index = text.indexOf(commandline._multilineEnd);
|
||||||
|
if (index >= 0) {
|
||||||
|
text = text.substring(1, index);
|
||||||
|
let callback = commandline._multilineCallback;
|
||||||
|
modes.pop();
|
||||||
|
|
||||||
|
return function () callback.call(commandline, text);
|
||||||
|
}
|
||||||
|
return Events.PASS;
|
||||||
|
});
|
||||||
|
|
||||||
let bind = function bind()
|
let bind = function bind()
|
||||||
mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(Array.slice(arguments)))
|
mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(Array.slice(arguments)))
|
||||||
|
|
||||||
@@ -1682,7 +1682,7 @@ var CommandLine = Module("commandline", {
|
|||||||
commandline.currentExtendedMode = null; // Don't let modes.pop trigger "cancel"
|
commandline.currentExtendedMode = null; // Don't let modes.pop trigger "cancel"
|
||||||
modes.pop();
|
modes.pop();
|
||||||
|
|
||||||
commandline.triggerCallback("submit", mode, command);
|
return function () commandline.triggerCallback("submit", mode, command);
|
||||||
});
|
});
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -95,8 +95,11 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
|
|
||||||
if (modes.replaying && !events.waitForPageLoad())
|
if (modes.replaying && !events.waitForPageLoad())
|
||||||
result = Events.KILL;
|
result = Events.KILL;
|
||||||
else
|
else {
|
||||||
result = this.actions[0]() === Events.PASS ? Events.PASS : Events.KILL;
|
for (var res = this.actions[0]; callable(res);)
|
||||||
|
res = res();
|
||||||
|
result = res === Events.PASS ? Events.PASS : Events.KILL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (result !== Events.KILL && processors.some(function (p) !p.main.passUnknown)) {
|
else if (result !== Events.KILL && processors.some(function (p) !p.main.passUnknown)) {
|
||||||
result = Events.KILL;
|
result = Events.KILL;
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ var Map = Class("Map", {
|
|||||||
if (this.names[0] != ".") // FIXME: Kludge.
|
if (this.names[0] != ".") // FIXME: Kludge.
|
||||||
mappings.repeat = repeat;
|
mappings.repeat = repeat;
|
||||||
|
|
||||||
|
if (this.executing)
|
||||||
|
util.dumpStack("Attempt to execute mapping recursively: " + args.command);
|
||||||
dactyl.assert(!this.executing, "Attempt to execute mapping recursively: " + args.command);
|
dactyl.assert(!this.executing, "Attempt to execute mapping recursively: " + args.command);
|
||||||
this.executing = true;
|
this.executing = true;
|
||||||
let res = dactyl.trapErrors(repeat);
|
let res = dactyl.trapErrors(repeat);
|
||||||
|
|||||||
Reference in New Issue
Block a user