diff --git a/common/content/commandline.js b/common/content/commandline.js
index 08f091ff..bd58c799 100644
--- a/common/content/commandline.js
+++ b/common/content/commandline.js
@@ -42,7 +42,7 @@ var CommandWidgets = Class("CommandWidgets", {
+ highlight="Normal Events" events="multilineInputEvents" />
@@ -569,9 +569,6 @@ var CommandLine = Module("commandline", {
nodeSet.commandline.completionList.visible = false;
},
- _multilineEnd: Modes.boundProperty(),
- _multilineCallback: Modes.boundProperty(),
-
_lastClearable: Modes.boundProperty(),
messages: Modes.boundProperty(),
@@ -759,20 +756,21 @@ var CommandLine = Module("commandline", {
* callback with that string as a parameter.
*
* @param {string} end
- * @param {function(string)} callbackFunc
+ * @param {function(string)} callback
*/
// FIXME: Buggy, especially when pasting.
- inputMultiline: function inputMultiline(end, callbackFunc) {
+ inputMultiline: function inputMultiline(end, callback) {
let cmd = this.command;
- modes.push(modes.COMMAND_LINE, modes.INPUT_MULTILINE, {
- keyModes: [modes.INPUT_MULTILINE]
+ modes.push(modes.INPUT_MULTILINE, null, {
+ mappingSelf: {
+ end: "\n" + end + "\n",
+ callback: callback
+ }
});
if (cmd != false)
this._echoLine(cmd, this.HL_NORMAL);
// save the arguments, they are needed in the event handler onKeyPress
- this._multilineEnd = "\n" + end + "\n";
- this._multilineCallback = callbackFunc;
this.multilineInputVisible = true;
this.widgets.multilineInput.value = "";
@@ -816,7 +814,7 @@ var CommandLine = Module("commandline", {
*/
multilineInputEvents: {
blur: function onBlur(event) {
- if (modes.extended & modes.INPUT_MULTILINE)
+ if (modes.main == modes.INPUT_MULTILINE)
this.timeout(function () {
dactyl.focus(this.widgets.multilineInput.inputField);
});
@@ -1355,6 +1353,11 @@ var CommandLine = Module("commandline", {
bases: [modes.COMMAND_LINE],
input: true
});
+
+ modes.addMode("INPUT_MULTILINE", {
+ bases: [modes.INSERT],
+ input: true
+ });
},
mappings: function init_mappings() {
@@ -1364,18 +1367,17 @@ var CommandLine = Module("commandline", {
mappings.add([modes.INPUT_MULTILINE],
["", "", ""], "Begin a new line",
- function (args) {
+ function ({ self }) {
let text = "\n" + commandline.widgets.multilineInput
.value.substr(0, commandline.widgets.multilineInput.selectionStart)
+ "\n";
- let index = text.indexOf(commandline._multilineEnd);
+ let index = text.indexOf(self.end);
if (index >= 0) {
text = text.substring(1, index);
- let callback = commandline._multilineCallback;
modes.pop();
- return function () callback.call(commandline, text);
+ return function () self.callback.call(commandline, text);
}
return Events.PASS;
});
diff --git a/common/content/modes.js b/common/content/modes.js
index 8a553bf7..c505cce4 100644
--- a/common/content/modes.js
+++ b/common/content/modes.js
@@ -154,11 +154,6 @@ var Modes = Module("modes", {
input: true
});
- this.addMode("INPUT_MULTILINE", {
- extended: true,
- hidden: true,
- input: true
- });
this.addMode("LINE", {
extended: true, hidden: true
});