1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 14:08:11 +01:00

- new 'insertmode' option

- fixed c-u behavior
This commit is contained in:
Martin Stubenschrott
2007-09-12 13:41:15 +00:00
parent 9a7ecb0f5c
commit e4f8b78f07
5 changed files with 30 additions and 21 deletions

2
NEWS
View File

@@ -2,7 +2,7 @@
2007-xx-xx: 2007-xx-xx:
* version 0.6 * version 0.6
* new gi browser command to focus last used input box * 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 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 * 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 * Escape finally clears any selection made in the document

View File

@@ -388,7 +388,9 @@ function Events() //{{{
} }
else if (elem && elem instanceof HTMLTextAreaElement) 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); vimperator.setMode(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA);
else else
vimperator.editor.startNormal(); vimperator.editor.startNormal();
@@ -408,24 +410,17 @@ function Events() //{{{
if (controller && controller.isCommandEnabled("cmd_copy")) if (controller && controller.isCommandEnabled("cmd_copy"))
could_copy = true; could_copy = true;
var extended = vimperator.modes.NONE; if (could_copy && !vimperator.hasMode(vimperator.modes.VISUAL))
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)))
{ {
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)) else if (vimperator.hasMode(vimperator.modes.VISUAL))
{ {
if (!could_copy && !vimperator.hasMode(vimperator.modes.CARET) && if (!could_copy && vimperator.hasMode(vimperator.modes.CARET))
!vimperator.hasMode(vimperator.modes.TEXTAREA)) vimperator.setMode(vimperator.modes.CARET);
vimperator.setMode(extended || vimperator.modes.NORMAL);
} }
} }
@@ -461,7 +456,7 @@ function Events() //{{{
} }
else if (vimperator.hasMode(vimperator.modes.INSERT)) 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); vimperator.setMode(vimperator.modes.TEXTAREA);
else else
{ {

View File

@@ -1832,7 +1832,13 @@ function Mappings() //{{{
{ } { }
)); ));
addDefaultMap(new Map([vimperator.modes.INSERT, vimperator.modes.COMMAND_LINE], ["<C-u>"], addDefaultMap(new Map([vimperator.modes.INSERT, vimperator.modes.COMMAND_LINE], ["<C-u>"],
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], ["<C-k>"], addDefaultMap(new Map([vimperator.modes.INSERT, vimperator.modes.COMMAND_LINE], ["<C-k>"],

View File

@@ -452,6 +452,14 @@ function Options() //{{{
default_value: true 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", addOption(new Option(["maxhints", "mh"], "number",
{ {
short_help: "Maximum number of simultaneously shown hints", short_help: "Maximum number of simultaneously shown hints",

View File

@@ -31,9 +31,9 @@ syn match vimperatorCommandWrapper "\<\h\w*\>" contains=vimperatorCommand
syn region vimperatorSet matchgroup=vimperatorCommand start="\<set\=\>" end="$" keepend oneline contains=vimperatorOption syn region vimperatorSet matchgroup=vimperatorCommand start="\<set\=\>" end="$" keepend oneline contains=vimperatorOption
syn keyword vimperatorOption activate act complete cpt defsearch ds extendedhinttags eht focusedhintstyle fhs fullscreen fs 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 \ 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 \ noignorecase noic insertmode im noinsertmode noim maxhints mh popups pps preload nopreload previewheight pvh showmode smd
\ showtabline stal smartcase scs nosmartcase noscs titlestring usermode um nousermode noum verbose vbs visualbell vb \ noshowmode nosmd showstatuslinks ssli \ showtabline stal smartcase scs nosmartcase noscs titlestring usermode um nousermode noum
\ wildmode wim wildoptions wop \ verbose vbs visualbell vb wildmode wim wildoptions wop
\ contained \ contained
syn region vimperatorJavascript start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=" end="$" contains=@javascriptTop keepend oneline syn region vimperatorJavascript start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=" end="$" contains=@javascriptTop keepend oneline