1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-02 09:59:07 +02:00

Completed suppor for Ctrl-k and Ctrl-v for r,t,f,T,f and insert/replace modes.

This commit is contained in:
rmaddy 2004-05-26 22:34:56 +00:00
parent d98a0b818f
commit fe05156454
15 changed files with 3244 additions and 306 deletions

View File

@ -35,7 +35,7 @@
<property name="project" value="IdeaVIM" />
<!-- Update this prior to building a new distribution -->
<property name="idea-version" value="4.x" />
<property name="version" value="0.7.2" />
<property name="version" value="0.7.3" />
<path id="build.classpath">
<pathelement path="${idea.home}/lib/idea.jar" />
@ -58,6 +58,7 @@
<mkdir dir="${classes}"/>
<javac destdir="${classes}" debug="on" classpathref="build.classpath" >
<src path="${src}"/>
<include name="com/maddyhome/idea/**" />
</javac>
<mkdir dir="${classes}/META-INF"/>
<copy file="plugin.xml" todir="${classes}/META-INF">

View File

@ -3,11 +3,15 @@ History of changes for @NAME@ for IDEA @IDEA-VERSION@
@VERSION@ from 0.7.1
New Features
- Added support for digraphs. Currently you can use Ctrl-K {char1}{char2} to
- Added support for digraphs. Currently you can use Ctrl-k {char1}{char2} to
enter a special character. This works while in Insert/Replace mode, or as an
argument to the r, F, T, f, and t commands. The :digraphs command has been
added to display the currently supported digraphs. Certain special cases of
the Ctrl-K {char1}{char2} sequence are not supported.
the Ctrl-K {char1}{char2} sequence are not supported. This supports all two
character digraphs as listed in RFC1345. This amounts to 1,338 digraphs!
Ensure the file encoding can handle the characters you enter.
- Added support for Ctrl-v {digits}. This works while in Insert/Replace mode, or
as an argument to the r, F, T, f, and t commands.
0.7.2 from 0.7.1

View File

@ -13,12 +13,12 @@ First Time Installation
UNIX/Linux
Copy vim.xml from the plugin to $HOME/.IntelliJIdea/config/keymaps. You will
Copy Vim.xml from the plugin to $HOME/.IntelliJIdea/config/keymaps. You will
have to create the keymaps directory if it doesn't exist.
Windows
Copy vim.xml from the plugin to
Copy Vim.xml from the plugin to
C:\Documents and Settings\<user>\.IntelliJIdea\config\keymaps.
You will have to create the keymaps directory if it doesn't exist.

View File

@ -6,8 +6,7 @@ Bugs to fix:
Requested Functionality to add:
- Full RFC1345 support
- Ctrl-V code support
- Support Ctrl-k and Ctrl-v in ex mode
- Highlight all searches (:set hls, :set nohls, :nohls)
- More fold region support
- Window support (need access to splitter)

1343
docs/vim/digraphs.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -62,6 +62,8 @@ tag char action ~
line
|i_CTRL-U| CTRL-U delete all entered characters in the current
line
|i_CTRL-V_digit| CTRL-V {number} insert three digit decimal number as a single
byte.
|i_CTRL-W| CTRL-W delete word before the cursor
|i_CTRL-Y| CTRL-Y insert the character which is above the cursor
|i_<Esc>| <Esc> end insert mode
@ -111,8 +113,6 @@ and don't auto-indent
insert the contents of a register literally
and fix indent.
|i_CTRL-V| CTRL-V {char} insert next non-digit literally
|i_CTRL-V_digit| CTRL-V {number} insert three digit decimal number as a single
byte.
|i_^_CTRL-D| ^ CTRL-D delete all indent in the current line, restore
it in the next line

173
install/Vim.xml Normal file
View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<keymap version="1" name="Vim" disable-mnemonics="false" parent="$default">
<action id="$Copy">
<keyboard-shortcut first-keystroke="control INSERT" />
</action>
<action id="$Cut">
<keyboard-shortcut first-keystroke="shift DELETE" />
</action>
<action id="$Paste">
<keyboard-shortcut first-keystroke="shift INSERT" />
</action>
<action id="$Redo">
<keyboard-shortcut first-keystroke="shift alt BACK_SPACE" />
</action>
<action id="$SelectAll" />
<action id="$Undo">
<keyboard-shortcut first-keystroke="alt BACK_SPACE" />
</action>
<action id="CheckinProject" />
<action id="ClassNameCompletion" />
<action id="ClearCase.CheckInProject" />
<action id="CodeCompletion" />
<action id="CommanderSwapPanels" />
<action id="ContextHelp" />
<action id="EditorBackSpace">
<keyboard-shortcut first-keystroke="BACK_SPACE" />
</action>
<action id="EditorCodeBlockEnd" />
<action id="EditorCodeBlockStart" />
<action id="EditorCopy">
<keyboard-shortcut first-keystroke="control INSERT" />
</action>
<action id="EditorCut">
<keyboard-shortcut first-keystroke="shift DELETE" />
</action>
<action id="EditorDeleteLine" />
<action id="EditorDeleteToWordEnd" />
<action id="EditorDeleteToWordStart" />
<action id="EditorDownWithSelection" />
<action id="EditorDuplicate" />
<action id="EditorIndentSelection" />
<action id="EditorJoinLines" />
<action id="EditorLeftWithSelection" />
<action id="EditorLineEndWithSelection" />
<action id="EditorLineStartWithSelection" />
<action id="EditorMoveToPageBottom" />
<action id="EditorMoveToPageBottomWithSelection" />
<action id="EditorMoveToPageTop" />
<action id="EditorMoveToPageTopWithSelection" />
<action id="EditorNextWord" />
<action id="EditorNextWordWithSelection" />
<action id="EditorPageDownWithSelection" />
<action id="EditorPageUpWithSelection" />
<action id="EditorPaste">
<keyboard-shortcut first-keystroke="shift INSERT" />
</action>
<action id="EditorPreviousWord" />
<action id="EditorPreviousWordWithSelection" />
<action id="EditorRedo" />
<action id="EditorRightWithSelection" />
<action id="EditorScrollDown" />
<action id="EditorScrollToCenter" />
<action id="EditorScrollUp" />
<action id="EditorSelectAll" />
<action id="EditorSelectWord" />
<action id="EditorSplitLine" />
<action id="EditorStartNewLine" />
<action id="EditorTextEnd" />
<action id="EditorTextEndWithSelection" />
<action id="EditorTextStart" />
<action id="EditorTextStartWithSelection" />
<action id="EditorToggleCase" />
<action id="EditorUnSelectWord" />
<action id="EditorUndo" />
<action id="EditorUnindentSelection" />
<action id="EditorUpWithSelection" />
<action id="Find" />
<action id="FindNext">
<keyboard-shortcut first-keystroke="F3" />
</action>
<action id="FindPrevious">
<keyboard-shortcut first-keystroke="shift F3" />
</action>
<action id="GotoBookmark2" />
<action id="GotoClass">
<keyboard-shortcut first-keystroke="shift alt N" />
</action>
<action id="GotoDeclaration">
<mouse-shortcut keystroke="control button1" />
<mouse-shortcut keystroke="button2" />
</action>
<action id="GotoLine" />
<action id="GotoSuperMethod">
<keyboard-shortcut first-keystroke="shift control U" />
</action>
<action id="ImplementMethods">
<keyboard-shortcut first-keystroke="shift control I" />
</action>
<action id="InsertLiveTemplate" />
<action id="MethodHierarchy.ImplementMethodAction" />
<action id="MethodHierarchy.OverrideMethodAction" />
<action id="OverrideMethods">
<keyboard-shortcut first-keystroke="shift control O" />
</action>
<action id="ParameterInfo">
<keyboard-shortcut first-keystroke="shift control P" />
</action>
<action id="QuickJavaDoc">
<mouse-shortcut keystroke="alt button2" />
</action>
<action id="RecentFiles" />
<action id="Replace" />
<action id="SaveAll" />
<action id="SmartTypeCompletion" />
<action id="Starteam.CheckinProject" />
<action id="Subversion.CommitProject" />
<action id="ToggleBookmark2" />
<action id="TypeHierarchy">
<keyboard-shortcut first-keystroke="shift control alt H" />
</action>
<action id="VimKeyHandler">
<keyboard-shortcut first-keystroke="control 2" />
<keyboard-shortcut first-keystroke="control A" />
<keyboard-shortcut first-keystroke="control alt SPACE" />
<keyboard-shortcut first-keystroke="control B" />
<keyboard-shortcut first-keystroke="control BACK_SLASH" />
<keyboard-shortcut first-keystroke="control C" />
<keyboard-shortcut first-keystroke="control CLOSE_BRACKET" />
<keyboard-shortcut first-keystroke="control D" />
<keyboard-shortcut first-keystroke="control E" />
<keyboard-shortcut first-keystroke="control END" />
<keyboard-shortcut first-keystroke="control F" />
<keyboard-shortcut first-keystroke="control G" />
<keyboard-shortcut first-keystroke="control H" />
<keyboard-shortcut first-keystroke="control HOME" />
<keyboard-shortcut first-keystroke="control I" />
<keyboard-shortcut first-keystroke="control J" />
<keyboard-shortcut first-keystroke="control K" />
<keyboard-shortcut first-keystroke="control L" />
<keyboard-shortcut first-keystroke="control LEFT" />
<keyboard-shortcut first-keystroke="control M" />
<keyboard-shortcut first-keystroke="control N" />
<keyboard-shortcut first-keystroke="control O" />
<keyboard-shortcut first-keystroke="control OPEN_BRACKET" />
<keyboard-shortcut first-keystroke="control P" />
<keyboard-shortcut first-keystroke="control PAGE_DOWN" />
<keyboard-shortcut first-keystroke="control PAGE_UP" />
<keyboard-shortcut first-keystroke="control Q" />
<keyboard-shortcut first-keystroke="control R" />
<keyboard-shortcut first-keystroke="control RIGHT" />
<keyboard-shortcut first-keystroke="control S" />
<keyboard-shortcut first-keystroke="control SPACE" />
<keyboard-shortcut first-keystroke="control T" />
<keyboard-shortcut first-keystroke="control U" />
<keyboard-shortcut first-keystroke="control V" />
<keyboard-shortcut first-keystroke="control W" />
<keyboard-shortcut first-keystroke="control X" />
<keyboard-shortcut first-keystroke="control Y" />
<keyboard-shortcut first-keystroke="control Z" />
<keyboard-shortcut first-keystroke="KP_DOWN" />
<keyboard-shortcut first-keystroke="KP_LEFT" />
<keyboard-shortcut first-keystroke="KP_RIGHT" />
<keyboard-shortcut first-keystroke="KP_UP" />
<keyboard-shortcut first-keystroke="shift control 2" />
<keyboard-shortcut first-keystroke="shift control SPACE" />
<keyboard-shortcut first-keystroke="shift DOWN" />
<keyboard-shortcut first-keystroke="shift LEFT" />
<keyboard-shortcut first-keystroke="shift RIGHT" />
<keyboard-shortcut first-keystroke="shift UP" />
<keyboard-shortcut first-keystroke="F1" />
</action>
</keymap>

View File

@ -1,170 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<keymap version="1" name="vim" disable-mnemonics="false" parent="$default">
<action id="$Copy">
<keyboard-shortcut id="$Copy" first-keystroke="control INSERT" />
</action>
<action id="$Cut">
<keyboard-shortcut id="$Cut" first-keystroke="shift DELETE" />
</action>
<action id="$Paste">
<keyboard-shortcut id="$Paste" first-keystroke="shift INSERT" />
</action>
<action id="$Redo">
<keyboard-shortcut id="$Redo" first-keystroke="shift alt BACK_SPACE" />
</action>
<action id="$SelectAll" />
<action id="$Undo">
<keyboard-shortcut id="$Undo" first-keystroke="alt BACK_SPACE" />
</action>
<action id="ClassNameCompletion" />
<action id="CodeCompletion" />
<action id="CommanderSwapPanels" />
<action id="ContextHelp" />
<action id="EditorBackSpace">
<keyboard-shortcut id="EditorBackSpace" first-keystroke="BACK_SPACE" />
</action>
<action id="EditorCodeBlockEnd" />
<action id="EditorCodeBlockStart" />
<action id="EditorCopy">
<keyboard-shortcut id="EditorCopy" first-keystroke="control INSERT" />
</action>
<action id="EditorCut">
<keyboard-shortcut id="EditorCut" first-keystroke="shift DELETE" />
</action>
<action id="EditorDeleteLine" />
<action id="EditorDeleteToWordEnd" />
<action id="EditorDeleteToWordStart" />
<action id="EditorDownWithSelection" />
<action id="EditorDuplicate" />
<action id="EditorIndentSelection" />
<action id="EditorJoinLines" />
<action id="EditorLeftWithSelection" />
<action id="EditorLineEndWithSelection" />
<action id="EditorLineStartWithSelection" />
<action id="EditorMoveToPageBottom" />
<action id="EditorMoveToPageBottomWithSelection" />
<action id="EditorMoveToPageTop" />
<action id="EditorMoveToPageTopWithSelection" />
<action id="EditorNextWord" />
<action id="EditorNextWordWithSelection" />
<action id="EditorPageDownWithSelection" />
<action id="EditorPageUpWithSelection" />
<action id="EditorPaste">
<keyboard-shortcut id="EditorPaste" first-keystroke="shift INSERT" />
</action>
<action id="EditorPreviousWord" />
<action id="EditorPreviousWordWithSelection" />
<action id="EditorRedo" />
<action id="EditorRightWithSelection" />
<action id="EditorScrollDown" />
<action id="EditorScrollToCenter" />
<action id="EditorScrollUp" />
<action id="EditorSelectAll" />
<action id="EditorSelectWord" />
<action id="EditorSplitLine" />
<action id="EditorStartNewLine" />
<action id="EditorTextEnd" />
<action id="EditorTextEndWithSelection" />
<action id="EditorTextStart" />
<action id="EditorTextStartWithSelection" />
<action id="EditorToggleCase" />
<action id="EditorUnSelectWord" />
<action id="EditorUndo" />
<action id="EditorUnindentSelection" />
<action id="EditorUpWithSelection" />
<action id="Find" />
<action id="FindNext">
<keyboard-shortcut id="FindNext" first-keystroke="F3" />
</action>
<action id="FindPrevious">
<keyboard-shortcut id="FindPrevious" first-keystroke="shift F3" />
</action>
<action id="GotoBookmark2" />
<action id="GotoClass">
<keyboard-shortcut id="GotoClass" first-keystroke="shift alt N" />
</action>
<action id="GotoDeclaration">
<mouse-shortcut id="GotoDeclaration" keystroke="control button1" />
<mouse-shortcut id="GotoDeclaration" keystroke="button2" />
</action>
<action id="GotoLine" />
<action id="GotoSuperMethod">
<keyboard-shortcut id="GotoSuperMethod" first-keystroke="shift control U" />
</action>
<action id="ImplementMethods">
<keyboard-shortcut id="ImplementMethods" first-keystroke="shift control I" />
</action>
<action id="InsertLiveTemplate" />
<action id="MethodHierarchy.ImplementMethodAction" />
<action id="MethodHierarchy.OverrideMethodAction" />
<action id="OverrideMethods">
<keyboard-shortcut id="OverrideMethods" first-keystroke="shift control O" />
</action>
<action id="ParameterInfo">
<keyboard-shortcut id="ParameterInfo" first-keystroke="shift control P" />
</action>
<action id="QuickJavaDoc">
<mouse-shortcut id="QuickJavaDoc" keystroke="alt button2" />
</action>
<action id="RecentFiles" />
<action id="Replace" />
<action id="SaveAll" />
<action id="SmartTypeCompletion" />
<action id="Starteam.CheckinProject" />
<action id="ToggleBookmark2" />
<action id="TypeHierarchy">
<keyboard-shortcut id="TypeHierarchy" first-keystroke="shift control alt H" />
</action>
<action id="VimKeyHandler">
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control 2" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control A" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control alt SPACE" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control B" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control BACK_SLASH" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control C" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control CLOSE_BRACKET" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control D" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control E" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control END" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control F" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control G" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control H" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control HOME" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control I" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control J" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control K" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control L" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control LEFT" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control M" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control N" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control O" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control OPEN_BRACKET" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control P" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control PAGE_DOWN" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control PAGE_UP" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control Q" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control R" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control RIGHT" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control S" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control SPACE" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control T" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control U" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control V" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control W" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control X" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control Y" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="control Z" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="F1" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="KP_DOWN" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="KP_LEFT" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="KP_RIGHT" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="KP_UP" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="shift control 2" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="shift control SPACE" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="shift DOWN" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="shift LEFT" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="shift RIGHT" />
<keyboard-shortcut id="VimKeyHandler" first-keystroke="shift UP" />
</action>
</keymap>

View File

@ -34,6 +34,7 @@ import com.maddyhome.idea.vim.command.CommandState;
import com.maddyhome.idea.vim.group.CommandGroups;
import com.maddyhome.idea.vim.group.RegisterGroup;
import com.maddyhome.idea.vim.helper.RunnableHelper;
import com.maddyhome.idea.vim.helper.DigraphSequence;
import com.maddyhome.idea.vim.key.ArgumentNode;
import com.maddyhome.idea.vim.key.BranchNode;
import com.maddyhome.idea.vim.key.CommandNode;
@ -169,65 +170,26 @@ public class KeyHandler
mode = STATE_ERROR;
}
}
/*
else if (currentArg == Argument.DIGRAPH)
{
logger.debug("currentArg == DIGRAPH(" + digraphState + ")");
switch (digraphState)
//logger.debug("currentArg == DIGRAPH(" + digraphState + ")");
int res = digraph.processKey(key, editor, context);
switch (res)
{
case 0:
// We should have a Ctrl-K if this is a true digraph or a regular character
if (key.getKeyCode() == KeyEvent.VK_K && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0)
{
// we have a Ctrl-K - start of a digraph
digraphState = 1;
logger.debug("we have Ctrl-K");
}
else
{
// We have a regular character
currentArg = Argument.CHARACTER;
handleKey(editor, key, context);
}
case DigraphSequence.RES_OK:
break;
case 1:
logger.debug("first key: " + chKey);
if (chKey != 0)
{
Argument arg = new Argument(chKey);
Command cmd = (Command)currentCmd.peek();
cmd.setArgument(arg);
digraphState = 2;
}
else
{
Argument arg = new Argument((char)11);
Command cmd = (Command)currentCmd.peek();
cmd.setArgument(arg);
mode = STATE_READY;
}
case DigraphSequence.RES_BAD:
mode = STATE_READY;
digraph = null;
break;
case 2:
logger.debug("second key: " + chKey);
if (chKey != 0)
{
char char1 = ((Command)currentCmd.peek()).getArgument().getCharacter();
char digraph = CommandGroups.getInstance().getDigraph().getDigraph(char1, chKey);
Argument arg = new Argument(digraph);
Command cmd = (Command)currentCmd.peek();
cmd.setArgument(arg);
mode = STATE_READY;
}
else
{
Argument arg = new Argument((char)11);
Command cmd = (Command)currentCmd.peek();
cmd.setArgument(arg);
mode = STATE_READY;
}
case DigraphSequence.RES_DONE:
currentArg = Argument.CHARACTER;
digraph = null;
break;
}
}
*/
// If we are this far - sheesh, then the user must be entering a command or a non-single-character argument
// to an entered command. Let's figure out which it is
else
@ -236,6 +198,32 @@ public class KeyHandler
keys.add(key);
logger.debug("keys now " + keys);
if (digraph == null && DigraphSequence.isDigraphStart(key))
{
digraph = new DigraphSequence();
}
if (digraph != null)
{
int res = digraph.processKey(key, editor, context);
switch (res)
{
case DigraphSequence.RES_OK:
break;
case DigraphSequence.RES_BAD:
digraph = null;
break;
case DigraphSequence.RES_DONE:
if (currentArg == Argument.DIGRAPH)
{
currentArg = Argument.CHARACTER;
}
digraph = null;
break;
}
return;
}
// Ask the key/action tree if this is an appropriate key at this point in the command and if so,
// return the node matching this keystroke
Node node = currentNode.getChild(key);
@ -314,7 +302,8 @@ public class KeyHandler
switch (arg.getArgType())
{
case Argument.DIGRAPH:
digraphState = 0;
//digraphState = 0;
digraph = new DigraphSequence();
// No break - fall through
case Argument.CHARACTER:
case Argument.MOTION:
@ -352,7 +341,27 @@ public class KeyHandler
if (CommandState.getInstance().getMode() == CommandState.MODE_INSERT ||
CommandState.getInstance().getMode() == CommandState.MODE_REPLACE)
{
if (!CommandGroups.getInstance().getChange().processKey(editor, context, key))
/*
if (digraph == null && DigraphSequence.isDigraphStart(key))
{
digraph = new DigraphSequence();
}
if (digraph != null)
{
int res = digraph.processKey(key, editor, context);
switch (res)
{
case DigraphSequence.RES_OK:
break;
case DigraphSequence.RES_BAD:
digraph = null;
break;
case DigraphSequence.RES_DONE:
digraph = null;
break;
}
}
else */ if (!CommandGroups.getInstance().getChange().processKey(editor, context, key))
{
shouldRecord = false;
}
@ -500,7 +509,8 @@ public class KeyHandler
mode = STATE_NEW_COMMAND;
currentCmd.clear();
currentArg = Argument.NONE;
digraphState = 0;
//digraphState = 0;
digraph = null;
logger.debug("reset");
}
@ -579,7 +589,8 @@ public class KeyHandler
private Stack currentCmd = new Stack();
private int currentArg;
private TypedActionHandler origHandler;
private int digraphState;
//private int digraphState;
private DigraphSequence digraph = null;
private static KeyHandler instance;

View File

@ -535,41 +535,6 @@ public class ChangeGroup extends AbstractActionGroup
{
logger.debug("processKey(" + key + ")");
switch (digraphState)
{
case 0:
if (key.getKeyCode() == KeyEvent.VK_K && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0)
{
digraphState = 1;
return true;
}
break;
case 1:
if (key.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
{
digraphChar = key.getKeyChar();
digraphState = 2;
return true;
}
else
{
digraphState = 0;
return false;
}
case 2:
if (key.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
{
char ch = CommandGroups.getInstance().getDigraph().getDigraph(digraphChar, key.getKeyChar());
if (ch != key.getKeyChar())
{
key = KeyStroke.getKeyStroke(ch);
}
}
digraphState = 0;
break;
}
if (key.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
{
// Regular characters are not handled by us, pass them back to Idea. We just keep track of the keystroke
@ -1469,8 +1434,6 @@ public class ChangeGroup extends AbstractActionGroup
private int insertStart;
private Command lastInsert;
private boolean inInsert;
private int digraphState = 0;
private char digraphChar;
private static Logger logger = Logger.getInstance(ChangeGroup.class.getName());
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ package com.maddyhome.idea.vim.group;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003 Rick Maddy
* Copyright (C) 2003-2004 Rick Maddy
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -20,7 +20,10 @@ package com.maddyhome.idea.vim.group;
*/
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.project.Project;
import com.maddyhome.idea.vim.KeyHandler;
import com.maddyhome.idea.vim.common.Register;
import java.util.List;
@ -87,7 +90,7 @@ public class MacroGroup extends AbstractActionGroup
* @param keys The list of keys to playback
* @param pos The position within the list for the specific key to queue
*/
private void playbackKeys(final Editor editor, final DataContext context, final List keys, final int pos)
public void playbackKeys(final Editor editor, final DataContext context, final List keys, final int pos)
{
if (pos >= keys.size())
{
@ -103,7 +106,7 @@ public class MacroGroup extends AbstractActionGroup
// the keys one at a time. With the old loop approach, all the keys got queued, then any events they caused
// were queued - after the keys. This is what caused the problem.
final KeyStroke stroke = (KeyStroke)keys.get(pos);
Runnable run = new Runnable() {
final Runnable run = new Runnable() {
public void run()
{
// Handle one keystroke then queue up the next key
@ -115,7 +118,12 @@ public class MacroGroup extends AbstractActionGroup
}
};
SwingUtilities.invokeLater(run);
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
CommandProcessor.getInstance().executeCommand((Project)context.getData(DataConstants.PROJECT), run, "foo", "bar");
}
});
}
private char lastRegister = 0;

View File

@ -0,0 +1,261 @@
package com.maddyhome.idea.vim.helper;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2004 Rick Maddy
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import com.maddyhome.idea.vim.group.CommandGroups;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.actionSystem.DataContext;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import javax.swing.KeyStroke;
public class DigraphSequence
{
public static final int RES_OK = 0;
public static final int RES_BAD = 1;
public static final int RES_DONE = 2;
public DigraphSequence()
{
}
public static boolean isDigraphStart(KeyStroke key)
{
if ((key.getModifiers() & KeyEvent.CTRL_MASK) != 0)
{
if (key.getKeyCode() == KeyEvent.VK_K || key.getKeyCode() == KeyEvent.VK_V)
{
return true;
}
}
return false;
}
public int processKey(KeyStroke key, Editor editor, DataContext context)
{
switch (digraphState)
{
case DIG_STATE_START:
logger.debug("DIG_STATE_START");
if (key.getKeyCode() == KeyEvent.VK_K && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0)
{
logger.debug("found Ctrl-K");
digraphState = DIG_STATE_DIG_ONE;
return RES_OK;
}
else if (key.getKeyCode() == KeyEvent.VK_V && (key.getModifiers() & KeyEvent.CTRL_MASK) != 0)
{
logger.debug("found Ctrl-V");
digraphState = DIG_STATE_CODE_START;
codeChars = new char[8];
codeCnt = 0;
return RES_OK;
}
else
{
postKey(key, editor, context);
return RES_DONE;
}
case DIG_STATE_DIG_ONE:
logger.debug("DIG_STATE_DIG_ONE");
if (key.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
{
digraphChar = key.getKeyChar();
digraphState = DIG_STATE_DIG_TWO;
return RES_OK;
}
else
{
digraphState = DIG_STATE_START;
return RES_BAD;
}
case DIG_STATE_DIG_TWO:
logger.debug("DIG_STATE_DIG_TWO");
digraphState = DIG_STATE_START;
if (key.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
{
char ch = CommandGroups.getInstance().getDigraph().getDigraph(digraphChar, key.getKeyChar());
postKey(KeyStroke.getKeyStroke(ch), editor, context);
return RES_DONE;
}
return RES_BAD;
case DIG_STATE_CODE_START:
logger.debug("DIG_STATE_CODE_START");
switch (key.getKeyChar())
{
case 'o':
case 'O':
codeMax = 3;
digraphState = DIG_STATE_CODE_CHAR;
codeType = 8;
logger.debug("Octal");
return RES_OK;
case 'x':
case 'X':
codeMax = 2;
digraphState = DIG_STATE_CODE_CHAR;
codeType = 16;
logger.debug("hex2");
return RES_OK;
case 'u':
codeMax = 4;
digraphState = DIG_STATE_CODE_CHAR;
codeType = 16;
logger.debug("hex4");
return RES_OK;
case 'U':
codeMax = 8;
digraphState = DIG_STATE_CODE_CHAR;
codeType = 16;
logger.debug("hex8");
return RES_OK;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
codeMax = 3;
digraphState = DIG_STATE_CODE_CHAR;
codeType = 10;
codeChars[codeCnt++] = key.getKeyChar();
logger.debug("decimal");
return RES_OK;
default:
logger.debug("unknown");
digraphState = DIG_STATE_START;
postKey(key, editor, context);
return RES_DONE;
}
case DIG_STATE_CODE_CHAR:
logger.debug("DIG_STATE_CODE_CHAR");
boolean valid = false;
switch (codeType)
{
case 10:
if (key.getKeyChar() >= '0' && key.getKeyChar() <= '9')
{
valid = true;
}
break;
case 8:
if (key.getKeyChar() >= '0' && key.getKeyChar() <= '7')
{
valid = true;
}
break;
case 16:
if (key.getKeyChar() >= '0' && key.getKeyChar() <= '9' ||
key.getKeyChar() >= 'a' && key.getKeyChar() <= 'f' ||
key.getKeyChar() >= 'A' && key.getKeyChar() <= 'F')
{
valid = true;
}
break;
}
if (valid)
{
logger.debug("valid");
codeChars[codeCnt++] = key.getKeyChar();
if (codeCnt == codeMax)
{
String digits = new String(codeChars, 0, codeCnt);
int val = Integer.parseInt(digits, codeType);
KeyStroke code = KeyStroke.getKeyStroke((char)val);
digraphState = DIG_STATE_START;
postKey(code, editor, context);
return RES_DONE;
}
else
{
return RES_OK;
}
}
else if (codeCnt > 0)
{
logger.debug("invalid");
String digits = new String(codeChars, 0, codeCnt);
int val = Integer.parseInt(digits, codeType);
digraphState = DIG_STATE_START;
KeyStroke code = KeyStroke.getKeyStroke((char)val);
postKeys(code, key, editor, context);
return RES_DONE;
}
else
{
return RES_BAD;
}
default:
return RES_BAD;
}
}
private void postKey(KeyStroke key, Editor editor, DataContext context)
{
ArrayList list = new ArrayList();
list.add(key);
postKeys(list, editor, context);
}
private void postKeys(KeyStroke key1, KeyStroke key2, Editor editor, DataContext context)
{
ArrayList list = new ArrayList();
list.add(key1);
list.add(key2);
postKeys(list, editor, context);
}
private void postKeys(ArrayList keys, Editor editor, DataContext context)
{
CommandGroups.getInstance().getMacro().playbackKeys(editor, context, keys, 0);
}
private int digraphState = DIG_STATE_START;
private char digraphChar;
private char[] codeChars;
private int codeCnt;
private int codeType;
private int codeMax;
private static final int DIG_STATE_START = 1;
private static final int DIG_STATE_DIG_ONE = 2;
private static final int DIG_STATE_DIG_TWO = 3;
private static final int DIG_STATE_CODE_START = 10;
private static final int DIG_STATE_CODE_CHAR = 11;
private static Logger logger = Logger.getInstance(DigraphSequence.class.getName());
}

View File

@ -2,7 +2,7 @@ package com.maddyhome.idea.vim.ui;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003 Rick Maddy
* Copyright (C) 2003-2004 Rick Maddy
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -29,7 +29,6 @@ import java.awt.Container;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ComponentAdapter;

View File

@ -41,6 +41,8 @@ tag char action ~
line
|i_CTRL-U| CTRL-U delete all entered characters in the current
line
|i_CTRL-V_digit| CTRL-V {number} insert three digit decimal number as a single
byte.
|i_CTRL-W| CTRL-W delete word before the cursor
|i_CTRL-Y| CTRL-Y insert the character which is above the cursor
|i_<Esc>| <Esc> end insert mode