So I'm writing a terminal emulation (I know, I should just compile putty, etc.) and am at the stage of plodding through vttest to make sure it's right. I'm basing it on the VT102 for now but will add later terminal features such as color when the basics are working right.
The command set is mostly ANSI. DEC had their own command set but supported the ANSI commands from about 1973. Those ANSI standards are apparently not available now but the ECMA equivalents are, I have them (ECMA-48 seems most relevant) but does not answer this question as far as I can see. Most ANSI command sequences start with ESC. Many commands start with the command sequence identifier shown here as CSI and represented in the data as 0x1c 0x5b (ESC [
), or 0xdb if 8-bit communication was possible. Then followed a sequence identifying the command. Some commands affect cursor position, some the screen, some provoke a response to the host and so on.
Some terminal commands include a numeric argument. Example CSI 10 ; 5 H
means make the cursor position row 10, column 5. When the numeric argument is missing there is a default value to use: CSI 10 ; H
means make the cursor position row 10, column 1 because 1 is the default value when an argument is not given.
I have the vt102 manual from vt100.net (great resource) and about a dozen pages giving partial information on these command sequences. Apparently the complete gospel DEC terminal spec never made it out of DEC.
What is clear is that CSI C
is move cursor right and that the default value is 1.
What isn't clear is what is the meaning of CSI 0 C
.
Why have a zero there, it would seem to make the command do nothing? If it means "use default value" then it could have been sent as 1 instead, but the shorter string would have no argument and rely on the default value being interpreted as 1 anyway. These actual physical VT terminals were often used at 300 baud and below so the one character did matter!
I'm not so advanced with vttest that I can just try it both ways and see which makes everything perfect but I'm far enough that little questions like this are starting to matter.
[
, which can be encoded either as the two-character sequenceESC [
, or as[
with the 8th bit set. (Some models may only supportESC [
) I don't know whatCSI 0 C
did on the vt102; on xterm it is equivalent toCSI 1 C
. I suspect, but don't know for sure, that 0 and the absence of a value are parsed identically at some point (thinkatoi
). Did you look for comments in the xterm source? – Gilles 'SO- stop being evil' Sep 21 '11 at 23:52