Package mars.venus.editor.jeditsyntax
Class DefaultInputHandler
java.lang.Object
java.awt.event.KeyAdapter
mars.venus.editor.jeditsyntax.InputHandler
mars.venus.editor.jeditsyntax.DefaultInputHandler
- All Implemented Interfaces:
KeyListener,EventListener
The default input handler. It maps sequences of keystrokes into actions
and inserts key typed events into the text area.
- Version:
- $Id: DefaultInputHandler.java,v 1.18 1999/12/13 03:40:30 sp Exp $
- Author:
- Slava Pestov
-
Nested Class Summary
Nested classes/interfaces inherited from class mars.venus.editor.jeditsyntax.InputHandler
InputHandler.BackspaceAction, InputHandler.BackspaceWordAction, InputHandler.ClipboardCopyAction, InputHandler.ClipboardCutAction, InputHandler.ClipboardPasteAction, InputHandler.DeleteAction, InputHandler.DeleteWordAction, InputHandler.DocumentEndAction, InputHandler.DocumentHomeAction, InputHandler.EndAction, InputHandler.HomeAction, InputHandler.IndentLeft, InputHandler.IndentRight, InputHandler.InsertCharAction, InputHandler.InsertNewlineAction, InputHandler.InsertTabAction, InputHandler.MacroRecorder, InputHandler.MoveLineDown, InputHandler.MoveLineUp, InputHandler.NewLineAfterAction, InputHandler.NewLineBeforeAction, InputHandler.NextCharAction, InputHandler.NextLineAction, InputHandler.NextPageAction, InputHandler.NextWordAction, InputHandler.NonRecordable, InputHandler.NonRepeatable, InputHandler.PrevCharAction, InputHandler.PrevLineAction, InputHandler.PrevPageAction, InputHandler.PrevWordAction, InputHandler.RepeatAction, InputHandler.SelectAllAction, InputHandler.ToggleOverwriteAction, InputHandler.ToggleRectangularAction, InputHandler.Wrapper -
Field Summary
Fields inherited from class mars.venus.editor.jeditsyntax.InputHandler
BACKSPACE, BACKSPACE_WORD, CLIP_COPY, CLIP_CUT, CLIP_PASTE, DELETE, DELETE_WORD, DOCUMENT_END, DOCUMENT_HOME, END, grabAction, HOME, INDENT_LEFT, INDENT_RIGHT, INSERT_BREAK, INSERT_CHAR, INSERT_TAB, MOVE_LINE_DOWN, MOVE_LINE_UP, NEW_LINE_AFTER, NEW_LINE_BEFORE, NEXT_CHAR, NEXT_LINE, NEXT_PAGE, NEXT_WORD, OVERWRITE, PREV_CHAR, PREV_LINE, PREV_PAGE, PREV_WORD, recorder, repeat, REPEAT, repeatCount, SELECT_ALL, SELECT_DOC_END, SELECT_DOC_HOME, SELECT_END, SELECT_HOME, SELECT_NEXT_CHAR, SELECT_NEXT_LINE, SELECT_NEXT_PAGE, SELECT_NEXT_WORD, SELECT_PREV_CHAR, SELECT_PREV_LINE, SELECT_PREV_PAGE, SELECT_PREV_WORD, SMART_HOME_END_PROPERTY, TOGGLE_RECT -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new input handler with no key bindings defined. -
Method Summary
Modifier and TypeMethodDescriptionvoidSet up the default key bindings.voidaddKeyBinding(String keyBinding, ActionListener action) Adds a key binding to this input handler.copy()Returns a copy of this input handler that shares the same key bindings.voidkeyPressed(KeyEvent event) Handle a key pressed event.voidHandle a key typed event.static KeyStrokeparseKeyStroke(String keyStroke) Converts a string to a keystroke.voidRemoves all key bindings from this input handler.voidremoveKeyBinding(String keyBinding) Removes a key binding from this input handler.Methods inherited from class mars.venus.editor.jeditsyntax.InputHandler
executeAction, getAction, getActionName, getMacroRecorder, getRepeatCount, getTextArea, grabNextKeyStroke, handleGrabAction, isRepeatEnabled, setMacroRecorder, setRepeatCount, setRepeatEnabledMethods inherited from class java.awt.event.KeyAdapter
keyReleased
-
Constructor Details
-
DefaultInputHandler
public DefaultInputHandler()Create a new input handler with no key bindings defined.
-
-
Method Details
-
addDefaultKeyBindings
public void addDefaultKeyBindings()Set up the default key bindings.- Specified by:
addDefaultKeyBindingsin classInputHandler
-
addKeyBinding
Adds a key binding to this input handler. The key binding is a list of white space separated key strokes of the form [modifiers+]key where modifier is C for Control, A for Alt, or S for Shift, and key is either a character (a-z) or a field name in the KeyEvent class prefixed with VK_ (e.g., BACK_SPACE)- Specified by:
addKeyBindingin classInputHandler- Parameters:
keyBinding- The key bindingaction- The action
-
removeKeyBinding
Removes a key binding from this input handler. This is not yet implemented.- Specified by:
removeKeyBindingin classInputHandler- Parameters:
keyBinding- The key binding
-
removeAllKeyBindings
public void removeAllKeyBindings()Removes all key bindings from this input handler.- Specified by:
removeAllKeyBindingsin classInputHandler
-
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.- Specified by:
copyin classInputHandler
-
keyPressed
Handle a key pressed event. This will look up the binding for the key stroke and execute it.- Specified by:
keyPressedin interfaceKeyListener- Overrides:
keyPressedin classKeyAdapter
-
keyTyped
Handle a key typed event. This inserts the key into the text area.- Specified by:
keyTypedin interfaceKeyListener- Overrides:
keyTypedin classKeyAdapter
-
parseKeyStroke
Converts a string to a keystroke. The string should be of the form modifiers+shortcut where modifiers is any combination of A for Alt, C for Control, S for Shift or M for Meta, and shortcut is either a single character, or a keycode name from theKeyEventclass, without theVK_prefix.- Parameters:
keyStroke- A string description of the key stroke
-