diff --git a/common/content/editor.js b/common/content/editor.js index 32052505..94347886 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -19,7 +19,7 @@ const Editor = Module("editor", { }, get isCaret() modes.getStack(1).main === modes.CARET, - get isTextArea() modes.getStack(1).main === modes.TEXTAREA, + get isTextEdit() modes.getStack(1).main === modes.TEXT_EDIT, line: function () { let line = 1; @@ -189,16 +189,16 @@ const Editor = Module("editor", { switch (cmd) { case "d": this.executeCommand("cmd_delete", 1); - modes.pop(modes.TEXTAREA); + modes.pop(modes.TEXT_EDIT); break; case "c": this.executeCommand("cmd_delete", 1); - modes.pop(modes.TEXTAREA); + modes.pop(modes.TEXT_EDIT); modes.push(modes.INSERT); break; case "y": this.executeCommand("cmd_copy", 1); - modes.pop(modes.TEXTAREA); + modes.pop(modes.TEXT_EDIT); break; default: @@ -436,8 +436,8 @@ const 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 TEXTAREA mode - function addMovementMap(keys, hasCount, caretModeMethod, caretModeArg, textareaCommand, visualTextareaCommand) { + // 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) { let extraInfo = {}; if (hasCount) extraInfo.count = true; @@ -483,11 +483,11 @@ const Editor = Module("editor", { let controller = buffer.selectionController; while (count-- && modes.main == modes.VISUAL) { - if (editor.isTextArea) { - if (typeof visualTextareaCommand == "function") - visualTextareaCommand(); + if (editor.isTextEdit) { + if (typeof visualTextEditCommand == "function") + visualTextEditCommand(); else - editor.executeCommand(visualTextareaCommand); + editor.executeCommand(visualTextEditCommand); } else caretExecute(true, true); @@ -495,19 +495,19 @@ const Editor = Module("editor", { }, extraInfo); - mappings.add([modes.TEXTAREA], keys, "", + mappings.add([modes.TEXT_EDIT], keys, "", function (count) { if (typeof count != "number" || count < 1) count = 1; - editor.executeCommand(textareaCommand, count); + editor.executeCommand(textEditCommand, count); }, extraInfo); } - // add mappings for commands like i,a,s,c,etc. in TEXTAREA mode + // add mappings for commands like i,a,s,c,etc. in TEXT_EDIT mode function addBeginInsertModeMap(keys, commands) { - mappings.add([modes.TEXTAREA], keys, "", + mappings.add([modes.TEXT_EDIT], keys, "", function (count) { commands.forEach(function (cmd) editor.executeCommand(cmd, 1)); @@ -516,7 +516,7 @@ const Editor = Module("editor", { } function addMotionMap(key) { - mappings.add([modes.TEXTAREA], [key], + mappings.add([modes.TEXT_EDIT], [key], "Motion command", function (motion, count) { editor.executeCommandWithMotion(key, motion, count); }, { count: true, motion: true }); @@ -532,7 +532,7 @@ const Editor = Module("editor", { editor.executeCommand("cmd_selectLineNext"); } - // KEYS COUNT CARET TEXTAREA VISUAL_TEXTAREA + // KEYS COUNT CARET TEXT_EDIT VISUAL_TEXT_EDIT addMovementMap(["k", ""], true, "lineMove", false, "cmd_linePrevious", selectPreviousLine); addMovementMap(["j", "", ""], true, "lineMove", true, "cmd_lineNext", selectNextLine); addMovementMap(["h", "", ""], true, "characterMove", false, "cmd_charPrevious", "cmd_selectCharPrevious"); @@ -612,8 +612,8 @@ const Editor = Module("editor", { mappings.add([modes.INSERT], [""], "Edit text field in Vi mode", function () { - if (!editor.isTextArea) - modes.push(modes.TEXTAREA); + if (!editor.isTextEdit) + modes.push(modes.TEXT_EDIT); else dactyl.beep(); }); @@ -631,8 +631,8 @@ const Editor = Module("editor", { ["", ""], "Expand insert mode abbreviation", function () { editor.expandAbbreviation(modes.INSERT); }); - // textarea mode - mappings.add([modes.TEXTAREA], + // text edit mode + mappings.add([modes.TEXT_EDIT], ["u"], "Undo", function (count) { editor.executeCommand("cmd_undo", count); @@ -640,7 +640,7 @@ const Editor = Module("editor", { }, { count: true }); - mappings.add([modes.TEXTAREA], + mappings.add([modes.TEXT_EDIT], [""], "Redo", function (count) { editor.executeCommand("cmd_redo", count); @@ -648,11 +648,11 @@ const Editor = Module("editor", { }, { count: true }); - mappings.add([modes.TEXTAREA], + mappings.add([modes.TEXT_EDIT], ["D"], "Delete the characters under the cursor until the end of the line", function () { editor.executeCommand("cmd_deleteToEndOfLine"); }); - mappings.add([modes.TEXTAREA], + mappings.add([modes.TEXT_EDIT], ["o"], "Open line below current", function (count) { editor.executeCommand("cmd_endLine", 1); @@ -660,7 +660,7 @@ const Editor = Module("editor", { events.feedkeys(""); }); - mappings.add([modes.TEXTAREA], + mappings.add([modes.TEXT_EDIT], ["O"], "Open line above current", function (count) { editor.executeCommand("cmd_beginLine", 1); @@ -669,18 +669,18 @@ const Editor = Module("editor", { editor.executeCommand("cmd_linePrevious", 1); }); - mappings.add([modes.TEXTAREA], + mappings.add([modes.TEXT_EDIT], ["X"], "Delete character to the left", function (count) { editor.executeCommand("cmd_deleteCharBackward", count); }, { count: true }); - mappings.add([modes.TEXTAREA], + mappings.add([modes.TEXT_EDIT], ["x"], "Delete character to the right", function (count) { editor.executeCommand("cmd_deleteCharForward", count); }, { count: true }); // visual mode - mappings.add([modes.CARET, modes.TEXTAREA], + mappings.add([modes.CARET, modes.TEXT_EDIT], ["v"], "Start visual mode", function (count) { modes.push(modes.VISUAL); }); @@ -688,7 +688,7 @@ const Editor = Module("editor", { ["v"], "End visual mode", function (count) { events.onEscape(); }); - mappings.add([modes.TEXTAREA], + mappings.add([modes.TEXT_EDIT], ["V"], "Start visual line mode", function (count) { modes.push(modes.VISUAL, modes.LINE); @@ -699,15 +699,15 @@ const Editor = Module("editor", { mappings.add([modes.VISUAL], ["c", "s"], "Change selected text", function (count) { - dactyl.assert(editor.isTextArea); + dactyl.assert(editor.isTextEdit); editor.executeCommand("cmd_cut"); - modes.replace(modes.INSERT, modes.TEXTAREA); + modes.replace(modes.INSERT, modes.TEXT_EDIT); }); mappings.add([modes.VISUAL], ["d"], "Delete selected text", function (count) { - if (editor.isTextArea) { + if (editor.isTextEdit) { editor.executeCommand("cmd_cut"); modes.pop(); } @@ -718,7 +718,7 @@ const Editor = Module("editor", { mappings.add([modes.VISUAL], ["y"], "Yank selected text", function (count) { - if (editor.isTextArea) { + if (editor.isTextEdit) { editor.executeCommand("cmd_copy"); modes.pop(); } @@ -726,7 +726,7 @@ const Editor = Module("editor", { dactyl.clipboardWrite(buffer.getCurrentWord(), true); }); - mappings.add([modes.VISUAL, modes.TEXTAREA], + mappings.add([modes.VISUAL, modes.TEXT_EDIT], ["p"], "Paste clipboard contents", function (count) { dactyl.assert(!editor.isCaret); @@ -734,11 +734,11 @@ const Editor = Module("editor", { count = 1; while (count--) editor.executeCommand("cmd_paste"); - modes.pop(modes.TEXTAREA); + modes.pop(modes.TEXT_EDIT); }); // finding characters - mappings.add([modes.TEXTAREA, modes.VISUAL], + mappings.add([modes.TEXT_EDIT, modes.VISUAL], ["f"], "Move to a character on the current line after the cursor", function (count, arg) { let pos = editor.findCharForward(arg, count); @@ -747,7 +747,7 @@ const Editor = Module("editor", { }, { arg: true, count: true }); - mappings.add([modes.TEXTAREA, modes.VISUAL], + mappings.add([modes.TEXT_EDIT, modes.VISUAL], ["F"], "Move to a charater on the current line before the cursor", function (count, arg) { let pos = editor.findCharBackward(arg, count); @@ -756,7 +756,7 @@ const Editor = Module("editor", { }, { arg: true, count: true }); - mappings.add([modes.TEXTAREA, modes.VISUAL], + mappings.add([modes.TEXT_EDIT, modes.VISUAL], ["t"], "Move before a character on the current line", function (count, arg) { let pos = editor.findCharForward(arg, count); @@ -765,7 +765,7 @@ const Editor = Module("editor", { }, { arg: true, count: true }); - mappings.add([modes.TEXTAREA, modes.VISUAL], + mappings.add([modes.TEXT_EDIT, modes.VISUAL], ["T"], "Move before a character on the current line, backwards", function (count, arg) { let pos = editor.findCharBackward(arg, count); @@ -774,8 +774,8 @@ const Editor = Module("editor", { }, { arg: true, count: true }); - // textarea and visual mode - mappings.add([modes.TEXTAREA, modes.VISUAL], + // text edit and visual mode + mappings.add([modes.TEXT_EDIT, modes.VISUAL], ["~"], "Switch case of the character under the cursor and move the cursor to the right", function (count) { if (modes.main == modes.VISUAL) @@ -794,7 +794,7 @@ const Editor = Module("editor", { text.substring(pos + 1); editor.moveToPosition(pos + 1, true, false); } - modes.pop(modes.TEXTAREA); + modes.pop(modes.TEXT_EDIT); }, { count: true }); }, diff --git a/common/content/events.js b/common/content/events.js index 05cdd7bf..c69723d8 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -633,7 +633,7 @@ const Events = Module("events", { case modes.INSERT: case modes.PASS_THROUGH: case modes.QUOTE: - case modes.TEXTAREA: + case modes.TEXT_EDIT: case modes.VISUAL: modes.pop(); break; @@ -708,7 +708,7 @@ const Events = Module("events", { if (options["insertmode"]) modes.set(modes.INSERT); else { - modes.set(modes.TEXTAREA); + modes.set(modes.TEXT_EDIT); if (elem.selectionEnd - elem.selectionStart > 0) modes.push(modes.VISUAL); } @@ -937,7 +937,7 @@ const Events = Module("events", { else { // if the key is neither a mapping nor the start of one // the mode checking is necessary so that things like g do not beep if (this._input.buffer != "" && !event.skipmap && - (mode & (modes.INSERT | modes.COMMAND_LINE | modes.TEXTAREA))) + (mode & (modes.INSERT | modes.COMMAND_LINE | modes.TEXT_EDIT))) events.feedkeys(this._input.buffer, { noremap: true, skipmap: true }); this._input.buffer = ""; @@ -947,7 +947,7 @@ const Events = Module("events", { if (!isEscape(key)) { // allow key to be passed to the host app if we can't handle it - stop = (mode == modes.TEXTAREA); + stop = (mode == modes.TEXT_EDIT); if (mode == modes.COMMAND_LINE) { if (!(modes.extended & modes.INPUT_MULTILINE)) @@ -1015,7 +1015,7 @@ const Events = Module("events", { modes.pop(); // Really not ideal. } else if (couldCopy) { - if (modes.main == modes.TEXTAREA && !options["insertmode"]) + if (modes.main == modes.TEXT_EDIT && !options["insertmode"]) modes.push(modes.VISUAL); else if (dactyl.mode == modes.CARET) modes.push(modes.VISUAL); @@ -1091,7 +1091,7 @@ const Events = Module("events", { [""], "Advance keyboard focus", function () { document.commandDispatcher.advanceFocus(); }); - mappings.add([modes.NORMAL, modes.PLAYER, modes.VISUAL, modes.CARET, modes.INSERT, modes.TEXTAREA], + mappings.add([modes.NORMAL, modes.PLAYER, modes.VISUAL, modes.CARET, modes.INSERT, modes.TEXT_EDIT], [""], "Rewind keyboard focus", function () { document.commandDispatcher.rewindFocus(); }); diff --git a/common/content/finder.js b/common/content/finder.js index d3182b7e..c92ac86d 100644 --- a/common/content/finder.js +++ b/common/content/finder.js @@ -189,14 +189,14 @@ const RangeFinder = Module("rangefinder", { ["N"], "Find previous", function () { rangefinder.findAgain(true); }); - mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["*"], + mappings.add(myModes.concat([modes.CARET, modes.TEXT_EDIT]), ["*"], "Find word under cursor", function () { rangefinder.find(buffer.getCurrentWord(), false); rangefinder.findAgain(); }); - mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["#"], + mappings.add(myModes.concat([modes.CARET, modes.TEXT_EDIT]), ["#"], "Find word under cursor backwards", function () { rangefinder.find(buffer.getCurrentWord(), true); diff --git a/common/content/modes.js b/common/content/modes.js index 53b4e8b6..32521510 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -58,7 +58,7 @@ const Modes = Module("modes", { this.pref = false; } }); - this.addMode("TEXTAREA", { char: "i", ownsFocus: true }); + this.addMode("TEXT_EDIT", { char: "t", ownsFocus: true }); this.addMode("EMBED", { input: true, ownsFocus: true }); this.addMode("PASS_THROUGH"); this.addMode("QUOTE", { diff --git a/common/locale/en-US/index.xml b/common/locale/en-US/index.xml index c533535f..965fd886 100644 --- a/common/locale/en-US/index.xml +++ b/common/locale/en-US/index.xml @@ -18,7 +18,7 @@ This file contains a list of all available commands, mappings and options.
i
Start Insert mode in text areas when insertmode is not set
Launch the external editor
-
Enter Textarea mode
+
Enter TextEdit mode
Expand an Insert-mode abbreviation
diff --git a/common/locale/en-US/insert.xml b/common/locale/en-US/insert.xml index 7a7e1d7a..3ec7d65a 100644 --- a/common/locale/en-US/insert.xml +++ b/common/locale/en-US/insert.xml @@ -20,8 +20,8 @@

- i_i - i_i + t_i + t_i

Starts Insert mode in text areas when insertmode is not set.

@@ -42,7 +42,7 @@ <C-t>

- Enter Textarea mode. This is useful for quick editing of text fields + Enter TextEdit mode. This is useful for quick editing of text fields with basic Vim-keys support. See also insertmode.

diff --git a/common/locale/en-US/map.xml b/common/locale/en-US/map.xml index a1c8a1b9..3382fbec 100644 --- a/common/locale/en-US/map.xml +++ b/common/locale/en-US/map.xml @@ -52,6 +52,7 @@
n
Normal mode: When browsing normally
v
Visual mode: When selecting text with the cursor keys
i
Insert mode: When interacting with text fields on a website
+
t
TextEdit mode: When editing text fields in Vim-like NORMAL mode
c
Command-line mode: When typing into the &dactyl.appName; command line
@@ -82,6 +83,8 @@ :vmap lhs rhs :im :imap :imap lhs rhs + :tm :tmap + :tmap lhs rhs :cm :cmap :cmap lhs rhs @@ -126,6 +129,8 @@ :vnoremap lhs rhs :ino :inoremap :inoremap lhs rhs + :tno :tnoremap + :tnoremap lhs rhs :cno :cnoremap :cnoremap lhs rhs @@ -150,6 +155,8 @@ :vunmap lhs rhs :iu :iunmap :iunmap lhs rhs + :tu :tunmap + :tunmap lhs rhs :cu :cunmap :cunmap lhs rhs @@ -166,6 +173,8 @@ :vmapclear :imapc :imapclear :imapclear + :tmapc :tmapclear + :tmapclear :cmapc :cmapclear :cmapclear @@ -180,6 +189,7 @@ :nmap :vmap :imap + :tmap :cmap

List all mappings for the applicable mode(s).

@@ -195,6 +205,8 @@ :vmap lhs :imap_l :imap lhs + :tmap_l + :tmap lhs :cmap_l :cmap lhs @@ -224,6 +236,7 @@ :nmap :nnoremap :nunmap :nmapclear – Normal mode :vmap :vnoremap :vunmap :vmapclear – Visual mode :imap :inoremap :iunmap :imapclear – Insert mode +:tmap :tnoremap :tunmap :tmapclear – TextArea mode :cmap :cnoremap :cunmap :cmapclear – Command-line mode diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml index e1f6a0f5..5cddc7c7 100644 --- a/common/locale/en-US/options.xml +++ b/common/locale/en-US/options.xml @@ -833,7 +833,7 @@

- Textarea mode can be entered with from Insert mode. + TextEdit mode can be entered with from Insert mode.

diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 14a43a59..3e8e7ffc 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -74,7 +74,7 @@ const Util = Module("Util", { if (services.get("threadManager").isMainThread) callback.call(self); else - mainThread.dispatch(Runnable(self, callback), mainThread.DISPATCH_NORMAL); + mainThread.dispatch(Runnable(self, callback, Array.slice(arguments, 2)), mainThread.DISPATCH_NORMAL); }, /**