Module jEdit

Class AbstractInputHandler<E extends JEditAbstractEditAction>

java.lang.Object
org.gjt.sp.jedit.input.AbstractInputHandler<E>
Direct Known Subclasses:
InputHandler, TextAreaInputHandler

public abstract class AbstractInputHandler<E extends JEditAbstractEditAction> extends Object
The abstract input handler manage the keyboard handling. The entry point is processKeyEvent(java.awt.event.KeyEvent, int, boolean)
Version:
$Id: FoldHandler.java 5568 2006-07-10 20:52:23Z kpouer $
Author:
Matthieu Casanova
  • Field Details

    • lastActionCount

      protected int lastActionCount
    • keyEventInterceptor

      protected KeyListener keyEventInterceptor
      This listener will receive keyboard events if it is not null.
    • readNextChar

      protected String readNextChar
    • repeatCount

      protected int repeatCount
    • lastAction

      protected E extends JEditAbstractEditAction lastAction
    • REPEAT_COUNT_THRESHOLD

      protected static final int REPEAT_COUNT_THRESHOLD
      See Also:
    • PREFIX_STR

      public static String PREFIX_STR
    • shortcutOn

      protected boolean shortcutOn
    • bindings

      protected Hashtable bindings
    • currentBindings

      protected Hashtable currentBindings
  • Constructor Details

    • AbstractInputHandler

      public AbstractInputHandler()
  • Method Details

    • addKeyBinding

      public void addKeyBinding(String keyBinding, 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)
      Parameters:
      keyBinding - The key binding
      action - The action
      Since:
      jEdit 4.2pre1
    • addKeyBinding

      public void addKeyBinding(String keyBinding, E 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
    • addKeyBinding

      public void addKeyBinding(String keyBinding, 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
      Since:
      jEdit 4.3pre1
    • removeKeyBinding

      public void removeKeyBinding(String keyBinding)
      Removes a key binding from this input handler.
      Parameters:
      keyBinding - The key binding
    • removeAllKeyBindings

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

      @Nullable public Object getKeyBinding(@Nonnull 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
    • getLastActionCount

      public int getLastActionCount()
      Returns the number of times the last action was executed. It can be used with smartHome and smartEnd
      Returns:
      the number of times the last action was executed
      Since:
      jEdit 2.5pre5
    • resetLastActionCount

      public void resetLastActionCount()
      Resets the last action count. This should be called when an editing operation that is not an action is invoked, for example a mouse click.
      Since:
      jEdit 4.0pre1
    • getKeyEventInterceptor

      public KeyListener getKeyEventInterceptor()
    • setKeyEventInterceptor

      public void setKeyEventInterceptor(KeyListener keyEventInterceptor)
      Sets the listener that will handle all key events in this view. For example, the complete word command uses this so that all key events are passed to the word list popup while it is visible.
      Parameters:
      keyEventInterceptor - the KeyListener that will receive the events
    • isPrefixActive

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

      public void setBindings(Hashtable bindings)
      Replace the set of key bindings.
      Since:
      jEdit 4.3pre1
    • setCurrentBindings

      public void setCurrentBindings(Hashtable bindings)
    • handleKey

      public abstract boolean handleKey(KeyEventTranslator.Key keyStroke, boolean dryRun)
      Handles a keystroke.
      Parameters:
      keyStroke - The key stroke.
      dryRun - only calculate the return value, do not have any other effect
      Returns:
      true if the input could be handled.
      Since:
      jEdit 4.3pre7
    • processKeyEvent

      public abstract void processKeyEvent(KeyEvent evt, int from, boolean global)
      Process a keyboard event. This is the entry point of the keyboard handling
      Parameters:
      evt - the keyboard event
      from - the source, it can be View.VIEW, View.ACTION_BAR or View.TEXT_AREA
      global - tell if the event comes from the DefaultKeyboardFocusManager or not
    • sendShortcutPrefixOff

      protected void sendShortcutPrefixOff()
    • invokeAction

      public abstract void invokeAction(String action)
    • invokeAction

      public abstract void invokeAction(E action)
    • toString

      public static String toString(KeyEvent evt)
      Return a String representation of the keyboard event for debugging purpose.
      Parameters:
      evt - the keyboard event
      Returns:
      a String representation for this keyboard event
      Since:
      jEdit 4.3pre15
    • processKeyEventKeyStrokeHandling

      protected void processKeyEventKeyStrokeHandling(KeyEvent evt, int from, String mode, boolean global)
      Parameters:
      evt - the keyboard event
      from - the source, it can be View.VIEW, View.ACTION_BAR or View.TEXT_AREA
      mode - the mode is "press" or "type" and is used for debug only
      global - tell if the event comes from the DefaultKeyboardFocusManager or not