mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 14:27:58 +01:00
Move fallthrough handler proccessing until after all normal key handling. Make MOW mode a COMMAND mode. Move most input processing into INPUT mode. Fixes unnecessary closing of the MOW on :.
This commit is contained in:
@@ -400,7 +400,6 @@ var Editor = Module("editor", {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
mappings: function () {
|
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
|
// 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) {
|
function addMovementMap(keys, hasCount, caretModeMethod, caretModeArg, textEditCommand, visualTextEditCommand) {
|
||||||
@@ -528,11 +527,11 @@ var Editor = Module("editor", {
|
|||||||
addMotionMap("y"); // yank
|
addMotionMap("y"); // yank
|
||||||
|
|
||||||
// insert mode mappings
|
// insert mode mappings
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-w>"], "Delete previous word",
|
["<C-w>"], "Delete previous word",
|
||||||
function () { editor.executeCommand("cmd_deleteWordBackward", 1); });
|
function () { editor.executeCommand("cmd_deleteWordBackward", 1); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-u>"], "Delete until beginning of current line",
|
["<C-u>"], "Delete until beginning of current line",
|
||||||
function () {
|
function () {
|
||||||
// broken in FF3, deletes the whole line:
|
// broken in FF3, deletes the whole line:
|
||||||
@@ -542,44 +541,43 @@ var Editor = Module("editor", {
|
|||||||
editor.executeCommand("cmd_delete", 1);
|
editor.executeCommand("cmd_delete", 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-k>"], "Delete until end of current line",
|
["<C-k>"], "Delete until end of current line",
|
||||||
function () { editor.executeCommand("cmd_deleteToEndOfLine", 1); });
|
function () { editor.executeCommand("cmd_deleteToEndOfLine", 1); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-a>"], "Move cursor to beginning of current line",
|
["<C-a>"], "Move cursor to beginning of current line",
|
||||||
function () { editor.executeCommand("cmd_beginLine", 1); });
|
function () { editor.executeCommand("cmd_beginLine", 1); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-e>"], "Move cursor to end of current line",
|
["<C-e>"], "Move cursor to end of current line",
|
||||||
function () { editor.executeCommand("cmd_endLine", 1); });
|
function () { editor.executeCommand("cmd_endLine", 1); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-h>"], "Delete character to the left",
|
["<C-h>"], "Delete character to the left",
|
||||||
function () { events.feedkeys("<BS>", true); });
|
function () { events.feedkeys("<BS>", true); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-d>"], "Delete character to the right",
|
["<C-d>"], "Delete character to the right",
|
||||||
function () { editor.executeCommand("cmd_deleteCharForward", 1); });
|
function () { editor.executeCommand("cmd_deleteCharForward", 1); });
|
||||||
|
|
||||||
/*mappings.add(myModes,
|
/*mappings.add([modes.INPUT],
|
||||||
["<C-Home>"], "Move cursor to beginning of text field",
|
["<C-Home>"], "Move cursor to beginning of text field",
|
||||||
function () { editor.executeCommand("cmd_moveTop", 1); });
|
function () { editor.executeCommand("cmd_moveTop", 1); });
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<C-End>"], "Move cursor to end of text field",
|
["<C-End>"], "Move cursor to end of text field",
|
||||||
function () { editor.executeCommand("cmd_moveBottom", 1); });*/
|
function () { editor.executeCommand("cmd_moveBottom", 1); });*/
|
||||||
|
|
||||||
mappings.add(myModes,
|
mappings.add([modes.INPUT],
|
||||||
["<S-Insert>"], "Insert clipboard/selection",
|
["<S-Insert>"], "Insert clipboard/selection",
|
||||||
function () { editor.pasteClipboard(); });
|
function () { editor.pasteClipboard(); });
|
||||||
|
|
||||||
// TODO: a better way to specify mode types
|
mappings.add([modes.INPUT, modes.TEXT_EDIT],
|
||||||
mappings.add(modes.getCharModes("i").concat(modes.TEXT_EDIT, modes.COMMAND_LINE),
|
|
||||||
["<C-i>"], "Edit text field with an external editor",
|
["<C-i>"], "Edit text field with an external editor",
|
||||||
function () { editor.editFieldExternally(); });
|
function () { editor.editFieldExternally(); });
|
||||||
|
|
||||||
mappings.add([modes.INSERT, modes.COMMAND_LINE],
|
mappings.add([modes.INPUT],
|
||||||
["<C-t>"], "Edit text field in Vi mode",
|
["<C-t>"], "Edit text field in Vi mode",
|
||||||
function () {
|
function () {
|
||||||
dactyl.assert(!editor.isTextEdit);
|
dactyl.assert(!editor.isTextEdit);
|
||||||
|
|||||||
@@ -982,10 +982,6 @@ var Events = Module("events", {
|
|||||||
input.postExecute = params.postExecute;
|
input.postExecute = params.postExecute;
|
||||||
if (params.onEvent && input.hive === mappings.builtinHive)
|
if (params.onEvent && input.hive === mappings.builtinHive)
|
||||||
input.fallthrough = function (event) {
|
input.fallthrough = function (event) {
|
||||||
// Bloody hell.
|
|
||||||
if (events.toString(event) === "<C-h>")
|
|
||||||
event.dactylString = "<BS>";
|
|
||||||
|
|
||||||
return params.onEvent(event) === false ? Events.KILL : Events.PASS;
|
return params.onEvent(event) === false ? Events.KILL : Events.PASS;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1006,6 +1002,14 @@ var Events = Module("events", {
|
|||||||
break;
|
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)
|
if (!ownsBuffer)
|
||||||
statusline.updateInputBuffer(buffer);
|
statusline.updateInputBuffer(buffer);
|
||||||
|
|
||||||
@@ -1143,19 +1147,6 @@ var Events = Module("events", {
|
|||||||
let res = this.onKeyPress(event);
|
let res = this.onKeyPress(event);
|
||||||
if (res === Events.KILL)
|
if (res === Events.KILL)
|
||||||
kill(event);
|
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)
|
if (res != Events.WAIT)
|
||||||
this.inputBuffer = "";
|
this.inputBuffer = "";
|
||||||
|
|||||||
@@ -99,6 +99,10 @@ var Modes = Module("modes", {
|
|||||||
bases: [this.COMMAND],
|
bases: [this.COMMAND],
|
||||||
ownsFocus: true
|
ownsFocus: true
|
||||||
});
|
});
|
||||||
|
this.addMode("OUTPUT_MULTILINE", {
|
||||||
|
description: "Active when the multi-line output buffer is open",
|
||||||
|
bases: [this.COMMAND],
|
||||||
|
});
|
||||||
|
|
||||||
this.addMode("INPUT", {
|
this.addMode("INPUT", {
|
||||||
char: "I",
|
char: "I",
|
||||||
@@ -124,16 +128,16 @@ var Modes = Module("modes", {
|
|||||||
description: "Active when an <embed> or <object> element is focused",
|
description: "Active when an <embed> or <object> element is focused",
|
||||||
ownsFocus: true
|
ownsFocus: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addMode("PASS_THROUGH", {
|
this.addMode("PASS_THROUGH", {
|
||||||
description: "All keys but <C-v> are ignored by " + config.appName,
|
description: "All keys but <C-v> are ignored by " + config.appName,
|
||||||
bases: [],
|
bases: [this.BASE],
|
||||||
hidden: true
|
hidden: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addMode("QUOTE", {
|
this.addMode("QUOTE", {
|
||||||
hidden: true,
|
hidden: true,
|
||||||
description: "The next key sequence is ignored by " + config.appName + ", unless in Pass Through mode",
|
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
|
display: function () modes.getStack(1).main == modes.PASS_THROUGH
|
||||||
? (modes.getStack(2).main.display() || modes.getStack(2).main.name) + " (next)"
|
? (modes.getStack(2).main.display() || modes.getStack(2).main.name) + " (next)"
|
||||||
: "PASS THROUGH (next)"
|
: "PASS THROUGH (next)"
|
||||||
@@ -143,8 +147,9 @@ var Modes = Module("modes", {
|
|||||||
postExecute: function (map) { if (modes.main == modes.QUOTE && map.name === "<C-v>") modes.pop() },
|
postExecute: function (map) { if (modes.main == modes.QUOTE && map.name === "<C-v>") modes.pop() },
|
||||||
onEvent: function () { if (modes.main == modes.QUOTE) modes.pop() }
|
onEvent: function () { if (modes.main == modes.QUOTE) modes.pop() }
|
||||||
});
|
});
|
||||||
this.addMode("OUTPUT_MULTILINE", {
|
this.addMode("IGNORE", { hidden: true }, {
|
||||||
description: "Active when the multi-line output buffer is open"
|
onEvent: function (event) Events.KILL,
|
||||||
|
bases: []
|
||||||
});
|
});
|
||||||
|
|
||||||
// this._extended modes, can include multiple modes, and even main modes
|
// 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",
|
description: "Active when a prompt is open in the command line",
|
||||||
input: true
|
input: true
|
||||||
});
|
});
|
||||||
this.addMode("IGNORE", { hidden: true }, {
|
|
||||||
onEvent: function (event) Events.KILL,
|
|
||||||
bases: []
|
|
||||||
});
|
|
||||||
|
|
||||||
this.push(this.NORMAL, 0, {
|
this.push(this.NORMAL, 0, {
|
||||||
enter: function (stack, prev) {
|
enter: function (stack, prev) {
|
||||||
|
|||||||
Reference in New Issue
Block a user