VT100 Terminal Control
VT100 Terminal Control
Many computer terminals and terminal emulators support colour and cursor control through a system of escape sequences. One such standard is commonly referred to as ANSI Colour. Several terminal specifications are based on the ANSI colour standard, including VT100. The following is a partial listing of the VT100 control set. represents the ASCII "escape" character, 0x1B. Bracketed tags represent modifiable decimal parameters; eg. {ROW} would be replaced by a row number.
<ESC>
Device Status
The following codes are used for reporting terminal/display settings, and vary depending on the implementation:
Query Device Code <ESC>[c
Generated by the device in response to a Query Device Status request; indicates that device is functioning correctly.
Report Device Failure <ESC>[3n
Generated by the device in response to a Query Device Status request; indicates that device is functioning improperly.
Query Cursor Position <ESC>[6n
Generated by the device in response to a Query Cursor Position request; reports current cursor position.
www.termsys.demon.co.uk/vtansi.htm
1/5
04/08/2011
Terminal Setup
The h and l codes are used for setting terminal/display mode, and vary depending on the implementation. Line Wrap is one of the few setup codes that tend to be used consistently:
Reset Device <ESC>c
Text wraps to next line if longer than the length of the display area.
Disable Line Wrap <ESC>[7l
Fonts
Some terminals support multiple fonts: normal/bold, swiss/italic, etc. There are a variety of special codes for certain terminals; the following are fairly standard:
Font Set G0 <ESC>(
Cursor Control
Cursor Home <ESC>[{ROW};{COLUMN}H
Sets the cursor position where subsequent text will begin. If no row/column parameters are provided (ie. <ESC>[H), the cursor will move to the home position, at the upper left of the screen.
Cursor Up <ESC>[{COUNT}A
<ESC>[{COUNT}D
2/5
04/08/2011
Scrolling
Scroll Screen <ESC>[r
Tab Control
Set Tab <ESC>H
04/08/2011
Erasing Text
Erase End of Line <ESC>[K
Erases from the current cursor position to the end of the current line.
Erase Start of Line <ESC>[1K
Erases from the current cursor position to the start of the current line.
Erase Line <ESC>[2K
Erases the screen from the current line down to the bottom of the screen.
Erase Up <ESC>[1J
Erases the screen from the current line up to the top of the screen.
Erase Screen <ESC>[2J
Erases the screen with the background colour and moves the cursor to home.
Printing
Some terminals support local printing:
Print Screen <ESC>[i
Disable log.
Start Print Log <ESC>[5i
Define Key
Set Key Definition <ESC>[{key};"{string}"p
Associates a string of text to a keyboard key. {key} indicates the key by its
www.termsys.demon.co.uk/vtansi.htm 4/5
04/08/2011
Sets multiple display attribute settings. The following lists standard attributes:
0 1 2 4 5 7 8 Reset all attributes Bright Dim Underscore Blink Reverse Hidden Foreground Colours Black Red Green Yellow Blue Magenta Cyan White Background Colours Black Red Green Yellow Blue Magenta Cyan White
30 31 32 33 34 35 36 37
40 41 42 43 44 45 46 47
[ Top | Status | Setup | Fonts | Cursor | Scrolling | Tabs | Erasing | Printing | Keyboard | Colours ]
www.termsys.demon.co.uk/vtansi.htm
5/5