diff --git a/common/content/editor.js b/common/content/editor.js index ff4775ad..b94fecb1 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -400,7 +400,6 @@ var Editor = Module("editor", { } }, { mappings: function () { - var myModes = [modes.INSERT, modes.COMMAND_LINE]; // add mappings for commands like h,j,k,l,etc. in CARET, VISUAL and TEXT_EDIT mode function addMovementMap(keys, hasCount, caretModeMethod, caretModeArg, textEditCommand, visualTextEditCommand) { @@ -528,11 +527,11 @@ var Editor = Module("editor", { addMotionMap("y"); // yank // insert mode mappings - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Delete previous word", function () { editor.executeCommand("cmd_deleteWordBackward", 1); }); - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Delete until beginning of current line", function () { // broken in FF3, deletes the whole line: @@ -542,44 +541,43 @@ var Editor = Module("editor", { editor.executeCommand("cmd_delete", 1); }); - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Delete until end of current line", function () { editor.executeCommand("cmd_deleteToEndOfLine", 1); }); - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Move cursor to beginning of current line", function () { editor.executeCommand("cmd_beginLine", 1); }); - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Move cursor to end of current line", function () { editor.executeCommand("cmd_endLine", 1); }); - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Delete character to the left", function () { events.feedkeys("", true); }); - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Delete character to the right", function () { editor.executeCommand("cmd_deleteCharForward", 1); }); - /*mappings.add(myModes, + /*mappings.add([modes.INPUT], [""], "Move cursor to beginning of text field", function () { editor.executeCommand("cmd_moveTop", 1); }); - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Move cursor to end of text field", function () { editor.executeCommand("cmd_moveBottom", 1); });*/ - mappings.add(myModes, + mappings.add([modes.INPUT], [""], "Insert clipboard/selection", function () { editor.pasteClipboard(); }); - // TODO: a better way to specify mode types - mappings.add(modes.getCharModes("i").concat(modes.TEXT_EDIT, modes.COMMAND_LINE), + mappings.add([modes.INPUT, modes.TEXT_EDIT], [""], "Edit text field with an external editor", function () { editor.editFieldExternally(); }); - mappings.add([modes.INSERT, modes.COMMAND_LINE], + mappings.add([modes.INPUT], [""], "Edit text field in Vi mode", function () { dactyl.assert(!editor.isTextEdit); diff --git a/common/content/events.js b/common/content/events.js index fb3b1e61..d40252a2 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -982,10 +982,6 @@ var Events = Module("events", { input.postExecute = params.postExecute; if (params.onEvent && input.hive === mappings.builtinHive) input.fallthrough = function (event) { - // Bloody hell. - if (events.toString(event) === "") - event.dactylString = ""; - return params.onEvent(event) === false ? Events.KILL : Events.PASS; }; } @@ -1006,6 +1002,14 @@ var Events = Module("events", { break; } + if (!refeed || refeed.length == 1) + for (let input in values(processors)) + if (input.fallthrough) { + if (res === Events.KILL) + break; + res = dactyl.trapErrors(input.fallthrough, input, event); + } + if (!ownsBuffer) statusline.updateInputBuffer(buffer); @@ -1143,19 +1147,6 @@ var Events = Module("events", { let res = this.onKeyPress(event); if (res === Events.KILL) kill(event); - else if (this.fallthrough) { - let evt = isArray(res) ? res[0] : event; - let r = dactyl.trapErrors(this.fallthrough, this, evt); - if (r === Events.KILL) - kill(evt); - res = r === Events.KILL ? Events.KILL : Events.PASS; - /* - if (r === Events.KILL) - res = res.slice(1); - else - res = r == Events.WAIT ? res : false; - */ - } if (res != Events.WAIT) this.inputBuffer = ""; diff --git a/common/content/modes.js b/common/content/modes.js index 863ca9d4..4dc372bf 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -99,6 +99,10 @@ var Modes = Module("modes", { bases: [this.COMMAND], ownsFocus: true }); + this.addMode("OUTPUT_MULTILINE", { + description: "Active when the multi-line output buffer is open", + bases: [this.COMMAND], + }); this.addMode("INPUT", { char: "I", @@ -124,16 +128,16 @@ var Modes = Module("modes", { description: "Active when an or element is focused", ownsFocus: true }); + this.addMode("PASS_THROUGH", { description: "All keys but are ignored by " + config.appName, - bases: [], + bases: [this.BASE], hidden: true }); - this.addMode("QUOTE", { hidden: true, description: "The next key sequence is ignored by " + config.appName + ", unless in Pass Through mode", - bases: [], + bases: [this.BASE], display: function () modes.getStack(1).main == modes.PASS_THROUGH ? (modes.getStack(2).main.display() || modes.getStack(2).main.name) + " (next)" : "PASS THROUGH (next)" @@ -143,8 +147,9 @@ var Modes = Module("modes", { postExecute: function (map) { if (modes.main == modes.QUOTE && map.name === "") modes.pop() }, onEvent: function () { if (modes.main == modes.QUOTE) modes.pop() } }); - this.addMode("OUTPUT_MULTILINE", { - description: "Active when the multi-line output buffer is open" + this.addMode("IGNORE", { hidden: true }, { + onEvent: function (event) Events.KILL, + bases: [] }); // this._extended modes, can include multiple modes, and even main modes @@ -177,10 +182,6 @@ var Modes = Module("modes", { description: "Active when a prompt is open in the command line", input: true }); - this.addMode("IGNORE", { hidden: true }, { - onEvent: function (event) Events.KILL, - bases: [] - }); this.push(this.NORMAL, 0, { enter: function (stack, prev) {