Main Page | Modules | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

CharacterLineFilter Class Reference
[Character input filters.]

#import <CharacterLineFilter.h>

Inherited by ANSICharLineFilter, DefaultLineFilter, EscapeLineFilter, XTermAltCharLineFilter, and XTermEscapeLineFilter.

Inheritance diagram for CharacterLineFilter:

Inheritance graph
[legend]
Collaboration diagram for CharacterLineFilter:

Collaboration graph
[legend]

Detailed Description

Abstract base class for terminal state machines.

CharacterLineFilter is an abstract base class for filters that turn character sequences into terminal commands. The controller that receives data from the host (MyDocument in Crescat) passes the incoming data to the current filter object (a CharacterLineFilter subclass) which passes it to the terminal model (TextStorageTerminal) either as characters to be rendered, or as commands.

CharacterLineFilters stack; there is a default filter that represents the responses to characters the terminal makes when in its initial state, but a command from the host (an escape character is the common example) may throw the terminal into a state in which characters have a different interpretation. For each such state, stack up a corresponding subclass of CharacterLineFilter, with the current filter as the fallback. Handling the transient state causes the filter to be popped off and released (releaseToFallback). Some inputs pop all filters off down to the default filter (releaseToDefault).

Definition at line 23 of file CharacterLineFilter.h.

Public Member Functions

(id) - initWithFallback:
 Initialize and stack over the given CharacterLineFilter.
(id) - initWithFallback:terminal:
 Designated initializer: Stack over the given CharacterLineFilter, using the given terminal.
(id) - processCharacter:
 Process one character of input.
(id) - processData:
 Process many characters of input.
(id) - releaseToFallback
 Release the receiver and return the next filter on the stack.
(id) - resetToDefault
 Release all filters down to the default; return default.
(id) - terminalDevice
 Getter for the target terminal device.
(void) - dealloc [implementation]
(BOOL) - isRootFilter [implementation]
 Whether this is the default filter (no fallback below it).

Protected Attributes

CharacterLineFilterfallback
id terminalDevice


Member Function Documentation

- (void) dealloc   [implementation]
 

Definition at line 33 of file CharacterLineFilter.m.

References fallback.

- (id) initWithFallback: (id)  inFallback  
 

Initialize and stack over the given CharacterLineFilter.

This is a convenience initializer, which uses the same terminal object as the fallback filter.

Parameters:
[in] inFallback the top of the line-filter stack. This is the filter that will become current when the receiver is released.
Return values:
self if initialization succeeded.
inFallback if inFallback was of the same class as self.

Definition at line 28 of file CharacterLineFilter.m.

References initWithFallback:terminal:.

Here is the call graph for this function:

- (id) initWithFallback: (id)  inFallback
terminal: (id)  terminal
 
 

Designated initializer: Stack over the given CharacterLineFilter, using the given terminal.

Keep the result of this initializer as the top of the line-filter stack, and feed data from the host to it (processCharacter: / processData:). Data will be translated into events, and corresponding messages will be sent to the terminal.

It is thought to be an error to enqueue the same filter twice in a row. If the receiver is of the same class as the inFallback filter, the receiver will be released and inFallback will be returned (thus ensuring that the returned value is always the proper top-of-stack). This stack-folding is noted in the console log.

Parameters:
[in] inFallback the top of the line-filter stack. This is the filter that will become current when the receiver is released.
Return values:
self if initialization succeeds.
inFallback if inFallback was of the same class as self.

Reimplemented in EscapeLineFilter, and XTermEscapeLineFilter.

Definition at line 14 of file CharacterLineFilter.m.

References fallback, and terminalDevice.

Referenced by initWithFallback:, and DefaultLineFilter::initWithTerminal:.

Here is the call graph for this function:

- (BOOL) isRootFilter   [implementation]
 

Whether this is the default filter (no fallback below it).

Definition at line 40 of file CharacterLineFilter.m.

References fallback.

Referenced by resetToDefault.

- (id) processCharacter: (unichar)  aCharacter  
 

Process one character of input.

Given one character from the host, respond by passing it to the terminal, changing the terminal state, or changing line filters. If the result involves a new line filter, this method allocates it and stacks it on top of the receiver.

The filter for the next character is returned, so always update the filter-stack variable with the result of this method.

Parameters:
[in] aCharacter A character (expect ISO-Latin-1) from the host.
Return values:
self If the next character is to be fed to this filter.
CharacterLineFilter A new filter, falling back to the receiver, if the character changes interpreter state.

Reimplemented in ANSICharLineFilter, DefaultLineFilter, EscapeLineFilter, XTermAltCharLineFilter, and XTermEscapeLineFilter.

Definition at line 67 of file CharacterLineFilter.m.

- (id) processData: (NSData *)  someData  
 

Process many characters of input.

This method iterates through the bytes of the given NSData, sending the first in a processCharacter: message to the receiver, and the succeeding ones to whatever line filter is top.

The filter for the next character is returned, so always update the filter-stack variable with the result of this method.

Parameters:
[in] someData NSData, characters (expect ISO-Latin-1) from the host.
Return values:
self If the next character is to be fed to this filter.
CharacterLineFilter A new filter, falling back to the receiver, if the character changes interpreter state.

Reimplemented in DefaultLineFilter.

Definition at line 72 of file CharacterLineFilter.m.

Referenced by MyDocument::dataArrivedFromPty:.

- (id) releaseToFallback  
 

Release the receiver and return the next filter on the stack.

This method is sent by the filter itself when it reaches end-of-state. End-of-state means that the filter is spent, and must be released; and the previous top-of-stack filter becomes top-of-stack again.

Return values:
CharacterLineFilter the fallback line filter, the handler for the next character.

Definition at line 47 of file CharacterLineFilter.m.

References fallback.

Referenced by resetToDefault.

- (id) resetToDefault  
 

Release all filters down to the default; return default.

Sends releaseToFallback to self, and to the results, until the result is the root filter (isRootFilter). A command, like a general reset, may terminate all character modes. This message takes all the character modes but the default off the handler stack and returns the default.

Definition at line 58 of file CharacterLineFilter.m.

References isRootFilter, and releaseToFallback.

Here is the call graph for this function:

- (id) terminalDevice  
 

Getter for the target terminal device.

Referenced by initWithFallback:terminal:.


Field Documentation

- (CharacterLineFilter*) fallback [protected]
 

Definition at line 25 of file CharacterLineFilter.h.

Referenced by dealloc, initWithFallback:terminal:, isRootFilter, and releaseToFallback.

- (id) terminalDevice [protected]
 

Definition at line 26 of file CharacterLineFilter.h.

Referenced by DefaultLineFilter::processCharacter:, and DefaultLineFilter::processData:.


The documentation for this class was generated from the following files:
Generated on Fri Sep 30 12:01:12 2005 for Crescat by  doxygen 1.4.4