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
public abstract class AbstractInputHandler<E extends JEditAbstractEditAction> extends java.lang.ObjectThe abstract input handler manage the keyboard handling. The entry point isprocessKeyEvent(java.awt.event.KeyEvent, int, boolean)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Hashtablebindingsprotected java.util.HashtablecurrentBindingsprotected java.awt.event.KeyListenerkeyEventInterceptorThis listener will receive keyboard events if it is not null.protected ElastActionprotected intlastActionCountstatic java.lang.StringPREFIX_STRprotected java.lang.StringreadNextCharprotected static intREPEAT_COUNT_THRESHOLDprotected intrepeatCountprotected booleanshortcutOn
-
Constructor Summary
Constructors Constructor Description AbstractInputHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddKeyBinding(java.lang.String keyBinding, E action)Adds a key binding to this input handler.voidaddKeyBinding(java.lang.String keyBinding, java.lang.Object action)Adds a key binding to this input handler.voidaddKeyBinding(java.lang.String keyBinding, java.lang.String action)Adds a key binding to this input handler.java.lang.ObjectgetKeyBinding(java.lang.String keyBinding)Returns either an edit action, or a hashtable if the specified key is a prefix.java.awt.event.KeyListenergetKeyEventInterceptor()intgetLastActionCount()Returns the number of times the last action was executed.abstract booleanhandleKey(KeyEventTranslator.Key keyStroke, boolean dryRun)Handles a keystroke.abstract voidinvokeAction(E action)abstract voidinvokeAction(java.lang.String action)booleanisPrefixActive()Returns if a prefix key has been pressed.abstract voidprocessKeyEvent(java.awt.event.KeyEvent evt, int from, boolean global)Process a keyboard event.protected voidprocessKeyEventKeyStrokeHandling(java.awt.event.KeyEvent evt, int from, java.lang.String mode, boolean global)voidremoveAllKeyBindings()Removes all key bindings from this input handler.voidremoveKeyBinding(java.lang.String keyBinding)Removes a key binding from this input handler.voidresetLastActionCount()Resets the last action count.protected voidsendShortcutPrefixOff()voidsetBindings(java.util.Hashtable bindings)Replace the set of key bindings.voidsetCurrentBindings(java.util.Hashtable bindings)voidsetKeyEventInterceptor(java.awt.event.KeyListener keyEventInterceptor)Sets the listener that will handle all key events in this view.static java.lang.StringtoString(java.awt.event.KeyEvent evt)Return a String representation of the keyboard event for debugging purpose.
-
-
-
Field Detail
-
lastActionCount
protected int lastActionCount
-
keyEventInterceptor
protected java.awt.event.KeyListener keyEventInterceptor
This listener will receive keyboard events if it is not null.
-
readNextChar
protected java.lang.String readNextChar
-
repeatCount
protected int repeatCount
-
lastAction
protected E extends JEditAbstractEditAction lastAction
-
REPEAT_COUNT_THRESHOLD
protected static final int REPEAT_COUNT_THRESHOLD
- See Also:
- Constant Field Values
-
PREFIX_STR
public static java.lang.String PREFIX_STR
-
shortcutOn
protected boolean shortcutOn
-
bindings
protected java.util.Hashtable bindings
-
currentBindings
protected java.util.Hashtable currentBindings
-
-
Method Detail
-
addKeyBinding
public void addKeyBinding(java.lang.String keyBinding, java.lang.String action)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
public void addKeyBinding(java.lang.String keyBinding, E action)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
public void addKeyBinding(java.lang.String keyBinding, java.lang.Object action)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
public void removeKeyBinding(java.lang.String keyBinding)
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
@Nullable public java.lang.Object getKeyBinding(@Nonnull java.lang.String keyBinding)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
public java.awt.event.KeyListener getKeyEventInterceptor()
-
setKeyEventInterceptor
public void setKeyEventInterceptor(java.awt.event.KeyListener keyEventInterceptor)
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
public void setBindings(java.util.Hashtable bindings)
Replace the set of key bindings.- Since:
- jEdit 4.3pre1
-
setCurrentBindings
public void setCurrentBindings(java.util.Hashtable bindings)
-
handleKey
public abstract boolean handleKey(KeyEventTranslator.Key keyStroke, boolean dryRun)
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
public abstract void processKeyEvent(java.awt.event.KeyEvent evt, int from, boolean global)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_BARorView.TEXT_AREAglobal- tell if the event comes from the DefaultKeyboardFocusManager or not
-
sendShortcutPrefixOff
protected void sendShortcutPrefixOff()
-
invokeAction
public abstract void invokeAction(java.lang.String action)
-
invokeAction
public abstract void invokeAction(E action)
-
toString
public static java.lang.String toString(java.awt.event.KeyEvent evt)
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(java.awt.event.KeyEvent evt, int from, java.lang.String mode, boolean global)- Parameters:
evt- the keyboard eventfrom- the source, it can beView.VIEW,View.ACTION_BARorView.TEXT_AREAmode- the mode is "press" or "type" and is used for debug onlyglobal- tell if the event comes from the DefaultKeyboardFocusManager or not
-
-