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 class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static interface
Macro recorder.static class
static class
static class
static class
static interface
If an action implements this interface, it should not be recorded by the macro recorder.static interface
If an action implements this interface, it should not be repeated.static class
static class
static class
static class
static class
static class
static class
static class
static interface
For use by EditAction.Wrapper only. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
protected ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
protected InputHandler.MacroRecorder
protected boolean
static final ActionListener
protected int
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final ActionListener
static final String
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).static final ActionListener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
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 action, Object source, String actionCommand) Executes the specified action, repeating and recording it as necessary.static ActionListener
Returns a named text area action.static String
getActionName
(ActionListener action) Returns the name of the specified text area action.Returns the macro recorder.int
Returns the number of times the next action will be repeated.static JEditTextArea
getTextArea
(EventObject event) Returns the text area that fired the specified event.void
grabNextKeyStroke
(ActionListener action) Grabs the next key typed event and invokes the specified action with the key as a the action command.protected void
handleGrabAction
(KeyEvent event) If a key is being grabbed, this method should be called with the appropriate key event.boolean
Returns if repeating is enabled.abstract void
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 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
-
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.
-