function ProcessChar(aCh : AnsiChar) : TApxParserCmdType; override;
TApxParserCmdType = (pctNone, pctChar, pctPending, pctComplete);
Processes a single character.
Please see the ProcessChar method of the TApxTerminalParser class on page 194 for a description of how the ProcessChar method works.
The VT100 terminal (and the ANSI specification) has one peculiarity that is generally not well implemented by terminal emulators. The VT100 terminal supports several one-byte control characters: line feed ($10), carriage return ($13), horizontal tab ($09), and so on. Like the VT100 terminal, the VT100 parser class recognizes these one-byte control characters, and acts upon them, even in the middle of an escape sequence. For example, <Esc><CR>7 (where <CR> is the carriage return character) will be interpreted as <CR><Esc>7; the <CR> being acted upon immediately, rather than being ignored. For this example, the result values returned by ProcessChar for the three characters would be: pctPending for the <Esc>; pctComplete for the <CR> (and the Argument, ArgumentCount, Command and Sequence properties would be set accordingly); and, finally, pctComplete for the <Esc>7 sequence (again setting the Argument, ArgumentCount, Command and Sequence properties accordingly). Notice that this behavior necessitates that the parser save the not quite complete escape sequence somewhere: this is done automatically.
The ANSI specification details the behavior if an <Esc> character appears in the middle of an escape sequence: the second <Esc> cancels the original escape sequence and starts a new one. So, for example, with <Esc[12<Esc>7, the second <Esc> character would cancel the partial escape sequence that begins <Esc>[12 and start a new one.
Two one-byte control characters that have special significance are CAN ($18) and SUB ($1A). These cancel the current escape sequence (if one is being built up). If ProcessChar is called with either of these characters, at any time, it will clear the VT100 parser and return pctNone.
Although the ProcessChar method will successfully parse and decode the standard VT100 escape sequences, in general it will not carry out any of the decoded commands internally. That job is left to the terminal component itself. However, there is an exception to the rule. Two escape sequences affect the operation of the VT100 parser. The first is the <Esc>[?2l sequence, which switches the terminal into VT52 mode. The second is the <Esc>< sequence, which switches it back to ANSI mode. The importance of these two modes is that the terminal recognizes different escape sequences in each of these modes and, hence, the parser has to be able to know when to parse the ANSI sequences and when to parse the VT52 sequences. For example, in ANSI mode the <Esc>D sequence is the same as move the cursor one line down (the "Index" operation) whereas in VT52 mode it means move the cursor one position left. If the parser could not determine which state the terminal was in, it may parse this sequence badly. Hence, the VT100 parser class maintains the InVT52Mode property and this is set internally by the ProcessChar method to reflect the current ANSI/VT52 mode on receipt of one of these two sequences.
See also: InVT52Mode