The cursor-motion, cm, string syntax is exactly the same as that used in the standard termcap file. The string is introduced by a standard terminal control sequence, then the desired row and column values are presented in the manner prescribed by the terminal. Normally, the row is sent to the terminal before the column.
Because different terminals have widely differing conventions for placement of the cursor, terminal independence requires that row and column values be translated into many different formats before being sent to the terminal. The Vermont Views terminal interface contains an internal routine that interprets format-conversion sequences in the cursor-motion strings and sends the formatted string to the terminal.
The formatting of cursor-motion strings is patterned after the formatting control used in printf(). The strings contain two types of objects: ordinary characters, which are simply copied to the output, and conversion specifications.
The conversion specifications are used to translate the normal row and column integers into the formats expected by the terminal. The conversion specifications are introduced by a percent sign (%). One of the conversion fields, %i, allows row and column values based on a zero origin to be incremented by one to make them appropriate for terminals whose origin is at (1,1).
The conversion specifications supported are listed in Table 58.3.
The %d is the most common format, which simply causes the integer specified to be sent to the terminal in ASCII format. The %2 specification causes one leading blank to sent if the row or column is only one digit (as is required by some terminals). The %3 specification is similar, except that it always ensures that three characters are sent. Some terminals require that the row and column integers be treated as ASCII character values (%c). The remaining specifications are for special-purpose conversions required by certain terminals.
The example below is the cm field for the ANSI standard console under XENIX:
|
The first two characters that this string will cause to be sent to the terminal are Esc followed by a left bracket [. This is the standard lead-in sequence for the ANSI console. The final H is the terminating character for the cursor command expected by the terminal. The semi-colon is expected by the terminal to separate the row value from the column value. The remaining part of the string tells the cursor-motion interpreter routine what to do with the integer row and column values passed to it.
For example, if the cursor-motion interpreter routine is passed the values 10 and 20 (row and column), and cm is as defined above, each value will be increment by 1, to 11 and 21, because of the %i in cm. This is required because ANSI terminals have an origin of (1,1). The row and column decimal integer values are converted to sequences of ASCII hexadecimal values ("11" = 0x31 0x31 and "21" = 0x32 0x31). The actual sequence of characters that will be sent to the terminal is:
|