|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.event.KeyAdapter com.jidesoft.editor.action.InputHandler
public abstract class InputHandler
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.
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 |
---|
public static final Action BACKSPACE
CodeEditor.backspaceChar()
public static final Action BACKSPACE_WORD
CodeEditor.backspaceWord()
public static final Action DELETE
CodeEditor.deleteChar()
public static final Action DELETE_WORD
CodeEditor.deleteWord()
public static final Action DELETE_LINE
CodeEditor.deleteLine()
public static final Action INSERT_BREAK
CodeEditor.insertBreak()
public static final Action SPLIT_LINE
CodeEditor.splitLine()
public static final Action START_NEW_LINE
CodeEditor.startNewLine()
public static final Action INDENT_SELECTION
CodeEditor.indentSelection()
public static final Action UNINDENT_SELECTION
CodeEditor.unindentSelection()
public static final Action JOIN_LINES
CodeEditor.joinLines()
public static final Action END
CodeEditor.moveToLineEnd(boolean)
public static final Action DOCUMENT_END
CodeEditor.moveToDocumentEnd(boolean)
public static final Action SELECT_ALL
CodeEditor.selectAll()
public static final Action SELECT_END
CodeEditor.moveToLineEnd(boolean)
public static final Action SELECT_DOC_END
CodeEditor.moveToDocumentEnd(boolean)
public static final Action HOME
CodeEditor.moveToLineStart(boolean)
public static final Action DOCUMENT_HOME
CodeEditor.moveToDocumentStart(boolean)
public static final Action SELECT_HOME
CodeEditor.moveToLineStart(boolean)
public static final Action SELECT_DOC_HOME
CodeEditor.moveToDocumentStart(boolean)
public static final Action NEXT_CHAR
CodeEditor.isVirtualSpaceAllowed()
is true. Otherwise moves the
caret to the next char excluding line breaks.
The default keystroke for this action is Right.
CodeEditor.moveToNextChar(boolean)
public static final Action NEXT_LINE
CodeEditor.isVirtualSpaceAllowed()
is false.
The default keystroke for this action is Down.
CodeEditor.moveToNextLine(boolean)
public static final Action NEXT_PAGE
CodeEditor.isVirtualSpaceAllowed()
is false.
The default keystroke for this action is Pgdn.
CodeEditor.moveToNextPage(boolean)
public static final Action NEXT_WORD
CodeEditor.moveToNextWord(boolean)
public static final Action SELECT_NEXT_CHAR
CodeEditor.isVirtualSpaceAllowed()
is
true. Otherwise extends selection to the next char excluding line breaks.
The default keystroke for this action is Shift+Right.
CodeEditor.moveToNextChar(boolean)
public static final Action SELECT_NEXT_LINE
CodeEditor.moveToNextLine(boolean)
public static final Action SELECT_NEXT_PAGE
CodeEditor.moveToNextPage(boolean)
public static final Action SELECT_NEXT_WORD
CodeEditor.moveToNextWord(boolean)
public static final Action OVERWRITE
CodeEditor.toggleOverwrite()
public static final Action PREV_CHAR
CodeEditor.isVirtualSpaceAllowed()
is true.
Otherwise moves the caret to the previous char excluding line breaks.
The default keystroke for this action is Left.
CodeEditor.moveToPreviousChar(boolean)
public static final Action PREV_LINE
CodeEditor.isVirtualSpaceAllowed()
is
false.
The default keystroke for this action is Up.
CodeEditor.moveToPreviousLine(boolean)
public static final Action PREV_PAGE
CodeEditor.isVirtualSpaceAllowed()
is
false.
The default keystroke for this action is Pgup.
CodeEditor.moveToPreviousPage(boolean)
public static final Action PREV_WORD
CodeEditor.moveToPreviousWord(boolean)
public static final Action GOTO_LINE
CodeEditor.promptGotoLine()
public static final Action FIND
CodeEditor.find()
public static final Action FIND_NEXT
CodeEditor.findNext()
public static final Action FIND_PREVIOUS
CodeEditor.findPrevious()
public static final Action REPLACE
CodeEditor.replace()
public static final Action QUICK_SEARCH
CodeEditor.quickSearch(String)
public static final Action SELECT_PREV_CHAR
CodeEditor.isVirtualSpaceAllowed()
is true. Otherwise extends selection to the previous char excluding line
breaks.
The default keystroke for this action is Shift+Left.
CodeEditor.moveToNextChar(boolean)
public static final Action SELECT_PREV_LINE
CodeEditor.moveToPreviousLine(boolean)
public static final Action SELECT_PREV_PAGE
CodeEditor.moveToPreviousPage(boolean)
public static final Action SELECT_PREV_WORD
CodeEditor.moveToPreviousWord(boolean)
public static final Action SELECT_WORD
CodeEditor.selectWord()
public static final Action SELECT_TO_MATCHING_BRACKET
CodeEditor.selectToMatchingBracket()
public static final Action REPEAT
public static final Action TOGGLE_RECT
SelectionModel.setColumnSelectionMode(boolean)
public static final Action DUPLICATE_SELECTION
CodeEditor.duplicateSelection()
public static final Action LINE_COMMENTS
CodeEditor.lineComments()
public static final Action BLOCK_COMMENTS
CodeEditor.blockComments()
public static final Action CLIP_COPY
CodeEditor.clipboardCopy()
public static final Action CLIP_PASTE
CodeEditor.clipboardPaste()
public static final Action CLIP_PASTE_WITH_DIALOG
CodeEditor.pasteWithDialog()
public static final Action CLIP_CUT
CodeEditor.clipboardCut()
public static final Action UNDO
CodeEditor.undo()
public static final Action REDO
CodeEditor.redo()
public static final Action FOLD_SELECTION
CodeEditor.toggleFoldingSelection()
public static final Action EXPAND_FOLDING
CodeEditor.expandFolding()
public static final Action COLLAPSE_FOLDING
CodeEditor.collapseFolding()
public static final Action EXPAND_ALL
CodeEditor.expandAll()
public static final Action COLLAPSE_ALL
CodeEditor.collapseAll()
public static final Action INSERT_CHAR
CodeEditor.insertChar(String)
public static final Action TOGGLE_CASE
CodeEditor.toggleCase()
public static final Action ESCAPE
protected static final Hashtable<String,Action> ACTIONS
protected Action _grabAction
protected boolean _repeat
protected int _repeatCount
protected InputHandler.MacroRecorder recorder
Constructor Detail |
---|
public InputHandler()
Method Detail |
---|
protected static void initDefaultActions()
public static void addAction(String name, Action action)
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.public static void addAction(Action action)
action
- the action. The name of the action must be unique. Otherwise, it will overwrite the previous action
with the same name.public static void removeAction(String name)
name
- the name of the action.public static Action getAction(String name)
name
- the action name
public static String getActionName(ActionListener listener)
listener
- the action listener
public static Enumeration<String> getActions()
public void keyPressed(KeyEvent evt)
keyPressed
in interface KeyListener
keyPressed
in class KeyAdapter
public void keyTyped(KeyEvent evt)
keyTyped
in interface KeyListener
keyTyped
in class KeyAdapter
public abstract Object findAction(KeyStroke keyStroke)
keyStroke
- the keystroke
public void grabNextKeyStroke(Action listener)
listener
- The actionpublic boolean isRepeatEnabled()
public void setRepeatEnabled(boolean repeat)
repeat
- the flagpublic int getRepeatCount()
public void setRepeatCount(int repeatCount)
repeatCount
- The repeat countpublic InputHandler.MacroRecorder getMacroRecorder()
public void setMacroRecorder(InputHandler.MacroRecorder recorder)
recorder
- The macro recorderpublic void executeAction(Action listener, Object source, String actionCommand)
listener
- The action listenersource
- The event sourceactionCommand
- The action commandpublic static CodeEditor getCodeEditor(EventObject evt)
evt
- The event
protected void handleGrabAction(KeyEvent evt)
evt
- the key eventpublic String modifySelectionOnPaste(CodeEditor syntaxArea, String selection)
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |