org.joone.edit.jedit
Class InputHandler
- java.lang.Object
-
- java.awt.event.KeyAdapter
-
- org.joone.edit.jedit.InputHandler
-
- All Implemented Interfaces:
- java.awt.event.KeyListener, java.util.EventListener
- Direct Known Subclasses:
- DefaultInputHandler
public abstract class InputHandler extends java.awt.event.KeyAdapterAn 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.
- See Also:
08/12/2002 Clipboard actions (Oliver Henning)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classInputHandler.backspacestatic classInputHandler.backspace_wordstatic classInputHandler.clip_copystatic classInputHandler.clip_cutstatic classInputHandler.clip_pastestatic classInputHandler.deletestatic classInputHandler.delete_wordstatic classInputHandler.document_endstatic classInputHandler.document_homestatic classInputHandler.endstatic classInputHandler.homestatic classInputHandler.insert_breakstatic classInputHandler.insert_charstatic classInputHandler.insert_tabstatic interfaceInputHandler.MacroRecorderMacro recorder.static classInputHandler.next_charstatic classInputHandler.next_linestatic classInputHandler.next_pagestatic classInputHandler.next_wordstatic interfaceInputHandler.NonRecordableIf an action implements this interface, it should not be recorded by the macro recorder.static interfaceInputHandler.NonRepeatableIf an action implements this interface, it should not be repeated.static classInputHandler.overwritestatic classInputHandler.prev_charstatic classInputHandler.prev_linestatic classInputHandler.prev_pagestatic classInputHandler.prev_wordstatic classInputHandler.repeatstatic classInputHandler.select_allstatic classInputHandler.toggle_rectstatic interfaceInputHandler.WrapperFor use by EditAction.Wrapper only.
-
Field Summary
Fields Modifier and Type Field and Description static java.awt.event.ActionListenerBACKSPACEstatic java.awt.event.ActionListenerBACKSPACE_WORDstatic java.awt.event.ActionListenerCLIP_COPYstatic java.awt.event.ActionListenerCLIP_CUTstatic java.awt.event.ActionListenerCLIP_PASTEstatic java.awt.event.ActionListenerDELETEstatic java.awt.event.ActionListenerDELETE_WORDstatic java.awt.event.ActionListenerDOCUMENT_ENDstatic java.awt.event.ActionListenerDOCUMENT_HOMEstatic java.awt.event.ActionListenerENDstatic java.awt.event.ActionListenerHOMEstatic java.awt.event.ActionListenerINSERT_BREAKstatic java.awt.event.ActionListenerINSERT_CHARstatic java.awt.event.ActionListenerINSERT_TABstatic ILoggerlogLoggerstatic java.awt.event.ActionListenerNEXT_CHARstatic java.awt.event.ActionListenerNEXT_LINEstatic java.awt.event.ActionListenerNEXT_PAGEstatic java.awt.event.ActionListenerNEXT_WORDstatic java.awt.event.ActionListenerOVERWRITEstatic java.awt.event.ActionListenerPREV_CHARstatic java.awt.event.ActionListenerPREV_LINEstatic java.awt.event.ActionListenerPREV_PAGEstatic java.awt.event.ActionListenerPREV_WORDstatic java.awt.event.ActionListenerREPEATstatic java.awt.event.ActionListenerSELECT_ALLstatic java.awt.event.ActionListenerSELECT_DOC_ENDstatic java.awt.event.ActionListenerSELECT_DOC_HOMEstatic java.awt.event.ActionListenerSELECT_ENDstatic java.awt.event.ActionListenerSELECT_HOMEstatic java.awt.event.ActionListenerSELECT_NEXT_CHARstatic java.awt.event.ActionListenerSELECT_NEXT_LINEstatic java.awt.event.ActionListenerSELECT_NEXT_PAGEstatic java.awt.event.ActionListenerSELECT_NEXT_WORDstatic java.awt.event.ActionListenerSELECT_PREV_CHARstatic java.awt.event.ActionListenerSELECT_PREV_LINEstatic java.awt.event.ActionListenerSELECT_PREV_PAGEstatic java.awt.event.ActionListenerSELECT_PREV_WORDstatic java.lang.StringSMART_HOME_END_PROPERTYIf 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 viewscreen, three presses = start/end of document).static java.awt.event.ActionListenerTOGGLE_RECT
-
Constructor Summary
Constructors Constructor and Description InputHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract voidaddDefaultKeyBindings()Adds the default key bindings to this input handler.abstract voidaddKeyBinding(java.lang.String keyBinding, java.awt.event.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(java.awt.event.ActionListener listener, java.lang.Object source, java.lang.String actionCommand)Executes the specified action, repeating and recording it as necessary.static java.awt.event.ActionListenergetAction(java.lang.String name)Returns a named text area action.static java.lang.StringgetActionName(java.awt.event.ActionListener listener)Returns the name of the specified text area action.static java.util.EnumerationgetActions()Returns an enumeration of all available actions.InputHandler.MacroRecordergetMacroRecorder()Returns the macro recorder.intgetRepeatCount()Returns the number of times the next action will be repeated.static JEditTextAreagetTextArea(java.util.EventObject evt)Returns the text area that fired the specified event.voidgrabNextKeyStroke(java.awt.event.ActionListener listener)Grabs the next key typed event and invokes the specified action with the key as a the action command.booleanisRepeatEnabled()Returns if repeating is enabled.abstract voidremoveAllKeyBindings()Removes all key bindings from this input handler.abstract voidremoveKeyBinding(java.lang.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.
-
-
-
Field Detail
-
log
public static final ILogger log
Logger
-
SMART_HOME_END_PROPERTY
public static final java.lang.String 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 viewscreen, three presses = start/end of document). By default, this property is not set.- See Also:
- Constant Field Values
-
BACKSPACE
public static final java.awt.event.ActionListener BACKSPACE
-
BACKSPACE_WORD
public static final java.awt.event.ActionListener BACKSPACE_WORD
-
DELETE
public static final java.awt.event.ActionListener DELETE
-
DELETE_WORD
public static final java.awt.event.ActionListener DELETE_WORD
-
END
public static final java.awt.event.ActionListener END
-
DOCUMENT_END
public static final java.awt.event.ActionListener DOCUMENT_END
-
SELECT_ALL
public static final java.awt.event.ActionListener SELECT_ALL
-
SELECT_END
public static final java.awt.event.ActionListener SELECT_END
-
SELECT_DOC_END
public static final java.awt.event.ActionListener SELECT_DOC_END
-
INSERT_BREAK
public static final java.awt.event.ActionListener INSERT_BREAK
-
INSERT_TAB
public static final java.awt.event.ActionListener INSERT_TAB
-
HOME
public static final java.awt.event.ActionListener HOME
-
DOCUMENT_HOME
public static final java.awt.event.ActionListener DOCUMENT_HOME
-
SELECT_HOME
public static final java.awt.event.ActionListener SELECT_HOME
-
SELECT_DOC_HOME
public static final java.awt.event.ActionListener SELECT_DOC_HOME
-
NEXT_CHAR
public static final java.awt.event.ActionListener NEXT_CHAR
-
NEXT_LINE
public static final java.awt.event.ActionListener NEXT_LINE
-
NEXT_PAGE
public static final java.awt.event.ActionListener NEXT_PAGE
-
NEXT_WORD
public static final java.awt.event.ActionListener NEXT_WORD
-
SELECT_NEXT_CHAR
public static final java.awt.event.ActionListener SELECT_NEXT_CHAR
-
SELECT_NEXT_LINE
public static final java.awt.event.ActionListener SELECT_NEXT_LINE
-
SELECT_NEXT_PAGE
public static final java.awt.event.ActionListener SELECT_NEXT_PAGE
-
SELECT_NEXT_WORD
public static final java.awt.event.ActionListener SELECT_NEXT_WORD
-
OVERWRITE
public static final java.awt.event.ActionListener OVERWRITE
-
PREV_CHAR
public static final java.awt.event.ActionListener PREV_CHAR
-
PREV_LINE
public static final java.awt.event.ActionListener PREV_LINE
-
PREV_PAGE
public static final java.awt.event.ActionListener PREV_PAGE
-
PREV_WORD
public static final java.awt.event.ActionListener PREV_WORD
-
SELECT_PREV_CHAR
public static final java.awt.event.ActionListener SELECT_PREV_CHAR
-
SELECT_PREV_LINE
public static final java.awt.event.ActionListener SELECT_PREV_LINE
-
SELECT_PREV_PAGE
public static final java.awt.event.ActionListener SELECT_PREV_PAGE
-
SELECT_PREV_WORD
public static final java.awt.event.ActionListener SELECT_PREV_WORD
-
REPEAT
public static final java.awt.event.ActionListener REPEAT
-
TOGGLE_RECT
public static final java.awt.event.ActionListener TOGGLE_RECT
-
CLIP_COPY
public static final java.awt.event.ActionListener CLIP_COPY
-
CLIP_PASTE
public static final java.awt.event.ActionListener CLIP_PASTE
-
CLIP_CUT
public static final java.awt.event.ActionListener CLIP_CUT
-
INSERT_CHAR
public static final java.awt.event.ActionListener INSERT_CHAR
-
-
Method Detail
-
getAction
public static java.awt.event.ActionListener getAction(java.lang.String name)
Returns a named text area action.- Parameters:
name- The action name
-
getActionName
public static java.lang.String getActionName(java.awt.event.ActionListener listener)
Returns the name of the specified text area action.- Parameters:
listener- The action
-
getActions
public static java.util.Enumeration getActions()
Returns an enumeration of all available actions.
-
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
public abstract void addKeyBinding(java.lang.String keyBinding, java.awt.event.ActionListener action)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
public abstract void removeKeyBinding(java.lang.String keyBinding)
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
public void grabNextKeyStroke(java.awt.event.ActionListener listener)
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
public InputHandler.MacroRecorder getMacroRecorder()
Returns the macro recorder. If this is non-null, all executed actions should be forwarded to the 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
-
copy
public abstract InputHandler 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
public void executeAction(java.awt.event.ActionListener listener, java.lang.Object source, java.lang.String actionCommand)Executes the specified action, repeating and recording it as necessary.- Parameters:
listener- The action listenersource- The event sourceactionCommand- The action command
-
getTextArea
public static JEditTextArea getTextArea(java.util.EventObject evt)
Returns the text area that fired the specified event.- Parameters:
evt- The event
-
-
DataMelt 3.0 © DataMelt by jWork.ORG