1
0
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:
Kris Maglione
2011-01-19 20:20:54 -05:00
parent 260a8aad1b
commit a8a840afc2
3 changed files with 30 additions and 40 deletions

View File

@@ -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],
["<C-w>"], "Delete previous word",
function () { editor.executeCommand("cmd_deleteWordBackward", 1); });
mappings.add(myModes,
mappings.add([modes.INPUT],
["<C-u>"], "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],
["<C-k>"], "Delete until end of current line",
function () { editor.executeCommand("cmd_deleteToEndOfLine", 1); });
mappings.add(myModes,
mappings.add([modes.INPUT],
["<C-a>"], "Move cursor to beginning of current line",
function () { editor.executeCommand("cmd_beginLine", 1); });
mappings.add(myModes,
mappings.add([modes.INPUT],
["<C-e>"], "Move cursor to end of current line",
function () { editor.executeCommand("cmd_endLine", 1); });
mappings.add(myModes,
mappings.add([modes.INPUT],
["<C-h>"], "Delete character to the left",
function () { events.feedkeys("<BS>", true); });
mappings.add(myModes,
mappings.add([modes.INPUT],
["<C-d>"], "Delete character to the right",
function () { editor.executeCommand("cmd_deleteCharForward", 1); });
/*mappings.add(myModes,
/*mappings.add([modes.INPUT],
["<C-Home>"], "Move cursor to beginning of text field",
function () { editor.executeCommand("cmd_moveTop", 1); });
mappings.add(myModes,
mappings.add([modes.INPUT],
["<C-End>"], "Move cursor to end of text field",
function () { editor.executeCommand("cmd_moveBottom", 1); });*/
mappings.add(myModes,
mappings.add([modes.INPUT],
["<S-Insert>"], "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],
["<C-i>"], "Edit text field with an external editor",
function () { editor.editFieldExternally(); });
mappings.add([modes.INSERT, modes.COMMAND_LINE],
mappings.add([modes.INPUT],
["<C-t>"], "Edit text field in Vi mode",
function () {
dactyl.assert(!editor.isTextEdit);

View File

@@ -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) === "<C-h>")
event.dactylString = "<BS>";
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 = "";

View File

@@ -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 <embed> or <object> element is focused",
ownsFocus: true
});
this.addMode("PASS_THROUGH", {
description: "All keys but <C-v> 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 === "<C-v>") 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) {