Package mars.venus.editor.jeditsyntax
Class InputHandler
java.lang.Object
java.awt.event.KeyAdapter
mars.venus.editor.jeditsyntax.InputHandler
- All Implemented Interfaces:
KeyListener,EventListener
- Direct Known Subclasses:
DefaultInputHandler
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)
- Version:
- $Id: InputHandler.java,v 1.14 1999/12/13 03:40:30 sp Exp $
- Author:
- Slava Pestov
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic interfaceMacro recorder.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic interfaceIf an action implements this interface, it should not be recorded by the macro recorder.static interfaceIf an action implements this interface, it should not be repeated.static classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic interfaceFor use by EditAction.Wrapper only. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerprotected ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerprotected InputHandler.MacroRecorderprotected booleanstatic final ActionListenerprotected intstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final ActionListenerstatic final StringIf 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 view screen, three presses = start/end of document).static final ActionListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidAdds the default key bindings to this input handler.abstract voidaddKeyBinding(String keyBinding, ActionListener action) Adds a key binding to this input handler.abstract InputHandlercopy()Returns a copy of this input handler that shares the same key bindings.voidexecuteAction(ActionListener action, Object source, String actionCommand) Executes the specified action, repeating and recording it as necessary.static ActionListenerReturns a named text area action.static StringgetActionName(ActionListener action) Returns the name of the specified text area action.Returns the macro recorder.intReturns the number of times the next action will be repeated.static JEditTextAreagetTextArea(EventObject event) Returns the text area that fired the specified event.voidgrabNextKeyStroke(ActionListener action) Grabs the next key typed event and invokes the specified action with the key as a the action command.protected voidhandleGrabAction(KeyEvent event) If a key is being grabbed, this method should be called with the appropriate key event.booleanReturns if repeating is enabled.abstract voidRemoves all key bindings from this input handler.abstract voidremoveKeyBinding(String keyBinding) Removes a key binding from this input handler.voidsetMacroRecorder(InputHandler.MacroRecorder recorder) Sets the macro recorder.voidsetRepeatCount(int repeatCount) Sets the number of times the next action will be repeated.voidsetRepeatEnabled(boolean repeat) Enables repeating.Methods inherited from class java.awt.event.KeyAdapter
keyPressed, keyReleased, keyTyped
-
Field Details
-
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 view screen, three presses = start/end of document). By default, this property is not set.- See Also:
-
BACKSPACE
-
BACKSPACE_WORD
-
DELETE
-
DELETE_WORD
-
END
-
DOCUMENT_END
-
SELECT_ALL
-
SELECT_END
-
SELECT_DOC_END
-
INSERT_BREAK
-
INSERT_TAB
-
HOME
-
DOCUMENT_HOME
-
SELECT_HOME
-
SELECT_DOC_HOME
-
NEXT_CHAR
-
NEXT_LINE
-
NEXT_PAGE
-
NEXT_WORD
-
SELECT_NEXT_CHAR
-
SELECT_NEXT_LINE
-
SELECT_NEXT_PAGE
-
SELECT_NEXT_WORD
-
OVERWRITE
-
PREV_CHAR
-
PREV_LINE
-
PREV_PAGE
-
PREV_WORD
-
SELECT_PREV_CHAR
-
SELECT_PREV_LINE
-
SELECT_PREV_PAGE
-
SELECT_PREV_WORD
-
REPEAT
-
TOGGLE_RECT
-
NEW_LINE_BEFORE
-
NEW_LINE_AFTER
-
MOVE_LINE_UP
-
MOVE_LINE_DOWN
-
INDENT_LEFT
-
INDENT_RIGHT
-
CLIP_COPY
-
CLIP_PASTE
-
CLIP_CUT
-
INSERT_CHAR
-
grabAction
-
repeat
protected boolean repeat -
repeatCount
protected int repeatCount -
recorder
-
-
Constructor Details
-
InputHandler
public InputHandler()
-
-
Method Details
-
getAction
Returns a named text area action.- Parameters:
name- The action name
-
getActionName
Returns the name of the specified text area action.- Parameters:
action- The action
-
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
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
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
Grabs the next key typed event and invokes the specified action with the key as a the action command.- Parameters:
action- 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. -
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
Returns the macro recorder. If this is non-null, all executed actions should be forwarded to the recorder. -
setMacroRecorder
Sets the macro recorder. If this is non-null, all executed actions should be forwarded to the recorder.- Parameters:
recorder- The macro recorder
-
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
Executes the specified action, repeating and recording it as necessary.- Parameters:
action- The action listenersource- The event sourceactionCommand- The action command
-
getTextArea
Returns the text area that fired the specified event.- Parameters:
event- The event
-
handleGrabAction
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.
-