Gridarta Editor
net.sf.gridarta.textedit.textarea.InputHandler Class Referenceabstract

An input handler converts the user's key strokes into concrete actions. More...

+ Inheritance diagram for net.sf.gridarta.textedit.textarea.InputHandler:
+ Collaboration diagram for net.sf.gridarta.textedit.textarea.InputHandler:

Classes

interface  NonRepeatable
 If an action implements this interface, it should not be repeated. More...
 

Public Member Functions

abstract void addDefaultKeyBindings ()
 Adds the default key bindings to this input handler. More...
 
abstract InputHandler copy ()
 Returns a copy of this input handler that shares the same key bindings. More...
 
int getRepeatCount ()
 Returns the number of times the next action will be repeated. More...
 
void setRepeatCount (final int repeatCount)
 Sets the number of times the next action will be repeated. More...
 
void setRepeatEnabled (final boolean repeat)
 Sets the enabled state of repetition. More...
 

Static Public Member Functions

static JEditTextArea getTextArea (final EventObject evt)
 Returns the text area that fired the specified event. More...
 

Protected Member Functions

void executeAction (final ActionListener listener, final Object source, @Nullable final String actionCommand)
 Executes the specified action, repeating and recording it as necessary. More...
 
boolean handleGrabAction (final KeyEvent evt)
 If a key is being grabbed, this method should be called with the appropriate key event. More...
 
boolean isRepeatEnabled ()
 Returns if repetition is enabled. More...
 

Protected Attributes

int repeatCount
 

Private Attributes

ActionListener grabAction
 
boolean repeat
 

Static Private Attributes

static final Category LOG = Logger.getLogger(InputHandler.class)
 The Logger for printing log messages. More...
 

Detailed Description

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.

Author
Slava Pestov
Andreas Vogl
See also
DefaultInputHandler

Definition at line 36 of file InputHandler.java.

Member Function Documentation

◆ addDefaultKeyBindings()

abstract void net.sf.gridarta.textedit.textarea.InputHandler.addDefaultKeyBindings ( )
abstract

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.

Reimplemented in net.sf.gridarta.textedit.textarea.DefaultInputHandler.

Referenced by net.sf.gridarta.textedit.textarea.TextAreaDefaults.TextAreaDefaults().

+ Here is the caller graph for this function:

◆ copy()

abstract InputHandler net.sf.gridarta.textedit.textarea.InputHandler.copy ( )
abstract

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.

Returns
copy of this InputHandler

Reimplemented in net.sf.gridarta.textedit.textarea.DefaultInputHandler.

◆ executeAction()

void net.sf.gridarta.textedit.textarea.InputHandler.executeAction ( final ActionListener  listener,
final Object  source,
@Nullable final String  actionCommand 
)
protected

Executes the specified action, repeating and recording it as necessary.

Parameters
listenerthe action listener
sourcethe event source
actionCommandthe action command

Definition at line 108 of file InputHandler.java.

References net.sf.gridarta.textedit.textarea.InputHandler.grabAction, net.sf.gridarta.textedit.textarea.InputHandler.repeat, and net.sf.gridarta.textedit.textarea.InputHandler.repeatCount.

Referenced by net.sf.gridarta.textedit.textarea.InputHandler.handleGrabAction(), net.sf.gridarta.textedit.textarea.DefaultInputHandler.keyPressed(), and net.sf.gridarta.textedit.textarea.DefaultInputHandler.keyTyped().

+ Here is the caller graph for this function:

◆ getRepeatCount()

int net.sf.gridarta.textedit.textarea.InputHandler.getRepeatCount ( )

Returns the number of times the next action will be repeated.

Returns
number of times the next action will be repeated (1 or the set repeat count)

Definition at line 83 of file InputHandler.java.

References net.sf.gridarta.textedit.textarea.InputHandler.repeat, and net.sf.gridarta.textedit.textarea.InputHandler.repeatCount.

Referenced by net.sf.gridarta.textedit.textarea.actions.InsertChar.actionPerformed(), net.sf.gridarta.textedit.textarea.JEditTextArea.copy(), and net.sf.gridarta.textedit.textarea.JEditTextArea.paste().

+ Here is the caller graph for this function:

◆ getTextArea()

static JEditTextArea net.sf.gridarta.textedit.textarea.InputHandler.getTextArea ( final EventObject  evt)
static

Returns the text area that fired the specified event.

This method will throw an Error if

evt

does not have a JEditTextArea in it's source component hierarchy.

Parameters
evtthe event
Returns
the JEditTextArea found as the source of
evt

Definition at line 144 of file InputHandler.java.

References net.sf.gridarta.textedit.textarea.InputHandler.LOG.

Referenced by net.sf.gridarta.textedit.textarea.actions.InsertBreak.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.InsertTab.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Overwrite.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Repeat.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.ToggleRectangle.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Delete.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Backspace.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.InsertChar.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.BackspaceWord.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.DeleteWord.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.DocumentHome.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.NextPage.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.NextChar.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.End.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.NextLine.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.DocumentEnd.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.PrevChar.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Home.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.PrevLine.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.PrevPage.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.NextWord.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.PrevWord.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Copy.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Cut.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Paste.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.FunctionMenu.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.Find.actionPerformed(), net.sf.gridarta.textedit.textarea.actions.FindAgain.actionPerformed(), and net.sf.gridarta.textedit.textarea.actions.Replace.actionPerformed().

+ Here is the caller graph for this function:

◆ handleGrabAction()

boolean net.sf.gridarta.textedit.textarea.InputHandler.handleGrabAction ( final KeyEvent  evt)
protected

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.

Parameters
evtthe key event the key should be grabbed of
Returns
whether a grab action was active

Definition at line 182 of file InputHandler.java.

References net.sf.gridarta.textedit.textarea.InputHandler.executeAction(), and net.sf.gridarta.textedit.textarea.InputHandler.grabAction.

Referenced by net.sf.gridarta.textedit.textarea.DefaultInputHandler.keyPressed(), and net.sf.gridarta.textedit.textarea.DefaultInputHandler.keyTyped().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRepeatEnabled()

boolean net.sf.gridarta.textedit.textarea.InputHandler.isRepeatEnabled ( )
protected

Returns if repetition is enabled.

When repetition is enabled, actions will be executed multiple times. This is usually invoked with a special key stroke in the input handler.

Returns
true
if repeating is enabled, otherwise
false

Definition at line 63 of file InputHandler.java.

References net.sf.gridarta.textedit.textarea.InputHandler.repeat.

Referenced by net.sf.gridarta.textedit.textarea.DefaultInputHandler.keyTyped().

+ Here is the caller graph for this function:

◆ setRepeatCount()

void net.sf.gridarta.textedit.textarea.InputHandler.setRepeatCount ( final int  repeatCount)

Sets the number of times the next action will be repeated.

Parameters
repeatCountthe repeat count

Definition at line 91 of file InputHandler.java.

References net.sf.gridarta.textedit.textarea.InputHandler.repeatCount.

Referenced by net.sf.gridarta.textedit.textarea.actions.Repeat.actionPerformed().

+ Here is the caller graph for this function:

◆ setRepeatEnabled()

void net.sf.gridarta.textedit.textarea.InputHandler.setRepeatEnabled ( final boolean  repeat)

Sets the enabled state of repetition.

When repetition is enabled, actions will be executed multiple times. Once repeating is enabled, the input handler should read a number from the keyboard.

Parameters
repeat

Definition at line 74 of file InputHandler.java.

References net.sf.gridarta.textedit.textarea.InputHandler.repeat.

Referenced by net.sf.gridarta.textedit.textarea.actions.Repeat.actionPerformed(), and net.sf.gridarta.textedit.textarea.DefaultInputHandler.keyTyped().

+ Here is the caller graph for this function:

Member Data Documentation

◆ grabAction

ActionListener net.sf.gridarta.textedit.textarea.InputHandler.grabAction
private

◆ LOG

final Category net.sf.gridarta.textedit.textarea.InputHandler.LOG = Logger.getLogger(InputHandler.class)
staticprivate

The Logger for printing log messages.

Definition at line 41 of file InputHandler.java.

Referenced by net.sf.gridarta.textedit.textarea.InputHandler.getTextArea().

◆ repeat

◆ repeatCount


The documentation for this class was generated from the following file: