JIDE 3.5.15

com.jidesoft.editor.action
Class InputHandler

java.lang.Object
  extended by java.awt.event.KeyAdapter
      extended by com.jidesoft.editor.action.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.

Version:
$Id: InputHandler.java,v 1.14 1999/12/13 03:40:30 sp Exp $
Author:
Slava Pestov
See Also:

08/12/2002 Clipboard actions (Oliver Henning)


Nested Class Summary
static interface InputHandler.MacroRecorder
          Macro recorder.
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 interface InputHandler.Wrapper
          For use by EditAction.Wrapper only.
 
Field Summary
protected  Action _grabAction
           
protected  boolean _repeat
           
protected  int _repeatCount
           
protected static Hashtable<String,Action> ACTIONS
           
static Action BACKSPACE
          Deletes a char before the caret if there is no selection.
static Action BACKSPACE_WORD
          Deletes from current caret to the start of the word if the caret is not at the start of the word or to the start of the previous word if the caret is currently at the start of the word.
static Action BLOCK_COMMENTS
          Comments the selected text using block comments.
static Action CLIP_COPY
          Places the selected text into the clipboard.
static Action CLIP_CUT
          Deletes the selected text from the text area and places it into the clipboard.
static Action CLIP_PASTE
          Inserts the clipboard contents into the document.
static Action CLIP_PASTE_WITH_DIALOG
          Shows a dialog so that the customer could choose text from the clipboard contents to paste.
static Action COLLAPSE_ALL
          Collapses all expanded spans.
static Action COLLAPSE_FOLDING
          Collapses the expanded span if any.
static Action DELETE
          Deletes a char at the caret if there is no selection.
static Action DELETE_LINE
          Deletes the entire line including line break associated with the line.
static Action DELETE_WORD
          Deletes from current caret to the start of the next word.
static Action DOCUMENT_END
          Moves the caret to the end of the document.
static Action DOCUMENT_HOME
          Moves the caret to the start of the document.
static Action DUPLICATE_SELECTION
          Inserts the selected text to the start of the current selection.
static Action END
          Moves the caret to the end of the line where the caret resides and clears current selection.
static Action ESCAPE
          Clears the selection if any.
static Action EXPAND_ALL
          Expands all folded spans.
static Action EXPAND_FOLDING
          Expands the folded span if any.
static Action FIND
          Shows a find and replace dialog to let the customer input searching text then search the text in the document or the current selected text.
static Action FIND_NEXT
          Looks for the next match in the document or the current selected text.
static Action FIND_PREVIOUS
          Looks for the previous match in the document or the current selected text.
static Action FOLD_SELECTION
          If there is no folding and has selection, the selected text will be folded and shown as "...".
static Action GOTO_LINE
          Shows a dialog so that the customer could input a line number then jump to the line.
static Action HOME
          Moves the caret to the start of the line where the caret resides.
static Action INDENT_SELECTION
          Indents all selected lines no matter if the selection is a line selection or not if there is a selection.
static Action INSERT_BREAK
          Deletes current selected text if any then inserts a line break.
static Action INSERT_CHAR
          Inserts the string into the document.
static Action JOIN_LINES
          Joins all selected lines by deleting line breaks and the empty spaces leading the lines.
static Action LINE_COMMENTS
          Comments all selected lines using line comments no matter if the selection is a line selection or not if there is a selection.
static Action NEXT_CHAR
          Moves the caret to the next column if CodeEditor.isVirtualSpaceAllowed() is true.
static Action NEXT_LINE
          Moves the caret to the next line.
static Action NEXT_PAGE
          Moves the caret to the next page.
static Action NEXT_WORD
          Moves the caret to the word start of the next word.
static Action OVERWRITE
          Toggles the editing mode between overwrite and insert.
static Action PREV_CHAR
          Moves the caret to the previous column or stay at column 0 if CodeEditor.isVirtualSpaceAllowed() is true.
static Action PREV_LINE
          Moves the caret to the previous line.
static Action PREV_PAGE
          Moves the caret to the previous page.
static Action PREV_WORD
          Moves caret to the the word start of the current word if the caret is not on the start of the current word or to the word start of the previous word if the caret is on the start of the current word.
static Action QUICK_SEARCH
          Shows a Searchable popup to start searching quickly.
protected  InputHandler.MacroRecorder recorder
           
static Action REDO
          Redo the last action (if possible).
static Action REPEAT
           
static Action REPLACE
          Shows a find and replace dialog to let the customer input searching text then search the text in the document or the current selected text.
static Action SELECT_ALL
          Selects all text in the document.
static Action SELECT_DOC_END
          Extends selection from current caret position to the end of the document.
static Action SELECT_DOC_HOME
          Extends selection from current caret position to the end of the document.
static Action SELECT_END
          Extends selection from current caret position to the end of the line where the caret resides.
static Action SELECT_HOME
          Extends selection from current caret position to the start of the line where the caret resides.
static Action SELECT_NEXT_CHAR
          Extends selection from current caret position to the next column if CodeEditor.isVirtualSpaceAllowed() is true.
static Action SELECT_NEXT_LINE
          Extends selection from current caret position to the next line.
static Action SELECT_NEXT_PAGE
          Extends selection from current caret position to the next page.
static Action SELECT_NEXT_WORD
          Extends selection from current caret position to the word start of the next word.
static Action SELECT_PREV_CHAR
          Extends selection from current caret position to the previous column or stay at column 0 if CodeEditor.isVirtualSpaceAllowed() is true.
static Action SELECT_PREV_LINE
          Extends selection from current caret position to the previous line.
static Action SELECT_PREV_PAGE
          Extends selection from current caret position to the next page.
static Action SELECT_PREV_WORD
          Extends selection from current caret position to the word start of the current word if the caret is not on the start of the current word or to the word start of the previous word if the caret is on the start of the current word.
static Action SELECT_TO_MATCHING_BRACKET
          Selects the block between the closest pair of brackets which contains current caret.
static Action SELECT_WORD
          Selects the word in current caret position.
static Action SPLIT_LINE
          Deletes current selected text if any then inserts a line break.
static Action START_NEW_LINE
          Inserts a line break after the end of the line where the caret is.
static Action TOGGLE_CASE
          Toggles the case when typing an alphabetic char.
static Action TOGGLE_RECT
          Toggles selection mode between normal selection mode and column selection mode.
static Action UNDO
          Undo the last action (if possible).
static Action UNINDENT_SELECTION
          Indents all selected lines no matter if the selection is a line selection or not if there is a selection.
 
Constructor Summary
InputHandler()
           
 
Method Summary
static void addAction(Action action)
          Adds an action to editor's action map.
static void addAction(String name, Action action)
          Adds an action to editor's action map.
 void executeAction(Action listener, Object source, String actionCommand)
          Executes the specified action, repeating and recording it as necessary.
abstract  Object findAction(KeyStroke keyStroke)
          Finds the action associated with the keystroke.
static Action 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<String> getActions()
          Gets the actions.
static CodeEditor getCodeEditor(EventObject evt)
          Returns the text area that fired the specified event.
 InputHandler.MacroRecorder getMacroRecorder()
          If this is non-null, all executed actions should be forwarded to the recorder.
 int getRepeatCount()
          Returns the number of times the next action will be repeated.
 void grabNextKeyStroke(Action listener)
          Grabs the next key typed event and invokes the specified action with the key as a the action command.
protected  void handleGrabAction(KeyEvent evt)
          If a key is being grabbed, this method should be called with the appropriate key event.
protected static void initDefaultActions()
           
 boolean isRepeatEnabled()
          Returns if repeating is enabled.
 void keyPressed(KeyEvent evt)
          Handle a key pressed event.
 void keyTyped(KeyEvent evt)
          Handle a key typed event.
 String modifySelectionOnPaste(CodeEditor syntaxArea, String selection)
           
static void removeAction(String name)
          Removes the action.
 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 java.awt.event.KeyAdapter
keyReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BACKSPACE

public static final Action BACKSPACE
Deletes a char before the caret if there is no selection. If there is a selection, delete all selected texts.

The default keystroke for this action is Backspace.

See Also:
CodeEditor.backspaceChar()

BACKSPACE_WORD

public static final Action BACKSPACE_WORD
Deletes from current caret to the start of the word if the caret is not at the start of the word or to the start of the previous word if the caret is currently at the start of the word.

The default keystroke for this action is Ctrl+Backspace / Meta+Backspace.

See Also:
CodeEditor.backspaceWord()

DELETE

public static final Action DELETE
Deletes a char at the caret if there is no selection. If there is a selection, delete all selected texts.

The default keystroke for this action is Delete

See Also:
CodeEditor.deleteChar()

DELETE_WORD

public static final Action DELETE_WORD
Deletes from current caret to the start of the next word.

The default keystroke for this action is Ctrl+Delete / Meta+Delete.

See Also:
CodeEditor.deleteWord()

DELETE_LINE

public static final Action DELETE_LINE
Deletes the entire line including line break associated with the line.

The default keystroke for this action is Shift+Delete.

See Also:
CodeEditor.deleteLine()

INSERT_BREAK

public static final Action INSERT_BREAK
Deletes current selected text if any then inserts a line break. It will also add empty spaces following the white spaces in the previous line. The caret will be put in the first non-space character or the end of the new line.

The default keystroke for this action is Enter.

See Also:
CodeEditor.insertBreak()

SPLIT_LINE

public static final Action SPLIT_LINE
Deletes current selected text if any then inserts a line break. It will also add empty spaces following the white spaces in the previous line. The caret will stay in the end of the current line.

The default keystroke for this action is Ctrl+Enter / Meta+Enter.

See Also:
CodeEditor.splitLine()

START_NEW_LINE

public static final Action START_NEW_LINE
Inserts a line break after the end of the line where the caret is. It will also add empty spaces following the white spaces in the previous line. Just clears selection and leaves the selected text no touch if there is any selection. The caret will be put in the first non-space character or the end of the new line.

The default keystroke for this action is Shift+Enter.

See Also:
CodeEditor.startNewLine()

INDENT_SELECTION

public static final Action INDENT_SELECTION
Indents all selected lines no matter if the selection is a line selection or not if there is a selection. If there is no selection, a tab or several white spaces will be inserted at the caret position.

The default keystroke for this action is Tab.

See Also:
CodeEditor.indentSelection()

UNINDENT_SELECTION

public static final Action UNINDENT_SELECTION
Indents all selected lines no matter if the selection is a line selection or not if there is a selection. If there is no selection, the line where the caret resides will be unindented.

The default keystroke for this action is Shift+Tab.

See Also:
CodeEditor.unindentSelection()

JOIN_LINES

public static final Action JOIN_LINES
Joins all selected lines by deleting line breaks and the empty spaces leading the lines. If there is no selection, the line where the caret resides and the next line will be joined. The current selection should be kept and the caret will be moved to where the last join happens.

The default keystroke for this action is Ctrl+Shift+J / Meta+Shift+J.

See Also:
CodeEditor.joinLines()

END

public static final Action END
Moves the caret to the end of the line where the caret resides and clears current selection.

The default keystroke for this action is End.

See Also:
CodeEditor.moveToLineEnd(boolean)

DOCUMENT_END

public static final Action DOCUMENT_END
Moves the caret to the end of the document.

The default keystroke for this action is Ctrl+End / Meta+End.

See Also:
CodeEditor.moveToDocumentEnd(boolean)

SELECT_ALL

public static final Action SELECT_ALL
Selects all text in the document.

The default keystroke for this action is Ctrl+A / Meta+A.

See Also:
CodeEditor.selectAll()

SELECT_END

public static final Action SELECT_END
Extends selection from current caret position to the end of the line where the caret resides.

The default keystroke for this action is Shift+End.

See Also:
CodeEditor.moveToLineEnd(boolean)

SELECT_DOC_END

public static final Action SELECT_DOC_END
Extends selection from current caret position to the end of the document.

The default keystroke for this action is Ctrl+Shift+End / Meta+Shift+End.

See Also:
CodeEditor.moveToDocumentEnd(boolean)

HOME

public static final Action HOME
Moves the caret to the start of the line where the caret resides.

The default keystroke for this action is Home.

See Also:
CodeEditor.moveToLineStart(boolean)

DOCUMENT_HOME

public static final Action DOCUMENT_HOME
Moves the caret to the start of the document.

The default keystroke for this action is Ctrl+Home / Meta+Home.

See Also:
CodeEditor.moveToDocumentStart(boolean)

SELECT_HOME

public static final Action SELECT_HOME
Extends selection from current caret position to the start of the line where the caret resides.

The default keystroke for this action is Shift+Home.

See Also:
CodeEditor.moveToLineStart(boolean)

SELECT_DOC_HOME

public static final Action SELECT_DOC_HOME
Extends selection from current caret position to the end of the document.

The default keystroke for this action is Ctrl+Shift+Home / Meta+Shift+Home.

See Also:
CodeEditor.moveToDocumentStart(boolean)

NEXT_CHAR

public static final Action NEXT_CHAR
Moves the caret to the next column if CodeEditor.isVirtualSpaceAllowed() is true. Otherwise moves the caret to the next char excluding line breaks.

The default keystroke for this action is Right.

See Also:
CodeEditor.moveToNextChar(boolean)

NEXT_LINE

public static final Action NEXT_LINE
Moves the caret to the next line. The column may change if CodeEditor.isVirtualSpaceAllowed() is false.

The default keystroke for this action is Down.

See Also:
CodeEditor.moveToNextLine(boolean)

NEXT_PAGE

public static final Action NEXT_PAGE
Moves the caret to the next page. The column may change if CodeEditor.isVirtualSpaceAllowed() is false.

The default keystroke for this action is Pgdn.

See Also:
CodeEditor.moveToNextPage(boolean)

NEXT_WORD

public static final Action NEXT_WORD
Moves the caret to the word start of the next word.

The default keystroke for this action is Ctrl+Right / Meta+Right.

See Also:
CodeEditor.moveToNextWord(boolean)

SELECT_NEXT_CHAR

public static final Action SELECT_NEXT_CHAR
Extends selection from current caret position to the next column if CodeEditor.isVirtualSpaceAllowed() is true. Otherwise extends selection to the next char excluding line breaks.

The default keystroke for this action is Shift+Right.

See Also:
CodeEditor.moveToNextChar(boolean)

SELECT_NEXT_LINE

public static final Action SELECT_NEXT_LINE
Extends selection from current caret position to the next line.

The default keystroke for this action is Shift+Down.

See Also:
CodeEditor.moveToNextLine(boolean)

SELECT_NEXT_PAGE

public static final Action SELECT_NEXT_PAGE
Extends selection from current caret position to the next page.

The default keystroke for this action is Shift+Pgdn.

See Also:
CodeEditor.moveToNextPage(boolean)

SELECT_NEXT_WORD

public static final Action SELECT_NEXT_WORD
Extends selection from current caret position to the word start of the next word.

The default keystroke for this action is Ctrl+Shift+Right / Meta+Shift+Right.

See Also:
CodeEditor.moveToNextWord(boolean)

OVERWRITE

public static final Action OVERWRITE
Toggles the editing mode between overwrite and insert. The caret will change accordingly.

The default keystroke for this action is Insert.

See Also:
CodeEditor.toggleOverwrite()

PREV_CHAR

public static final Action PREV_CHAR
Moves the caret to the previous column or stay at column 0 if CodeEditor.isVirtualSpaceAllowed() is true. Otherwise moves the caret to the previous char excluding line breaks.

The default keystroke for this action is Left.

See Also:
CodeEditor.moveToPreviousChar(boolean)

PREV_LINE

public static final Action PREV_LINE
Moves the caret to the previous line. The column may change if CodeEditor.isVirtualSpaceAllowed() is false.

The default keystroke for this action is Up.

See Also:
CodeEditor.moveToPreviousLine(boolean)

PREV_PAGE

public static final Action PREV_PAGE
Moves the caret to the previous page. The column may change if CodeEditor.isVirtualSpaceAllowed() is false.

The default keystroke for this action is Pgup.

See Also:
CodeEditor.moveToPreviousPage(boolean)

PREV_WORD

public static final Action PREV_WORD
Moves caret to the the word start of the current word if the caret is not on the start of the current word or to the word start of the previous word if the caret is on the start of the current word.

The default keystroke for this action is Ctrl+Left / Meta+Left.

See Also:
CodeEditor.moveToPreviousWord(boolean)

GOTO_LINE

public static final Action GOTO_LINE
Shows a dialog so that the customer could input a line number then jump to the line.

The default keystroke for this action is Ctrl+G / Meta+G.

See Also:
CodeEditor.promptGotoLine()

FIND

public static final Action FIND
Shows a find and replace dialog to let the customer input searching text then search the text in the document or the current selected text.

The default keystroke for this action is Ctrl+F / Meta+F.

See Also:
CodeEditor.find()

FIND_NEXT

public static final Action FIND_NEXT
Looks for the next match in the document or the current selected text.

The default keystroke for this action is F3.

See Also:
CodeEditor.findNext()

FIND_PREVIOUS

public static final Action FIND_PREVIOUS
Looks for the previous match in the document or the current selected text.

The default keystroke for this action is Shift+F3.

See Also:
CodeEditor.findPrevious()

REPLACE

public static final Action REPLACE
Shows a find and replace dialog to let the customer input searching text then search the text in the document or the current selected text.

The default keystroke for this action is Ctrl+R / Meta+R.

See Also:
CodeEditor.replace()

QUICK_SEARCH

public static final Action QUICK_SEARCH
Shows a Searchable popup to start searching quickly.

The default keystroke for this action is Alt+F3.

See Also:
CodeEditor.quickSearch(String)

SELECT_PREV_CHAR

public static final Action SELECT_PREV_CHAR
Extends selection from current caret position to the previous column or stay at column 0 if CodeEditor.isVirtualSpaceAllowed() is true. Otherwise extends selection to the previous char excluding line breaks.

The default keystroke for this action is Shift+Left.

See Also:
CodeEditor.moveToNextChar(boolean)

SELECT_PREV_LINE

public static final Action SELECT_PREV_LINE
Extends selection from current caret position to the previous line.

The default keystroke for this action is Shift+Up.

See Also:
CodeEditor.moveToPreviousLine(boolean)

SELECT_PREV_PAGE

public static final Action SELECT_PREV_PAGE
Extends selection from current caret position to the next page.

The default keystroke for this action is Shift+Pgup.

See Also:
CodeEditor.moveToPreviousPage(boolean)

SELECT_PREV_WORD

public static final Action SELECT_PREV_WORD
Extends selection from current caret position to the word start of the current word if the caret is not on the start of the current word or to the word start of the previous word if the caret is on the start of the current word.

The default keystroke for this action is Ctrl+Shift+Left / Meta+Shift+Left.

See Also:
CodeEditor.moveToPreviousWord(boolean)

SELECT_WORD

public static final Action SELECT_WORD
Selects the word in current caret position.

The default keystroke for this action is Ctrl+W / Meta+W.

See Also:
CodeEditor.selectWord()

SELECT_TO_MATCHING_BRACKET

public static final Action SELECT_TO_MATCHING_BRACKET
Selects the block between the closest pair of brackets which contains current caret.

The default keystroke for this action is Ctrl+B / Meta+B.

See Also:
CodeEditor.selectToMatchingBracket()

REPEAT

public static final Action REPEAT

TOGGLE_RECT

public static final Action TOGGLE_RECT
Toggles selection mode between normal selection mode and column selection mode.

The default keystroke for this action is Ctrl+\ / Alt+Shift+Insert.

See Also:
SelectionModel.setColumnSelectionMode(boolean)

DUPLICATE_SELECTION

public static final Action DUPLICATE_SELECTION
Inserts the selected text to the start of the current selection. Keeps the current selection and the current caret position. If there is no selection, the current line will be duplicated.

The default keystroke for this action is Ctrl+D / Meta+D.

See Also:
CodeEditor.duplicateSelection()

LINE_COMMENTS

public static final Action LINE_COMMENTS
Comments all selected lines using line comments no matter if the selection is a line selection or not if there is a selection. If there is no selection, the line where the caret resides will be commented.

It works only if you use LanguageSpec's configureCodeEditor to configure a CodeEditor. Otherwise it doesn't know what line comment string to use.

The default keystroke for this action is Ctrl+Slash / Meta+Slash.

See Also:
CodeEditor.lineComments()

BLOCK_COMMENTS

public static final Action BLOCK_COMMENTS
Comments the selected text using block comments. It works only if you use LanguageSpec's configureCodeEditor to configure a CodeEditor. Otherwise it doesn't know what block comment string to use.

The default keystroke for this action is Ctrl+Shift+Slash / Meta+Shift+Slash.

See Also:
CodeEditor.blockComments()

CLIP_COPY

public static final Action CLIP_COPY
Places the selected text into the clipboard. If there is no selection, selects the current line then places the selected line into the clipboard.

The default keystroke for this action is Ctrl+C / Meta+C.

See Also:
CodeEditor.clipboardCopy()

CLIP_PASTE

public static final Action CLIP_PASTE
Inserts the clipboard contents into the document. Deletes current selected text first if there is any.

The default keystroke for this action is Ctrl+V / Meta+V.

See Also:
CodeEditor.clipboardPaste()

CLIP_PASTE_WITH_DIALOG

public static final Action CLIP_PASTE_WITH_DIALOG
Shows a dialog so that the customer could choose text from the clipboard contents to paste.

The default keystroke for this action is Ctrl+Shift+V / Meta+Shift+V.

See Also:
CodeEditor.pasteWithDialog()

CLIP_CUT

public static final Action CLIP_CUT
Deletes the selected text from the text area and places it into the clipboard. If there is no selection, the current line where the caret resides will be selected and deleted and placed into the clipboard.

The default keystroke for this action is Ctrl+X / Meta+X.

See Also:
CodeEditor.clipboardCut()

UNDO

public static final Action UNDO
Undo the last action (if possible).

The default keystroke for this action is Ctrl+Z / Meta+Z.

See Also:
CodeEditor.undo()

REDO

public static final Action REDO
Redo the last action (if possible).

The default keystroke for this action is Ctrl+Shift+Z / Meta+Shift+Z.

See Also:
CodeEditor.redo()

FOLD_SELECTION

public static final Action FOLD_SELECTION
If there is no folding and has selection, the selected text will be folded and shown as "...". If the entire folded texts are selected, the folding will be removed. If there is no folding and no selection, do nothing.

The default keystroke for this action is Ctrl+Period / Meta+Period.

See Also:
CodeEditor.toggleFoldingSelection()

EXPAND_FOLDING

public static final Action EXPAND_FOLDING
Expands the folded span if any.

The default keystroke for this action is Ctrl+Equals / Meta+Equals.

See Also:
CodeEditor.expandFolding()

COLLAPSE_FOLDING

public static final Action COLLAPSE_FOLDING
Collapses the expanded span if any.

The default keystroke for this action is Ctrl+Minus / Meta+Minus.

See Also:
CodeEditor.collapseFolding()

EXPAND_ALL

public static final Action EXPAND_ALL
Expands all folded spans.

The default keystroke for this action is Ctrl+Shift+Equals / Meta+Shift+Equals.

See Also:
CodeEditor.expandAll()

COLLAPSE_ALL

public static final Action COLLAPSE_ALL
Collapses all expanded spans.

The default keystroke for this action is Ctrl+Shift+Minus / Meta+Shift+Minus.

See Also:
CodeEditor.collapseAll()

INSERT_CHAR

public static final Action INSERT_CHAR
Inserts the string into the document. Deletes the selected text first if there is a selection.

This is the default action for any other key strokes if the action for that key stroke is not defined.

See Also:
CodeEditor.insertChar(String)

TOGGLE_CASE

public static final Action TOGGLE_CASE
Toggles the case when typing an alphabetic char.

The default keystroke for this action is Ctrl+Shift+U / Meta+Shift+U.

See Also:
CodeEditor.toggleCase()

ESCAPE

public static final Action ESCAPE
Clears the selection if any. If there is no selection, clears any highlights. If there is no selection and highlights, does nothing.

The default keystroke for this action is Escape.


ACTIONS

protected static final Hashtable<String,Action> ACTIONS

_grabAction

protected Action _grabAction

_repeat

protected boolean _repeat

_repeatCount

protected int _repeatCount

recorder

protected InputHandler.MacroRecorder recorder
Constructor Detail

InputHandler

public InputHandler()
Method Detail

initDefaultActions

protected static void initDefaultActions()

addAction

public static void addAction(String name,
                             Action action)
Adds an action to editor's action map.

Parameters:
name - the name of the action. It must be unique. Otherwise, it will overwrite the previous action with the same name.
action - the action listener.

addAction

public static void addAction(Action action)
Adds an action to editor's action map.

Parameters:
action - the action. The name of the action must be unique. Otherwise, it will overwrite the previous action with the same name.

removeAction

public static void removeAction(String name)
Removes the action.

Parameters:
name - the name of the action.

getAction

public static Action getAction(String name)
Returns a named text area action.

Parameters:
name - the action name
Returns:
the action.

getActionName

public static String getActionName(ActionListener listener)
Returns the name of the specified text area action.

Parameters:
listener - the action listener
Returns:
the action name.

getActions

public static Enumeration<String> getActions()
Gets the actions.

Returns:
an enumeration of all available actions.

keyPressed

public void keyPressed(KeyEvent evt)
Handle a key pressed event. This will look up the binding for the key stroke and execute it.

Specified by:
keyPressed in interface KeyListener
Overrides:
keyPressed in class KeyAdapter

keyTyped

public void keyTyped(KeyEvent evt)
Handle a key typed event. This inserts the key into the text area.

Specified by:
keyTyped in interface KeyListener
Overrides:
keyTyped in class KeyAdapter

findAction

public abstract Object findAction(KeyStroke keyStroke)
Finds the action associated with the keystroke.

Parameters:
keyStroke - the keystroke
Returns:
the action associated with the keystroke.

grabNextKeyStroke

public void grabNextKeyStroke(Action listener)
Grabs the next key typed event and invokes the specified action with the key as a the action command.

Parameters:
listener - The action

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.

Returns:
true or false.

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.

Parameters:
repeat - the flag

getRepeatCount

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

Returns:
the count.

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()
If this is non-null, all executed actions should be forwarded to the recorder.

Returns:
the macro 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

executeAction

public void executeAction(Action 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

getCodeEditor

public static CodeEditor getCodeEditor(EventObject evt)
Returns the text area that fired the specified event.

Parameters:
evt - The event
Returns:
the CodeEditor.

handleGrabAction

protected void handleGrabAction(KeyEvent evt)
If a key is being grabbed, this method should be called with the appropriate key event. It executes the grab action with the typed character as the parameter.

Parameters:
evt - the key event

modifySelectionOnPaste

public String modifySelectionOnPaste(CodeEditor syntaxArea,
                                     String selection)

JIDE 3.5.15