Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.maddyhome.idea.vim.key
Class KeyParser  view KeyParser download KeyParser.java

java.lang.Object
  extended bycom.maddyhome.idea.vim.key.KeyParser

public class KeyParser
extends java.lang.Object

The key parser creates a tree of key sequences with terminals represnting complete keystroke sequences mapped to specific actions. Arguments also act as terminals represents a complete command that requires more keystrokes as an argument.

There are several trees. Each tree represents a valid set of keystroke sequences for a given mode in Vim. These modes include:

Several convenience methods are provided for building the key mapping trees. The mappings supplied to all the registerAction methods are combinations of the five mapping constants. The action names supplied must be valid action ids registered with Idea. These can be built in actions supplied with Idea or custom actions supplied with the plugin. All the custom Vim Plugin actions are listed in the plugin.xml file.


Field Summary
private static KeyParser instance
           
private  java.util.HashMap keyRoots
           
private static Logger logger
           
static int MAPPING_CMD_LINE
          Indicates this key mapping applies to Command Line mode
private static int MAPPING_CNT
           
static int MAPPING_INSERT
          Indicates this key mapping applies to Insert mode
static int MAPPING_NORMAL
          Indicates this key mapping applies to Normal mode
static int MAPPING_NVO
          Helper value for the typical key mapping that works in Normal, Visual, and Operator Pending modes
static int MAPPING_OP_PEND
          Indicates this key mapping applies to Operator Pending mode
static int MAPPING_VISUAL
          Indicates this key mapping applies to Visual mode
 
Constructor Summary
private KeyParser()
          Creates the key parser
 
Method Summary
private  Node addNode(ParentNode base, java.lang.String actName, int cmdType, int cmdFlags, javax.swing.KeyStroke key, int argType, boolean last)
          Adds a new node to the tree
static KeyParser getInstance()
          Returns the singleton instance of this key parser
 RootNode getKeyRoot(int mode)
          Returns the root of the key mapping for the given mapping mode
private  void registerAction(int mapping, java.lang.String actName, int cmdType, int cmdFlags, javax.swing.KeyStroke[] keys, int argType)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, int cmdFlags, Shortcut shortcut)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, int cmdFlags, Shortcut[] shortcuts)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, int cmdFlags, Shortcut[] shortcuts, int argType)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, int cmdFlags, Shortcut shortcut, int argType)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, Shortcut shortcut)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, Shortcut[] shortcuts)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, Shortcut[] shortcuts, int argType)
          Registers the action
 void registerAction(int mapping, java.lang.String actName, int cmdType, Shortcut shortcut, int argType)
          Registers the action
static void setupActionHandler(java.lang.String ideaActName)
           
static void setupActionHandler(java.lang.String ideaActName, java.lang.String vimActName, javax.swing.KeyStroke stroke)
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAPPING_NORMAL

public static final int MAPPING_NORMAL
Indicates this key mapping applies to Normal mode

See Also:
Constant Field Values

MAPPING_VISUAL

public static final int MAPPING_VISUAL
Indicates this key mapping applies to Visual mode

See Also:
Constant Field Values

MAPPING_OP_PEND

public static final int MAPPING_OP_PEND
Indicates this key mapping applies to Operator Pending mode

See Also:
Constant Field Values

MAPPING_INSERT

public static final int MAPPING_INSERT
Indicates this key mapping applies to Insert mode

See Also:
Constant Field Values

MAPPING_CMD_LINE

public static final int MAPPING_CMD_LINE
Indicates this key mapping applies to Command Line mode

See Also:
Constant Field Values

MAPPING_CNT

private static final int MAPPING_CNT
See Also:
Constant Field Values

MAPPING_NVO

public static final int MAPPING_NVO
Helper value for the typical key mapping that works in Normal, Visual, and Operator Pending modes

See Also:
Constant Field Values

keyRoots

private java.util.HashMap keyRoots

instance

private static KeyParser instance

logger

private static Logger logger
Constructor Detail

KeyParser

private KeyParser()
Creates the key parser

Method Detail

getInstance

public static KeyParser getInstance()
Returns the singleton instance of this key parser


setupActionHandler

public static void setupActionHandler(java.lang.String ideaActName)

setupActionHandler

public static void setupActionHandler(java.lang.String ideaActName,
                                      java.lang.String vimActName,
                                      javax.swing.KeyStroke stroke)

getKeyRoot

public RootNode getKeyRoot(int mode)
Returns the root of the key mapping for the given mapping mode


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           Shortcut shortcut)
Registers the action


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           int cmdFlags,
                           Shortcut shortcut)
Registers the action


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           Shortcut shortcut,
                           int argType)
Registers the action


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           int cmdFlags,
                           Shortcut shortcut,
                           int argType)
Registers the action


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           Shortcut[] shortcuts)
Registers the action


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           Shortcut[] shortcuts,
                           int argType)
Registers the action


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           int cmdFlags,
                           Shortcut[] shortcuts)
Registers the action


registerAction

public void registerAction(int mapping,
                           java.lang.String actName,
                           int cmdType,
                           int cmdFlags,
                           Shortcut[] shortcuts,
                           int argType)
Registers the action


registerAction

private void registerAction(int mapping,
                            java.lang.String actName,
                            int cmdType,
                            int cmdFlags,
                            javax.swing.KeyStroke[] keys,
                            int argType)
Registers the action


addNode

private Node addNode(ParentNode base,
                     java.lang.String actName,
                     int cmdType,
                     int cmdFlags,
                     javax.swing.KeyStroke key,
                     int argType,
                     boolean last)
Adds a new node to the tree


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).