org.gjt.sp.jedit.gui
Class DefaultInputHandler

java.lang.Object
  extended byorg.gjt.sp.jedit.gui.InputHandler
      extended byorg.gjt.sp.jedit.gui.DefaultInputHandler

public class DefaultInputHandler
extends InputHandler

The default input handler. It maps sequences of keystrokes into actions and inserts key typed events into the text area.

Version:
$Id: DefaultInputHandler.java,v 1.40 2004/04/19 05:59:31 spestov Exp $
Author:
Slava Pestov

Field Summary
 
Fields inherited from class org.gjt.sp.jedit.gui.InputHandler
lastAction, lastActionCount, readNextChar, repeatCount, view
 
Constructor Summary
DefaultInputHandler(View view)
          Creates a new input handler with no key bindings defined.
DefaultInputHandler(View view, DefaultInputHandler copy)
          Creates a new input handler with the same set of key bindings as the one specified.
 
Method Summary
 void _addKeyBinding(java.lang.String keyBinding, java.lang.Object action)
          Adds a key binding to this input handler.
 void addKeyBinding(java.lang.String keyBinding, EditAction action)
          Adds a key binding to this input handler.
 void addKeyBinding(java.lang.String keyBinding, java.lang.String action)
          Adds a key binding to this input handler.
 java.lang.Object getKeyBinding(java.lang.String keyBinding)
          Returns either an edit action, or a hashtable if the specified key is a prefix.
static java.lang.String getModifierString(java.awt.event.InputEvent evt)
          Returns a string containing symbolic modifier names set in the specified event.
static char getSymbolicModifierName(int mod)
          Returns a the symbolic modifier name for the specified Java modifier flag.
 boolean handleKey(KeyEventTranslator.Key keyStroke)
          Handles the given keystroke.
 boolean isPrefixActive()
          Returns if a prefix key has been pressed.
static javax.swing.KeyStroke parseKeyStroke(java.lang.String keyStroke)
          Deprecated. We don't use Swing KeyStrokes anymore.
 void removeAllKeyBindings()
          Removes all key bindings from this input handler.
 void removeKeyBinding(java.lang.String keyBinding)
          Removes a key binding from this input handler.
 
Methods inherited from class org.gjt.sp.jedit.gui.InputHandler
getLastAction, getLastActionCount, getRepeatCount, invokeAction, invokeAction, invokeLastAction, invokeReadNextChar, readNextChar, readNextChar, resetLastActionCount, setRepeatCount, userInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInputHandler

public DefaultInputHandler(View view)
Creates a new input handler with no key bindings defined.

Parameters:
view - The view

DefaultInputHandler

public DefaultInputHandler(View view,
                           DefaultInputHandler copy)
Creates a new input handler with the same set of key bindings as the one specified. Note that both input handlers share a pointer to exactly the same key binding table; so adding a key binding in one will also add it to the other.

Parameters:
copy - The input handler to copy key bindings from
view - The view
Method Detail

addKeyBinding

public void addKeyBinding(java.lang.String keyBinding,
                          java.lang.String action)
Adds a key binding to this input handler. The key binding is a list of white space separated key strokes of the form [modifiers+]key where modifier is C for Control, A for Alt, or S for Shift, and key is either a character (a-z) or a field name in the KeyEvent class prefixed with VK_ (e.g., BACK_SPACE)

Specified by:
addKeyBinding in class InputHandler
Parameters:
keyBinding - The key binding
action - The action
Since:
jEdit 4.2pre1

addKeyBinding

public void addKeyBinding(java.lang.String keyBinding,
                          EditAction action)
Adds a key binding to this input handler. The key binding is a list of white space separated key strokes of the form [modifiers+]key where modifier is C for Control, A for Alt, or S for Shift, and key is either a character (a-z) or a field name in the KeyEvent class prefixed with VK_ (e.g., BACK_SPACE)

Specified by:
addKeyBinding in class InputHandler
Parameters:
keyBinding - The key binding
action - The action

removeKeyBinding

public void removeKeyBinding(java.lang.String keyBinding)
Removes a key binding from this input handler. This is not yet implemented.

Specified by:
removeKeyBinding in class InputHandler
Parameters:
keyBinding - The key binding

removeAllKeyBindings

public void removeAllKeyBindings()
Removes all key bindings from this input handler.

Specified by:
removeAllKeyBindings in class InputHandler

getKeyBinding

public java.lang.Object getKeyBinding(java.lang.String keyBinding)
Returns either an edit action, or a hashtable if the specified key is a prefix.

Parameters:
keyBinding - The key binding
Since:
jEdit 3.2pre5

isPrefixActive

public boolean isPrefixActive()
Returns if a prefix key has been pressed.

Overrides:
isPrefixActive in class InputHandler

handleKey

public boolean handleKey(KeyEventTranslator.Key keyStroke)
Handles the given keystroke.

Specified by:
handleKey in class InputHandler
Parameters:
keyStroke - The key stroke
Since:
jEdit 4.2pre5

getSymbolicModifierName

public static char getSymbolicModifierName(int mod)
Returns a the symbolic modifier name for the specified Java modifier flag.

Parameters:
mod - A modifier constant from InputEvent
Since:
jEdit 4.1pre3

getModifierString

public static java.lang.String getModifierString(java.awt.event.InputEvent evt)
Returns a string containing symbolic modifier names set in the specified event.

Parameters:
evt - The event
Since:
jEdit 4.1pre3

parseKeyStroke

public static javax.swing.KeyStroke parseKeyStroke(java.lang.String keyStroke)
Deprecated. We don't use Swing KeyStrokes anymore.


_addKeyBinding

public void _addKeyBinding(java.lang.String keyBinding,
                           java.lang.Object action)
Adds a key binding to this input handler. The key binding is a list of white space separated key strokes of the form [modifiers+]key where modifier is C for Control, A for Alt, or S for Shift, and key is either a character (a-z) or a field name in the KeyEvent class prefixed with VK_ (e.g., BACK_SPACE)

Parameters:
keyBinding - The key binding
action - The action