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.

  • 2
    Terminology note: CSI is escape-[, which can be encoded either as the two-character sequence ESC [, or as [ with the 8th bit set. (Some models may only support ESC [) I don't know what CSI 0 C did on the vt102; on xterm it is equivalent to CSI 1 C. I suspect, but don't know for sure, that 0 and the absence of a value are parsed identically at some point (think atoi). Did you look for comments in the xterm source? Commented Sep 21, 2011 at 23:52
  • Absolutely correct, thanks for the edit, and expect I will need to look at some source to get some more clues.
    – user10907
    Commented Sep 22, 2011 at 1:54

2 Answers 2


I got in touch with Thomas Dickey (invisible-island.net) who maintains xterm and vttest - he explained that CSI 0 C is the same as CSI 1 C or CSI C in xterm.

For anyone looking for more information on terminal programming I highly recommend checking out the xterm source he hosts - specifically the ctlseqs.txt inside xterm, which looks very much like the one true terminal control sequences reference I've been searching for.

  • This source file was useful for me to find what the CSI code is; the information about the CSI being represented as 0x9b byte from the mentioned ctlseqs.txt seems to be wrong, it actually is 0x1b
    – Hi-Angel
    Commented Mar 31, 2015 at 13:34

Why hardcode compatibility for a specific terminal type when you've already got a database mapping the functionality to specific code sequences for lots of different terminals? (the terminfo database is usually in /usr/share and is included in most ncurses distributions). Any resource on curses should explain the way these functions are labelled.

Note that terminfo files are usually compiled (using tic) so you might have to dig a bit to find the terminfo source files.

See also http://tldp.org/HOWTO/Text-Terminal-HOWTO.html#toc16 (there's a link in their to one repository of terminfo.src files)

  • The device I'm putting the terminal on has no terminfo or ncurses, and writing a specific terminal emulation seems to be the best way to get netback to run on it. There are nethacks for iPad already but I just want to be able to play it with a keyboard in DECgraphics mode rather than any GUI with touch control scheme as all of them seem to have. I don't expect this will set the world on fire but it's the way I want to play nethack.
    – user10907
    Commented Sep 22, 2011 at 23:36
  • 1
    No - I'm not saying there should be an entry in terminfo for your hardware - there WILL be an entry for a VT102 though describing all the command sequences which nethack or any other curses based application will use.
    – symcbean
    Commented Sep 26, 2011 at 13:13
  • Ah, thanks - that would be a good compact reference.
    – user10907
    Commented Oct 1, 2011 at 3:06

You must log in to answer this question.