General Information

[NOTE: "DEC" is Digital Equipment Corporation, I do not know if it is trademarked, but it would be wise to act as though it is. Probably trademarked also are VT100, VT102, VT220 . The ANSI in this document is American National Standards Institute. Specifically, several ANSI standards are referenced in DEC manuals of this era]

This is a quick reference of the input and output sequences for some of the older DEC terminals. While there may be few of these terminals still active (especially the VT100 series), there are still numerous software packages and emulators written for these terminals. This is not a complete list of sequences, but mainly what is needed for normal input/output activity. Printer control and test requests are generally omitted, among other things.

This summary is compiled from the following copyrighted DEC documents:

    - VT100 user guide      - (C) 1981 by DEC
    - VT102 user guide      - (C) 1982 by DEC
    - VT220 pocket programmer guide - (C) 1983 by DEC

*** No guarantee is made regarding completeness or correctness. Aside from my typing inabilities, the manuals themselves are not complete and may not be correct in all details. ***

VT220 control keys

These are the hex codes generated by using the control key with the specified keys. e.g. ^C is to hold down the control key and then press the C key.

 _key___name____hex__            _key___name____hex__

 ^2 ^   null    x00                 ^P  dle     x10
    ^A  soh     x01                 ^Q  dc1     x11
    ^B  stx     x02                 ^R  dc2     x12
    ^C  etx     x03                 ^S  dc3     x13
    ^D  eot     x04                 ^T  dc4     x14
    ^E  enq     x05                 ^U  nak     x15
    ^F  ack     x06                 ^V  syn     x16
    ^G  bel     x07                 ^W  etb     x17
    ^H  bs      x08                 ^X  can     x18
    ^I  ht      x09                 ^Y  em      x19
    ^J  lf      x0A                 ^Z  sub     x1A
    ^K  vt      x0B              ^3 ^[  esc     x1B
    ^L  ff      x0C              ^4 ^/  fs      x1C
    ^M  cr      x0D              ^5 ^]  gs      x1D
    ^N  so      x0E              ^6 ^~  rs      x1E
    ^O  si      x0F              ^7 ^?  us      x1F
                                 ^8     del     x7F

Reading the escape sequence tables

Terminal input sequences

These are sequences generated by the keyboard.


config ____ title _____ sequence

X X X _     up-arrow    esc [ A
X X X _     down-arrow  esc [ B
X X X _     right-arrow esc [ C
X X X _     left-arrow  esc [ D

X X X _     keypad 0    esc O p
X X X _     keypad 1    esc O q
X X X _     keypad 2    esc O r
X X X _     keypad 3    esc O s
X X X _     keypad 4    esc O t
X X X _     keypad 5    esc O u
X X X _     keypad 6    esc O v
X X X _     keypad 7    esc O w
X X X _     keypad 8    esc O x
X X X _     keypad 9    esc O y
X X X _     keypad -    esc O m
X X X _     keypad ,    esc O l
X X X _     keypad .    esc O n
X X X _     enter       esc O M

X X X _     pf1         esc O P
X X X _     pf2         esc O Q
X X X _     pf3         esc O R
X X X _     pf4         esc O S

_ _ X _     find        esc [ 1 ~   
_ _ X _     insert      esc [ 2 ~   
_ _ X _     remove      esc [ 3 ~   
_ _ X _     select      esc [ 4 ~   
_ _ X _     prev scrn   esc [ 5 ~   
_ _ X _     next scrn   esc [ 6 ~

_ _ X _     F6          esc [ 1 7 ~ 
_ _ X _     F7          esc [ 1 8 ~ 
_ _ X _     F8          esc [ 1 9 ~ 
_ _ X _     F9          esc [ 2 0 ~ 
_ _ X _     F10         esc [ 2 1 ~ 
_ _ X _     F11         esc [ 2 3 ~ 
_ _ X _     F12         esc [ 2 4 ~ 
_ _ X _     F13         esc [ 2 5 ~ 
_ _ X _     F14         esc [ 2 6 ~ 
_ _ X _     HELP        esc [ 2 8 ~ 
_ _ X _     DO          esc [ 2 9 ~ 
_ _ X _     F17         esc [ 3 1 ~ 
_ _ X _     F18         esc [ 3 2 ~ 
_ _ X _     F19         esc [ 3 3 ~ 
_ _ X _     F20         esc [ 3 4 ~ 

Terminal output sequences

These are control sequences that the terminal recognizes for sepcial display functions. All special sequences begin with the ESC character. The ESC character has a value of hex 0x1B . Anything that is not part of an escape sequence is printed as literal text on the screen.

config ____ title _____________ sequence

X X X X     UK chars-g0         esc ( A
X X X X     UK graphic-g1       esc ) A
X X X X     ASCII - g0          esc ( B
X X X X     ASCII - g1          esc ) B
_ _ X _     ASCII - g2          esc * B
_ _ X _     ASCII - g3          esc + B
X X X X     DEC charset - g0    esc ( 0
X X X X     DEC charset - g1    esc ) 0
_ _ X _     DEC charset - g2    esc * 0
_ _ X _     DEC charset - g3    esc + 0
_ _ X _     DEC supplement-g0   esc ( <
_ _ X _     DEC supplement-g1   esc ) <
_ _ X _     DEC supplement-g2   esc * <
_ _ X _     DEC supplement-g3   esc + <

X X X X     set rendition       esc [ ** m
        [ codes for rendition ]
X X X X            normal  0
X X X X            bold    1
X X X X            underln 4
X X X X            blink   5
X X X X            inverse 7
_ _ X _            not bold     2 2
_ _ X _            not underln  2 4
_ _ X _            not blink    2 5
_ _ X _            not invers   2 7

X X X _     set mode            esc [ ** h
        [ codes for mode ]
X _ _ _             cursor              1
_ X X X             keyboard lock       2
X _ _ _             column              3
X _ _ _             scrolling           4
_ X X X             insert mode         4
X _ _ _             screen              5
X _ _ _             origin              6
X _ _ _             auto-wrap           7
X _ _ _             auto-repeat         8
X _ _ _             interlace           9
_ X X X             send/receive off    1 2
X X X X             line feed/new line  2 0
X X X _     reset mode          esc [ ** l

_ X X _     set expanded mode   esc [ ? * h
        [ codes for expanded mode ]
_ X X _             cursor              1
_ X X _             ansi/vt52           2
_ X X _             column              3
_ X X _             scrolling           4
_ X X _             reverse screen      5
_ X X _             origin relative     6
_ X X _             auto-wrap           7
_ X X _             auto-repeat         8
_ X X _             print form feed     1 8
_ X X _             print extent        1 9
_ X X _             text cursor         2 5
_ X X _     reset expanded mode esc [ ? * l

X X X _     application keypad  esc =
X X X _     numeric keypad      esc >

X X X _     scroll region       esc [ * ; * r
X X X X     cursor up           esc [ * A
X X X X     cursor down         esc [ * B
X X X X     cursor right        esc [ * C
X X X X     cursor left         esc [ * D
X X X X     cursor posn         esc [ * ; * H
X X X X     cursor posn         esc [ * ; * f
        [NOTE the above two are documented as equivalent ]
X X X X     home                esc [ H
X X X X     home                esc [ f
X X X X     index               esc D
X X X X     reverse index       esc M
X X X X     next line           esc E
X X X _     save                esc 7
X X X _     restore             esc 8
 
X X X X     horiz tab set       esc H
X X X X     horiz tab clear     esc g  
X X X X     horiz tab clear     esc 0 g
X X X X     clear all tabs      esc 3 g
X X X X     reset to init       esc c
_ _ X _     reset to powerup    esc [ ! p

X X X X     erase to EOL        esc [ K
X X X X     erase to EOL        esc [ 0 K
X X X X     erase to BOL        esc [ 1 K
X X X X     erase line          esc [ 2 K
X X X X     erase to end screen esc [ J
X X X X     erase to end screen esc [ 0 J
X X X X     erase to begin scrn esc [ 1 J
X X X X     erase screen        esc [ 2 J

X X _ X     get dev attributes  esc [ * c
X X X X     get dev status      esc [ * n

_ X X X     delete char         esc [ * P
_ X X X     insert line         esc [ * L
_ X X X     delete line         esc [ * M
_ _ X _     insert char         esc [ * @
_ _ X _     erase char          esc [ * X

_ _ X _     VT100 mode          esc [ 6 1 " p
_ _ X _     VT220 mode 8-bit    esc [ 6 2 " p
_ _ X _     VT220 mode 8-bit    esc [ 6 2 ; 0 " p
_ _ X _     VT220 mode 7-bit    esc [ 6 2 ; 1 " p
_ _ X _     VT220 mode 8-bit    esc [ 6 2 ; 2 " p

Usage notes

At the time of these DEC documents, the bullet item on every marketing brochure was to be ANSI-compatible. DEC does list two seperate versions of the standard: ANSI-X3.64-1979 and ANSI-X3.41-1974 . Judging from the dates on these standards, you should be wary of them as regards to whatever the latest standard for video terminal might be. Nowadays, virtually every software and hardware package I see advertises some form of compatibility with the VTxxx series. The ANSI is not always mentioned. The VT220 has become a de-facto standard, as mere ANSI compliance is probably not enough anymore.

There are a number of non-ANSI codes that interact, and have caused me grief in the past. The scrolling region defaults at powerup to the top and bottom of the physical screen. If a smaller region is defined by an application, then the origin-mode setting becomes significant. When the origin-mode is on, then the direct cursor position command uses line numbers that are relative to the scroll-region; i.e. line 1 is the top of the region, not of the screen. Also origin mode prevents the cursor from being moved below the scroll region. If the origin-mode is off, then line numbers are relative to the physical screen and all lines are accessible.

The save cursor command will save only the cursor position, rendition mode, character set, and origin mode.

There are two different forms of the position cursor command (where you specifiy rwo and column). One ends with 'H' and one with 'f'. The manuals do not explain the history, but they do recommend the form ending with 'H'.