org.gjt.sp.jedit.gui
Class InputHandler

java.lang.Object
  extended by org.gjt.sp.jedit.input.AbstractInputHandler
      extended by org.gjt.sp.jedit.gui.InputHandler
Direct Known Subclasses:
DefaultInputHandler

public abstract class InputHandler
extends AbstractInputHandler

An input handler converts the user's key strokes into concrete actions. It also takes care of macro recording and action repetition.

This class provides all the necessary support code for an input handler, but doesn't actually do any key binding logic. It is up to the implementations of this class to do so.

See Also:
DefaultInputHandler

Field Summary
protected  EditAction lastAction
           
protected  View view
           
 
Fields inherited from class org.gjt.sp.jedit.input.AbstractInputHandler
keyEventInterceptor, lastActionCount, readNextChar, REPEAT_COUNT_THRESHOLD, repeatCount
 
Constructor Summary
InputHandler(View view)
          Creates a new input handler.
 
Method Summary
abstract  void addKeyBinding(java.lang.String keyBinding, EditAction action)
          Adds a key binding to this input handler.
abstract  void addKeyBinding(java.lang.String keyBinding, java.lang.String action)
          Adds a key binding to this input handler.
 EditAction getLastAction()
          Returns the last executed action.
 int getRepeatCount()
          Returns the number of times the next action will be repeated.
 boolean handleKey(KeyEventTranslator.Key keyStroke)
          Handles a keystroke.
 void invokeAction(EditAction action)
          Invokes the specified action, repeating and recording it as necessary.
 void invokeAction(java.lang.String action)
          Invokes the specified action, repeating and recording it as necessary.
 void invokeLastAction()
           
protected  void invokeReadNextChar(char ch)
           
 void processKeyEvent(java.awt.event.KeyEvent evt, int from, boolean global)
          Forwards key events directly to the input handler.
 void readNextChar(java.lang.String code)
          Deprecated. Use the other form of this method instead
 void readNextChar(java.lang.String msg, java.lang.String code)
          Invokes the specified BeanShell code, replacing __char__ in the code with the next input character.
abstract  void removeAllKeyBindings()
          Removes all key bindings from this input handler.
abstract  void removeKeyBinding(java.lang.String keyBinding)
          Removes a key binding from this input handler.
 void setRepeatCount(int repeatCount)
          Sets the number of times the next action will be repeated.
protected  void userInput(char ch)
           
 
Methods inherited from class org.gjt.sp.jedit.input.AbstractInputHandler
getKeyEventInterceptor, getLastActionCount, handleKey, isPrefixActive, processKeyEventKeyStrokeHandling, resetLastActionCount, setKeyEventInterceptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

view

protected final View view

lastAction

protected EditAction lastAction
Constructor Detail

InputHandler

public InputHandler(View view)
Creates a new input handler.

Parameters:
view - The view
Method Detail

addKeyBinding

public abstract void addKeyBinding(java.lang.String keyBinding,
                                   java.lang.String action)
Adds a key binding to this input handler.

Parameters:
keyBinding - The key binding (the format of this is input-handler specific)
action - The action

addKeyBinding

public abstract void addKeyBinding(java.lang.String keyBinding,
                                   EditAction action)
Adds a key binding to this input handler.

Parameters:
keyBinding - The key binding (the format of this is input-handler specific)
action - The action

removeKeyBinding

public abstract void removeKeyBinding(java.lang.String keyBinding)
Removes a key binding from this input handler.

Parameters:
keyBinding - The key binding

removeAllKeyBindings

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


handleKey

public final boolean handleKey(KeyEventTranslator.Key keyStroke)
Handles a keystroke.

Parameters:
keyStroke - The key stroke.
Returns:
true if the input could be handled.
Since:
jEdit 4.2pre5

processKeyEvent

public void processKeyEvent(java.awt.event.KeyEvent evt,
                            int from,
                            boolean global)
Forwards key events directly to the input handler. This is slightly faster than using a KeyListener because some Swing overhead is avoided.

Specified by:
processKeyEvent in class AbstractInputHandler
Since:
4.3pre7

getRepeatCount

public int getRepeatCount()
Returns the number of times the next action will be repeated.


setRepeatCount

public void setRepeatCount(int repeatCount)
Sets the number of times the next action will be repeated.

Parameters:
repeatCount - The repeat count

getLastAction

public EditAction getLastAction()
Returns the last executed action.

Since:
jEdit 2.5pre5

readNextChar

public void readNextChar(java.lang.String msg,
                         java.lang.String code)
Invokes the specified BeanShell code, replacing __char__ in the code with the next input character.

Parameters:
msg - The prompt to display in the status bar
code - The code
Since:
jEdit 3.2pre2

readNextChar

public void readNextChar(java.lang.String code)
Deprecated. Use the other form of this method instead


invokeAction

public void invokeAction(java.lang.String action)
Invokes the specified action, repeating and recording it as necessary.

Parameters:
action - The action
Since:
jEdit 4.2pre1

invokeAction

public void invokeAction(EditAction action)
Invokes the specified action, repeating and recording it as necessary.

Parameters:
action - The action

invokeLastAction

public void invokeLastAction()

userInput

protected void userInput(char ch)

invokeReadNextChar

protected void invokeReadNextChar(char ch)