diff --git a/NEWS b/NEWS index bd3ec241..78f77f2c 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ 2007-xx-xx: * version 0.6 * new gi browser command to focus last used input box - * edit TEXTAREAs with many vim commands in a vim and even visual mode + * edit TEXTAREAs with many vim commands in a vim and even visual mode if you :set noinsertmode * support for emacs/bash-like ctrl-e/a/u/k/h keys in single line text fields * support for * and # mappings to search for the text selection or the text under the cursor * Escape finally clears any selection made in the document diff --git a/chrome/content/vimperator/events.js b/chrome/content/vimperator/events.js index 0d9e67dc..b2aab836 100644 --- a/chrome/content/vimperator/events.js +++ b/chrome/content/vimperator/events.js @@ -388,7 +388,9 @@ function Events() //{{{ } else if (elem && elem instanceof HTMLTextAreaElement) { - if (elem.selectionEnd - elem.selectionStart > 0) + if (vimperator.options["insertmode"]) + vimperator.setMode(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); + else if (elem.selectionEnd - elem.selectionStart > 0) vimperator.setMode(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA); else vimperator.editor.startNormal(); @@ -408,24 +410,17 @@ function Events() //{{{ if (controller && controller.isCommandEnabled("cmd_copy")) could_copy = true; - var extended = vimperator.modes.NONE; - if (vimperator.hasMode(vimperator.modes.TEXTAREA)) - extended = vimperator.modes.TEXTAREA; - else if (vimperator.hasMode(vimperator.modes.CARET)) - extended = vimperator.modes.CARET; - - if (could_copy && !vimperator.hasMode(vimperator.modes.VISUAL) && - (vimperator.hasMode(vimperator.modes.NORMAL) || - vimperator.hasMode(vimperator.modes.TEXTAREA) || - vimperator.hasMode(vimperator.modes.CARET))) + if (could_copy && !vimperator.hasMode(vimperator.modes.VISUAL)) { - vimperator.setMode(vimperator.modes.VISUAL, extended); + if (vimperator.hasMode(vimperator.modes.TEXTAREA) && !vimperator.options["insertmode"]) + vimperator.setMode(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA); + else if (vimperator.hasMode(vimperator.modes.CARET)) + vimperator.setMode(vimperator.modes.VISUAL, vimperator.modes.CARET); } else if (vimperator.hasMode(vimperator.modes.VISUAL)) { - if (!could_copy && !vimperator.hasMode(vimperator.modes.CARET) && - !vimperator.hasMode(vimperator.modes.TEXTAREA)) - vimperator.setMode(extended || vimperator.modes.NORMAL); + if (!could_copy && vimperator.hasMode(vimperator.modes.CARET)) + vimperator.setMode(vimperator.modes.CARET); } } @@ -461,7 +456,7 @@ function Events() //{{{ } else if (vimperator.hasMode(vimperator.modes.INSERT)) { - if(vimperator.hasMode(vimperator.modes.TEXTAREA)) + if(vimperator.hasMode(vimperator.modes.TEXTAREA) && !vimperator.options["insertmode"]) vimperator.setMode(vimperator.modes.TEXTAREA); else { diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js index 55b00d35..aa166c3b 100644 --- a/chrome/content/vimperator/mappings.js +++ b/chrome/content/vimperator/mappings.js @@ -1832,7 +1832,13 @@ function Mappings() //{{{ { } )); addDefaultMap(new Map([vimperator.modes.INSERT, vimperator.modes.COMMAND_LINE], [""], - function() { vimperator.editor.executeCommand("cmd_deleteToBeginningOfLine", 1); }, + function() + { + // broken in FF3, deletes the wohle line: + // vimperator.editor.executeCommand("cmd_deleteToBeginningOfLine", 1); + vimperator.editor.executeCommand("cmd_selectBeginLine", 1); + vimperator.editor.executeCommand("cmd_delete", 1); + }, { } )); addDefaultMap(new Map([vimperator.modes.INSERT, vimperator.modes.COMMAND_LINE], [""], diff --git a/chrome/content/vimperator/options.js b/chrome/content/vimperator/options.js index 1a39caf9..398bd0e7 100644 --- a/chrome/content/vimperator/options.js +++ b/chrome/content/vimperator/options.js @@ -452,6 +452,14 @@ function Options() //{{{ default_value: true } )); + addOption(new Option(["insertmode", "im"], "boolean", + { + short_help: "Use Insert mode as the default for text areas", + help: "Makes Vimperator work in a way that Insert mode is the default mode for text areas. " + + "Useful if you want to use Vimperator as a modeless editor, keeping the known Firefox interface for editing text areas.", + default_value: true + } + )); addOption(new Option(["maxhints", "mh"], "number", { short_help: "Maximum number of simultaneously shown hints", diff --git a/vimperator.vim b/vimperator.vim index 79794c43..766c26f8 100644 --- a/vimperator.vim +++ b/vimperator.vim @@ -31,9 +31,9 @@ syn match vimperatorCommandWrapper "\<\h\w*\>" contains=vimperatorCommand syn region vimperatorSet matchgroup=vimperatorCommand start="\" end="$" keepend oneline contains=vimperatorOption syn keyword vimperatorOption activate act complete cpt defsearch ds extendedhinttags eht focusedhintstyle fhs fullscreen fs \ nofullscreen nofs guioptions go hintchars hc hintstyle hs hinttags incsearch is noincsearch nois ignorecase ic - \ noignorecase noic maxhints mh popups pps preload nopreload previewheight pvh showmode smd noshowmode nosmd showstatuslinks ssli - \ showtabline stal smartcase scs nosmartcase noscs titlestring usermode um nousermode noum verbose vbs visualbell vb - \ wildmode wim wildoptions wop + \ noignorecase noic insertmode im noinsertmode noim maxhints mh popups pps preload nopreload previewheight pvh showmode smd + \ noshowmode nosmd showstatuslinks ssli \ showtabline stal smartcase scs nosmartcase noscs titlestring usermode um nousermode noum + \ verbose vbs visualbell vb wildmode wim wildoptions wop \ contained syn region vimperatorJavascript start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=" end="$" contains=@javascriptTop keepend oneline