processing.app.syntax

## Class InputHandler

- Object
- - KeyAdapter
  - - InputHandler

- All Implemented Interfaces:
    KeyListener, EventListener
  Direct Known Subclasses:
    DefaultInputHandler

      public abstract class InputHandler
      extends KeyAdapter

  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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `InputHandler.backspace`
    `static class` | `InputHandler.backspace_word`
    `static class` | `InputHandler.clipboard_copy`
    `static class` | `InputHandler.clipboard_cut`
    `static class` | `InputHandler.clipboard_paste`
    `static class` | `InputHandler.delete`
    `static class` | `InputHandler.delete_word`
    `static class` | `InputHandler.document_end`
    `static class` | `InputHandler.document_home`
    `static class` | `InputHandler.end`
    `static class` | `InputHandler.home`
    `static class` | `InputHandler.insert_break`
    `static class` | `InputHandler.insert_char`
    `static class` | `InputHandler.insert_tab`
    `static interface` | `InputHandler.MacroRecorder` Macro recorder.
    `static class` | `InputHandler.next_char`
    `static class` | `InputHandler.next_line`
    `static class` | `InputHandler.next_page`
    `static class` | `InputHandler.next_word`
    `static interface` | `InputHandler.NonRecordable` If an action implements this interface, it should not be recorded by the macro recorder.
    `static interface` | `InputHandler.NonRepeatable` If an action implements this interface, it should not be repeated.
    `static class` | `InputHandler.overwrite`
    `static class` | `InputHandler.prev_char`
    `static class` | `InputHandler.prev_line`
    `static class` | `InputHandler.prev_page`
    `static class` | `InputHandler.prev_word`
    `static class` | `InputHandler.repeat`
    `static class` | `InputHandler.toggle_rect`
    `static interface` | `InputHandler.Wrapper` For use by EditAction.Wrapper only.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ActionListener` | `BACKSPACE`
    `static ActionListener` | `BACKSPACE_WORD`
    `static ActionListener` | `CLIPBOARD_COPY`
    `static ActionListener` | `CLIPBOARD_CUT`
    `static ActionListener` | `CLIPBOARD_PASTE`
    `static String` | `CONTEXT_AWARE_HOME_END` If this PDE property is set to Boolean.TRUE, the home/end keys will go to the first/last non-whitespace character of the line.
    `static ActionListener` | `DELETE`
    `static ActionListener` | `DELETE_WORD`
    `static ActionListener` | `DOCUMENT_END`
    `static ActionListener` | `DOCUMENT_HOME`
    `static ActionListener` | `END`
    `static ActionListener` | `HOME`
    `static ActionListener` | `INSERT_BREAK`
    `static ActionListener` | `INSERT_CHAR`
    `static ActionListener` | `INSERT_TAB`
    `static ActionListener` | `NEXT_CHAR`
    `static ActionListener` | `NEXT_LINE`
    `static ActionListener` | `NEXT_PAGE`
    `static ActionListener` | `NEXT_WORD`
    `static ActionListener` | `OVERWRITE`
    `static ActionListener` | `PREV_CHAR`
    `static ActionListener` | `PREV_LINE`
    `static ActionListener` | `PREV_PAGE`
    `static ActionListener` | `PREV_WORD`
    `static ActionListener` | `REPEAT`
    `static ActionListener` | `SELECT_DOC_END`
    `static ActionListener` | `SELECT_DOC_HOME`
    `static ActionListener` | `SELECT_END`
    `static ActionListener` | `SELECT_HOME`
    `static ActionListener` | `SELECT_NEXT_CHAR`
    `static ActionListener` | `SELECT_NEXT_LINE`
    `static ActionListener` | `SELECT_NEXT_PAGE`
    `static ActionListener` | `SELECT_NEXT_WORD`
    `static ActionListener` | `SELECT_PREV_CHAR`
    `static ActionListener` | `SELECT_PREV_LINE`
    `static ActionListener` | `SELECT_PREV_PAGE`
    `static ActionListener` | `SELECT_PREV_WORD`
    `static String` | `SMART_HOME_END_PROPERTY` If this client property is set to Boolean.TRUE on the text area, the home/end keys will support 'smart' BRIEF-like behaviour (one press = start/end of line, two presses = start/end of viewscreen, three presses = start/end of document).
    `static ActionListener` | `TOGGLE_RECT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InputHandler()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `addDefaultKeyBindings()` Adds the default key bindings to this input handler.
    `abstract void` | `addKeyBinding(String keyBinding, ActionListener action)` Adds a key binding to this input handler.
    `abstract InputHandler` | `copy()` Returns a copy of this input handler that shares the same key bindings.
    `void` | `executeAction(ActionListener listener, Object source, String actionCommand)` Executes the specified action, repeating and recording it as necessary.
    `static int` | `findWordEnd(String line, int pos, String noWordSep)` Locates the end of the word at the specified position.
    `static int` | `findWordStart(String line, int pos, String noWordSep)` Locates the start of the word at the specified position.
    `static ActionListener` | `getAction(String name)` Returns a named text area action.
    `static String` | `getActionName(ActionListener listener)` Returns the name of the specified text area action.
    `static Enumeration` | `getActions()` Returns an enumeration of all available actions.
    `InputHandler.MacroRecorder` | `getMacroRecorder()` Returns the macro recorder.
    `int` | `getRepeatCount()` Returns the number of times the next action will be repeated.
    `static JEditTextArea` | `getTextArea(EventObject evt)` Returns the text area that fired the specified event.
    `void` | `grabNextKeyStroke(ActionListener listener)` Grabs the next key typed event and invokes the specified action with the key as a the action command.
    `boolean` | `isRepeatEnabled()` Returns if repeating is enabled.
    `abstract void` | `removeAllKeyBindings()` Removes all key bindings from this input handler.
    `abstract void` | `removeKeyBinding(String keyBinding)` Removes a key binding from this input handler.
    `void` | `setMacroRecorder(InputHandler.MacroRecorder recorder)` Sets the macro recorder.
    `void` | `setRepeatCount(int repeatCount)` Sets the number of times the next action will be repeated.
    `void` | `setRepeatEnabled(boolean repeat)` Enables repeating.

    - ### Methods inherited from class KeyAdapter

      `keyPressed, keyReleased, keyTyped`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SMART_HOME_END_PROPERTY

          public static final String SMART_HOME_END_PROPERTY

      If this client property is set to Boolean.TRUE on the text area, the home/end keys will support 'smart' BRIEF-like behaviour (one press = start/end of line, two presses = start/end of viewscreen, three presses = start/end of document). By default, this property is not set.
      See Also:
        Constant Field Values

    - #### CONTEXT_AWARE_HOME_END

          public static final String CONTEXT_AWARE_HOME_END

      If this PDE property is set to Boolean.TRUE, the home/end keys will go to the first/last non-whitespace character of the line. If already at the that character, the keypress will move the cursor to the actual start/end of the line. SMART_HOME_END_PROPERTY takes precedence over this property.
      See Also:
        Constant Field Values

    - #### BACKSPACE

          public static final ActionListener BACKSPACE

    - #### BACKSPACE_WORD

          public static final ActionListener BACKSPACE_WORD

    - #### DELETE

          public static final ActionListener DELETE

    - #### DELETE_WORD

          public static final ActionListener DELETE_WORD

    - #### END

          public static final ActionListener END

    - #### DOCUMENT_END

          public static final ActionListener DOCUMENT_END

    - #### SELECT_END

          public static final ActionListener SELECT_END

    - #### SELECT_DOC_END

          public static final ActionListener SELECT_DOC_END

    - #### INSERT_BREAK

          public static final ActionListener INSERT_BREAK

    - #### INSERT_TAB

          public static final ActionListener INSERT_TAB

    - #### HOME

          public static final ActionListener HOME

    - #### DOCUMENT_HOME

          public static final ActionListener DOCUMENT_HOME

    - #### SELECT_HOME

          public static final ActionListener SELECT_HOME

    - #### SELECT_DOC_HOME

          public static final ActionListener SELECT_DOC_HOME

    - #### NEXT_CHAR

          public static final ActionListener NEXT_CHAR

    - #### NEXT_LINE

          public static final ActionListener NEXT_LINE

    - #### NEXT_PAGE

          public static final ActionListener NEXT_PAGE

    - #### NEXT_WORD

          public static final ActionListener NEXT_WORD

    - #### SELECT_NEXT_CHAR

          public static final ActionListener SELECT_NEXT_CHAR

    - #### SELECT_NEXT_LINE

          public static final ActionListener SELECT_NEXT_LINE

    - #### SELECT_NEXT_PAGE

          public static final ActionListener SELECT_NEXT_PAGE

    - #### SELECT_NEXT_WORD

          public static final ActionListener SELECT_NEXT_WORD

    - #### OVERWRITE

          public static final ActionListener OVERWRITE

    - #### PREV_CHAR

          public static final ActionListener PREV_CHAR

    - #### PREV_LINE

          public static final ActionListener PREV_LINE

    - #### PREV_PAGE

          public static final ActionListener PREV_PAGE

    - #### PREV_WORD

          public static final ActionListener PREV_WORD

    - #### SELECT_PREV_CHAR

          public static final ActionListener SELECT_PREV_CHAR

    - #### SELECT_PREV_LINE

          public static final ActionListener SELECT_PREV_LINE

    - #### SELECT_PREV_PAGE

          public static final ActionListener SELECT_PREV_PAGE

    - #### SELECT_PREV_WORD

          public static final ActionListener SELECT_PREV_WORD

    - #### REPEAT

          public static final ActionListener REPEAT

    - #### TOGGLE_RECT

          public static final ActionListener TOGGLE_RECT

    - #### CLIPBOARD_CUT

          public static final ActionListener CLIPBOARD_CUT

    - #### CLIPBOARD_COPY

          public static final ActionListener CLIPBOARD_COPY

    - #### CLIPBOARD_PASTE

          public static final ActionListener CLIPBOARD_PASTE

    - #### INSERT_CHAR

          public static final ActionListener INSERT_CHAR

  - ### Constructor Detail

    - #### InputHandler

          public InputHandler()

  - ### Method Detail

    - #### getAction

          public static ActionListener getAction(String name)

      Returns a named text area action.
      Parameters:
        `name` - The action name

    - #### getActionName

          public static String getActionName(ActionListener listener)

      Returns the name of the specified text area action.
      Parameters:
        `listener` - The action

    - #### getActions

          public static Enumeration getActions()

      Returns an enumeration of all available actions.

    - #### addDefaultKeyBindings

          public abstract void addDefaultKeyBindings()

      Adds the default key bindings to this input handler. This should not be called in the constructor of this input handler, because applications might load the key bindings from a file, etc.

    - #### addKeyBinding

          public abstract void addKeyBinding(String keyBinding,
                           ActionListener 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(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.

    - #### grabNextKeyStroke

          public void grabNextKeyStroke(ActionListener listener)

      Grabs the next key typed event and invokes the specified action with the key as a the action command.

    - #### isRepeatEnabled

          public boolean isRepeatEnabled()

      Returns if repeating is enabled. When repeating is enabled, actions will be executed multiple times. This is usually invoked with a special key stroke in the input handler.

    - #### setRepeatEnabled

          public void setRepeatEnabled(boolean repeat)

      Enables repeating. When repeating is enabled, actions will be executed multiple times. Once repeating is enabled, the input handler should read a number from the keyboard.

    - #### 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

    - #### getMacroRecorder

          public InputHandler.MacroRecorder getMacroRecorder()

      Returns the macro recorder. If this is non-null, all executed actions should be forwarded to the recorder.

    - #### setMacroRecorder

          public void setMacroRecorder(InputHandler.MacroRecorder recorder)

      Sets the macro recorder. If this is non-null, all executed actions should be forwarded to the recorder.
      Parameters:
        `recorder` - The macro recorder

    - #### copy

          public abstract InputHandler copy()

      Returns a copy of this input handler that shares the same key bindings. Setting key bindings in the copy will also set them in the original.

    - #### executeAction

          public void executeAction(ActionListener listener,
                           Object source,
                           String actionCommand)

      Executes the specified action, repeating and recording it as necessary.
      Parameters:
        `listener` - The action listener
        `source` - The event source
        `actionCommand` - The action command

    - #### getTextArea

          public static JEditTextArea getTextArea(EventObject evt)

      Returns the text area that fired the specified event.
      Parameters:
        `evt` - The event

    - #### findWordStart

          public static int findWordStart(String line,
                          int pos,
                          String noWordSep)

      Locates the start of the word at the specified position. Moved from TextUtilities.java [fry 121210].
      Parameters:
        `line` - The text
        `pos` - The position

    - #### findWordEnd

          public static int findWordEnd(String line,
                        int pos,
                        String noWordSep)

      Locates the end of the word at the specified position. Moved from TextUtilities.java [fry 121210].
      Parameters:
        `line` - The text
        `pos` - The position