- mappings.add([modes.INPUT],
- ["<C-h>"], "Delete character to the left",
- function () { events.feedkeys("<BS>", true); });
-
- mappings.add([modes.INPUT],
- ["<C-d>"], "Delete character to the right",
- function () { editor.executeCommand("cmd_deleteCharForward", 1); });
-
- mappings.add([modes.INPUT],
- ["<S-Insert>"], "Insert clipboard/selection",
- function () { editor.pasteClipboard(); });
-
- mappings.add([modes.INPUT, modes.TEXT_EDIT],
- ["<C-i>"], "Edit text field with an external editor",
- function () { editor.editFieldExternally(); });
-
- mappings.add([modes.INPUT],
- ["<C-t>"], "Edit text field in Vi mode",
- function () {
- dactyl.assert(!editor.isTextEdit);
- modes.push(modes.TEXT_EDIT);
- });
+ if (command != "c")
+ sel.modify("extend", "forward", "character");
+ },
+ { count: true, type: "operator" });
+
+ let bind = function bind(names, description, action, params)
+ mappings.add([modes.INPUT], names, description,
+ action, update({ type: "editor" }, params));
+
+ bind(["<C-w>"], "Delete previous word",
+ function () {
+ if (editor.editor)
+ clear(false, /\w/)(editor.editor);
+ else
+ editor.executeCommand("cmd_deleteWordBackward", 1);
+ });
+
+ bind(["<C-u>"], "Delete until beginning of current line",
+ function () {
+ // Deletes the whole line. What the hell.
+ // editor.executeCommand("cmd_deleteToBeginningOfLine", 1);
+
+ editor.executeCommand("cmd_selectBeginLine", 1);
+ if (editor.selection && editor.selection.isCollapsed) {
+ editor.executeCommand("cmd_deleteCharBackward", 1);
+ editor.executeCommand("cmd_selectBeginLine", 1);
+ }
+
+ if (editor.getController("cmd_delete").isCommandEnabled("cmd_delete"))
+ editor.executeCommand("cmd_delete", 1);
+ });
+
+ bind(["<C-k>"], "Delete until end of current line",
+ function () { editor.executeCommand("cmd_deleteToEndOfLine", 1); });
+
+ bind(["<C-a>"], "Move cursor to beginning of current line",
+ function () { editor.executeCommand("cmd_beginLine", 1); });
+
+ bind(["<C-e>"], "Move cursor to end of current line",
+ function () { editor.executeCommand("cmd_endLine", 1); });
+
+ bind(["<C-h>"], "Delete character to the left",
+ function () { events.feedkeys("<BS>", true); });
+
+ bind(["<C-d>"], "Delete character to the right",
+ function () { editor.executeCommand("cmd_deleteCharForward", 1); });
+
+ bind(["<S-Insert>"], "Insert clipboard/selection",
+ function () { editor.paste(); });
+
+ bind(["<C-i>"], "Edit text field with an external editor",
+ function () { editor.editFieldExternally(); });
+
+ bind(["<C-t>"], "Edit text field in Text Edit mode",
+ function () {
+ dactyl.assert(!editor.isTextEdit && editor.editor);
+ dactyl.assert(dactyl.focusedElement ||
+ // Sites like Google like to use a
+ // hidden, editable window for keyboard
+ // focus and use their own WYSIWYG editor
+ // implementations for the visible area,
+ // which we can't handle.
+ let (f = document.commandDispatcher.focusedWindow.frameElement)
+ f && Hints.isVisible(f, true));
+
+ modes.push(modes.TEXT_EDIT);
+ });
+
+ // Ugh.
+ mappings.add([modes.INPUT, modes.CARET],
+ ["<*-CR>", "<*-BS>", "<*-Del>", "<*-Left>", "<*-Right>", "<*-Up>", "<*-Down>",
+ "<*-Home>", "<*-End>", "<*-PageUp>", "<*-PageDown>",
+ "<M-c>", "<M-v>", "<*-Tab>"],
+ "Handled by " + config.host,
+ function () Events.PASS_THROUGH);