sub_arctic.input
Class text_focus_agent

java.lang.Object
  |
  +--sub_arctic.input.dispatch_agent
        |
        +--sub_arctic.input.focus_dispatch_agent
              |
              +--sub_arctic.input.single_focus_agent
                    |
                    +--sub_arctic.input.text_focus_agent

public class text_focus_agent
extends single_focus_agent

Focus based dispatch agent for delivering text input. This agent dispatches under the text_acceptor input protocol. That protocol provides features for filtering characters, recognizing and acting of special "action characters", and performing standard edit functions (i.e., character delete and line kill) in addition to normal text input.

See Also:
text_acceptor

Field Summary
protected  java.lang.reflect.Method action_char
          Keep a reference to the method action_char in the protected protocol.;
 char del_char1
          First character to be treated as a "delete character".
 char del_char2
          Second character to be treated as a "delete character".
protected  java.lang.reflect.Method delete_char
          Keep a reference to the method delete_char in the protected protocol.;
protected  java.lang.reflect.Method end_text_entry
          Keep a ref to the end_text_entry method.
protected  java.lang.reflect.Method line_kill
          Keep a reference to the method line_kill in the protected protocol.;
 char line_kill_char
          Character to be treated as a "line kill character".
protected  java.lang.reflect.Method new_char
          Keep a reference to the method new_char in the protected protocol.;
protected  java.lang.reflect.Method special_key
          Keep a reference to the special_key method
protected  java.lang.reflect.Method start_text_entry
          Keep a reference to the method start_text_entry in the protocol.
 
Fields inherited from class sub_arctic.input.focus_dispatch_agent
_focus_set, _user_info_set
 
Constructor Summary
text_focus_agent()
          Simple constructor.
 
Method Summary
 boolean allowable_focus(focusable candidate_obj)
          Indicate whether the given object is suitable to be our focus.
 boolean dispatch_event(event evt, java.lang.Object user_info, interactor to_obj, int seq_num)
          Attempt to dispatch the given event as text input.
static int eol_action(int ch)
          Standard filter to translate end of line characters into closure actions.
protected  void inform_focus_enter(focusable obj, event evt, java.lang.Object user_info)
          Handle informing an object that it has become the new text focus.
protected  void inform_focus_exit(focusable obj, event evt, java.lang.Object user_info)
          Handle informing an object that it has lost the text focus.
static int no_white(int ch)
          Standard filter that removes all whitespace.
static int only_digits(int ch)
          Standard filter to accept only decimal digits.
static int only_numeric(int ch)
          Standard filter to accept only decimal digits, plus, minus, and decimal point.
static int translate_to_lower(int ch)
          Standard translation filter for mapping to all lower case.
static int translate_to_upper(int ch)
          Standard translation filter for mapping to all upper case.
 
Methods inherited from class sub_arctic.input.single_focus_agent
add_to_focus, clear_focus, remove_from_focus, set_focus_to
 
Methods inherited from class sub_arctic.input.focus_dispatch_agent
focus_item, focus_set_size, is_in_focus, user_info_item
 
Methods inherited from class sub_arctic.input.dispatch_agent
after_dispatch_notify, dispatch_unused_event, event_is_useful
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start_text_entry

protected java.lang.reflect.Method start_text_entry
Keep a reference to the method start_text_entry in the protocol.

new_char

protected java.lang.reflect.Method new_char
Keep a reference to the method new_char in the protected protocol.;

action_char

protected java.lang.reflect.Method action_char
Keep a reference to the method action_char in the protected protocol.;

delete_char

protected java.lang.reflect.Method delete_char
Keep a reference to the method delete_char in the protected protocol.;

line_kill

protected java.lang.reflect.Method line_kill
Keep a reference to the method line_kill in the protected protocol.;

special_key

protected java.lang.reflect.Method special_key
Keep a reference to the special_key method

end_text_entry

protected java.lang.reflect.Method end_text_entry
Keep a ref to the end_text_entry method.

del_char1

public char del_char1
First character to be treated as a "delete character". This can be disabled by setting it to '\0'. Defaults to backspace. Note: once the system allows user preferences for edit character to be determined, this will become protected.

del_char2

public char del_char2
Second character to be treated as a "delete character". This can be disabled by setting it to '\0' or the same as del_char2. Defaults to delete. Note: once the system allows user preferences for edit character to be determined, this will become protected.

line_kill_char

public char line_kill_char
Character to be treated as a "line kill character". This can be disabled by setting it to '\0'. Defaults to ^U ('\025'). Note: once the system allows user preferences for edit character to be determined, this will become protected.
Constructor Detail

text_focus_agent

public text_focus_agent()
Simple constructor.
Method Detail

inform_focus_enter

protected void inform_focus_enter(focusable obj,
                                  event evt,
                                  java.lang.Object user_info)
Handle informing an object that it has become the new text focus. This calls the start_text_entry() method.
Parameters:
focusable - obj the object receiving focus
event - evt the event that "caused" the focus.
Object - user_info the user info to be passed to the object.
Overrides:
inform_focus_enter in class focus_dispatch_agent

inform_focus_exit

protected void inform_focus_exit(focusable obj,
                                 event evt,
                                 java.lang.Object user_info)
Handle informing an object that it has lost the text focus. This calls the end_text_entry() method.
Parameters:
focusable - obj the object loosing focus
event - evt the event that "caused" the loss of focus.
Object - user_info the user info to be passed to the object.
Overrides:
inform_focus_exit in class focus_dispatch_agent

allowable_focus

public boolean allowable_focus(focusable candidate_obj)
Indicate whether the given object is suitable to be our focus. In this case it needs to be a text_acceptor object.
Parameters:
focusable - candidate_obj the object being inquired about.
Returns:
boolean indicating if the object is suitable.
Overrides:
allowable_focus in class focus_dispatch_agent

dispatch_event

public boolean dispatch_event(event evt,
                              java.lang.Object user_info,
                              interactor to_obj,
                              int seq_num)
Attempt to dispatch the given event as text input.
Parameters:
event - evt the event to dispatch.
Object - user_info ignored (since we are focus agent).
interactor - to_obj ignored (since we are focus agent).
int - seq_num ignored (since we are focus agent).
Returns:
boolean indicating if the input was consumed.
Overrides:
dispatch_event in class focus_dispatch_agent

translate_to_upper

public static int translate_to_upper(int ch)
Standard translation filter for mapping to all upper case. Special values are passed through unaltered, so this filter can be composed with others if desired.
Parameters:
int - ch ordinal value of the character to translate.
Returns:
int the ordinal value of the character converted to upper case.

translate_to_lower

public static int translate_to_lower(int ch)
Standard translation filter for mapping to all lower case. Special values are passed through unaltered, so this filter can be composed with others if desired.
Parameters:
int - ch ordinal value of the character to translate.
Returns:
int the ordinal value of the character converted to lower case.

no_white

public static int no_white(int ch)
Standard filter that removes all whitespace. As with other filters, this can be composed with other standard filters. For example, one can code something like:
  return no_white(eol_action(translate_to_lower(ch)));
 
Parameters:
int - ch ordinal value of the character to filter.
Returns:
int the ordinal value of the filtered character.

only_digits

public static int only_digits(int ch)
Standard filter to accept only decimal digits.
Parameters:
int - ch ordinal value of the character to filter.
Returns:
int the ordinal value of the filtered character.

only_numeric

public static int only_numeric(int ch)
Standard filter to accept only decimal digits, plus, minus, and decimal point.
Parameters:
int - ch ordinal value of the character to filter.
Returns:
int the ordinal value of the filtered character.

eol_action

public static int eol_action(int ch)
Standard filter to translate end of line characters into closure actions. As with other filters, this can be composed with other standard filters. For example, one can code something like:
   return only_digits(eol_action(ch));
 
Parameters:
int - ch ordinal value of the character to filter.
Returns:
int the ordinal value of the filtered character.