Module jEdit
Package org.gjt.sp.jedit.input
Class AbstractInputHandler<E extends JEditAbstractEditAction>
java.lang.Object
org.gjt.sp.jedit.input.AbstractInputHandler<E>
- Direct Known Subclasses:
InputHandler
,TextAreaInputHandler
The abstract input handler manage the keyboard handling.
The entry point is
processKeyEvent(java.awt.event.KeyEvent, int, boolean)
- Version:
- $Id: FoldHandler.java 5568 2006-07-10 20:52:23Z kpouer $
- Author:
- Matthieu Casanova
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addKeyBinding
(String keyBinding, E action) Adds a key binding to this input handler.void
addKeyBinding
(String keyBinding, Object action) Adds a key binding to this input handler.void
addKeyBinding
(String keyBinding, String action) Adds a key binding to this input handler.getKeyBinding
(String keyBinding) Returns either an edit action, or a hashtable if the specified key is a prefix.int
Returns the number of times the last action was executed.abstract boolean
handleKey
(KeyEventTranslator.Key keyStroke, boolean dryRun) Handles a keystroke.abstract void
invokeAction
(E action) abstract void
invokeAction
(String action) boolean
Returns if a prefix key has been pressed.abstract void
processKeyEvent
(KeyEvent evt, int from, boolean global) Process a keyboard event.protected void
processKeyEventKeyStrokeHandling
(KeyEvent evt, int from, String mode, boolean global) void
Removes all key bindings from this input handler.void
removeKeyBinding
(String keyBinding) Removes a key binding from this input handler.void
Resets the last action count.protected void
void
setBindings
(Hashtable bindings) Replace the set of key bindings.void
setCurrentBindings
(Hashtable bindings) void
setKeyEventInterceptor
(KeyListener keyEventInterceptor) Sets the listener that will handle all key events in this view.static String
Return a String representation of the keyboard event for debugging purpose.
-
Field Details
-
lastActionCount
protected int lastActionCount -
keyEventInterceptor
This listener will receive keyboard events if it is not null. -
readNextChar
-
repeatCount
protected int repeatCount -
lastAction
-
REPEAT_COUNT_THRESHOLD
protected static final int REPEAT_COUNT_THRESHOLD- See Also:
-
PREFIX_STR
-
shortcutOn
protected boolean shortcutOn -
bindings
-
currentBindings
-
-
Constructor Details
-
AbstractInputHandler
public AbstractInputHandler()
-
-
Method Details
-
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)- Parameters:
keyBinding
- The key bindingaction
- The action- Since:
- jEdit 4.2pre1
-
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)- Parameters:
keyBinding
- The key bindingaction
- The action
-
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)- Parameters:
keyBinding
- The key bindingaction
- The action- Since:
- jEdit 4.3pre1
-
removeKeyBinding
Removes a key binding from this input handler.- Parameters:
keyBinding
- The key binding
-
removeAllKeyBindings
public void removeAllKeyBindings()Removes all key bindings from this input handler. -
getKeyBinding
Returns either an edit action, or a hashtable if the specified key is a prefix.- Parameters:
keyBinding
- The key binding- Since:
- jEdit 3.2pre5
-
getLastActionCount
public int getLastActionCount()Returns the number of times the last action was executed. It can be used with smartHome and smartEnd- Returns:
- the number of times the last action was executed
- Since:
- jEdit 2.5pre5
-
resetLastActionCount
public void resetLastActionCount()Resets the last action count. This should be called when an editing operation that is not an action is invoked, for example a mouse click.- Since:
- jEdit 4.0pre1
-
getKeyEventInterceptor
-
setKeyEventInterceptor
Sets the listener that will handle all key events in this view. For example, the complete word command uses this so that all key events are passed to the word list popup while it is visible.- Parameters:
keyEventInterceptor
- the KeyListener that will receive the events
-
isPrefixActive
public boolean isPrefixActive()Returns if a prefix key has been pressed. -
setBindings
Replace the set of key bindings.- Since:
- jEdit 4.3pre1
-
setCurrentBindings
-
handleKey
Handles a keystroke.- Parameters:
keyStroke
- The key stroke.dryRun
- only calculate the return value, do not have any other effect- Returns:
- true if the input could be handled.
- Since:
- jEdit 4.3pre7
-
processKeyEvent
Process a keyboard event. This is the entry point of the keyboard handling- Parameters:
evt
- the keyboard eventfrom
- the source, it can beView.VIEW
,View.ACTION_BAR
orView.TEXT_AREA
global
- tell if the event comes from the DefaultKeyboardFocusManager or not
-
sendShortcutPrefixOff
protected void sendShortcutPrefixOff() -
invokeAction
-
invokeAction
-
toString
Return a String representation of the keyboard event for debugging purpose.- Parameters:
evt
- the keyboard event- Returns:
- a String representation for this keyboard event
- Since:
- jEdit 4.3pre15
-
processKeyEventKeyStrokeHandling
protected void processKeyEventKeyStrokeHandling(KeyEvent evt, int from, String mode, boolean global) - Parameters:
evt
- the keyboard eventfrom
- the source, it can beView.VIEW
,View.ACTION_BAR
orView.TEXT_AREA
mode
- the mode is "press" or "type" and is used for debug onlyglobal
- tell if the event comes from the DefaultKeyboardFocusManager or not
-