This document describes how to control a VT100 terminal. The entries are of the form "name, description, escape code".
The name isn't important, and the description is just to help you find what you're looking for. What you have to do is send the "escape code" to the screen. These codes are often several characters long, but they all begin with ^[
. This isn't the two characters ^
and [
, but rather a representation of the ASCII code ESC
(which is why these are called escape codes).
ESC
has the decimal value 27 and should be sent before the rest of the code, which is simply an ASCII string.
As an example of how to use this information, here's how to clear the screen in C, using the VT100 escape codes:
#define ASCII_ESC 27
printf( "%c[2J", ASCII_ESC );
or:
puts( "\033[2J" );
Name | Description | Esc Code |
---|---|---|
setnl LMN |
Set new line mode | ESC [ 20h |
setappl DECCKM |
Set cursor key to application | ESC [ ?1h |
setansi DECANM |
Set ANSI (versus VT52) | none |
setcol DECCOLM |
Set number of columns to 132 | ESC [ ?3h |
setsmooth DECSCLM |
Set smooth scrolling | ESC [ ?4h |
setrevscrn DECSCNM |
Set reverse video on screen | ESC [ ?5h |
setorgrel DECOM |
Set origin to relative | ESC [ ?6h |
setwrap DECAWM |
Set auto-wrap mode | ESC [ ?7h |
setrep DECARM |
Set auto-repeat mode | ESC [ ?8h |
setinter DECINLM |
Set interlacing mode | ESC [ ?9h |
setlf LMN |
Set line feed mode | ESC [ 20l |
setcursor DECCKM |
Set cursor key to cursor | ESC [ ?1l |
setvt52 DECANM |
Set VT52 (versus ANSI) | ESC [ ?2l |
resetcol DECCOLM |
Set number of columns to 80 | ESC [ ?3l |
setjump DECSCLM |
Set jump scrolling | ESC [ ?4l |
setnormscrn DECSCNM |
Set normal video on screen | ESC [ ?5l |
setorgabs DECOM |
Set origin to absolute | ESC [ ?6l |
resetwrap DECAWM |
Reset auto-wrap mode | ESC [ ?7l |
resetrep DECARM |
Reset auto-repeat mode | ESC [ ?8l |
resetinter DECINLM |
Reset interlacing mode | ESC [ ?9l |
altkeypad DECKPAM |
Set alternate keypad mode | ESC = |
numkeypad DECKPNM |
Set numeric keypad mode | ESC > |
setukg0 | Set United Kingdom G0 character set | ESC ( A |
setukg1 | Set United Kingdom G1 character set | ESC ) A |
setusg0 | Set United States G0 character set | ESC ( B |
setusg1 | Set United States G1 character set | ESC ) B |
setspecg0 | Set G0 special chars. & line set | ESC ( 0 |
setspecg1 | Set G1 special chars. & line set | ESC ) 0 |
setaltg0 | Set G0 alternate character ROM | ESC ( 1 |
setaltg1 | Set G1 alternate character ROM | ESC ) 1 |
setaltspecg0 | Set G0 alt char ROM and spec. graphics | ESC ( 2 |
setaltspecg1 | Set G1 alt char ROM and spec. graphics | ESC ) 2 |
setss2 SS2 |
Set single shift 2 | ESC N |
setss3 SS3 |
Set single shift 3 | ESC O |
modesoff SGR0 |
Turn off character attributes | ESC [ m |
modesoff SGR0 |
Turn off character attributes | ESC [ 0m |
bold SGR1 |
Turn bold mode on | ESC [ 1m |
lowint SGR2 |
Turn low intensity mode on | ESC [ 2m |
underline SGR4 |
Turn underline mode on | ESC [ 4m |
blink SGR5 |
Turn blinking mode on | ESC [ 5m |
reverse SGR7 |
Turn reverse video on | ESC [ 7m |
invisible SGR8 |
Turn invisible text mode on | ESC [ 8m |
setwin DECSTBM |
Set top and bottom line of a window | ESC [ v ; v r |
cursorup(n) CUU |
Move cursor up n lines | ESC [ n A |
cursordn(n) CUD |
Move cursor down n lines | ESC [ n B |
cursorrt(n) CUF |
Move cursor right n lines | ESC [ n C |
cursorlf(n) CUB |
Move cursor left n lines | ESC [ n D |
cursorhome | Move cursor to upper left corner | ESC [ H |
cursorhome | Move cursor to upper left corner | ESC [ ;H |
cursorpos(v,h) CUP |
Move cursor to screen location v,h | ESC [ v ; h H |
hvhome | Move cursor to upper left corner | ESC [ f |
hvhome | Move cursor to upper left corner | ESC [ ;f |
hvpos(v,h) CUP |
Move cursor to screen location v,h | ESC [ v ; h f |
index IND |
Move/scroll window up one line | ESC D |
revindex RI |
Move/scroll window down one line | ESC M |
nextline NEL |
Move to next line | ESC E |
savecursor DECSC |
Save cursor position and attributes | ESC 7 |
restorecursor DECSC |
Restore cursor position and attributes | ESC 8 |
tabset HTS |
Set a tab at the current column | ESC H |
tabclr TBC |
Clear a tab at the current column | ESC [ g |
tabclr TBC |
Clear a tab at the current column | ESC [ 0g |
tabclrall TBC |
Clear all tabs | ESC [ 3g |
dhtop DECDHL |
Double-height letters, top half | ESC # 3 |
dhbot DECDHL |
Double-height letters, bottom half | ESC # 4 |
swsh DECSWL |
Single width, single height letters | ESC # 5 |
dwsh DECDWL |
Double width, single height letters | ESC # 6 |
cleareol EL0 |
Clear line from cursor right | ESC [ K |
cleareol EL0 |
Clear line from cursor right | ESC [ 0K |
clearbol EL1 |
Clear line from cursor left | ESC [ 1K |
clearline EL2 |
Clear entire line | ESC [ 2K |
cleareos ED0 |
Clear screen from cursor down | ESC [ J |
cleareos ED0 |
Clear screen from cursor down | ESC [ 0J |
clearbos ED1 |
Clear screen from cursor up | ESC [ 1J |
clearscreen ED2 |
Clear entire screen | ESC [ 2J |
devstat DSR |
Device status report | ESC 5 n |
termok DSR |
(Response) terminal is OK | ESC 0 n |
termnok DSR |
(Response) terminal is not OK | ESC 3 n |
getcursor DSR |
Get cursor position | ESC 6 n |
cursorpos CPR |
(Response) cursor is at v,h | ESC v ; h R |
ident DA |
Identify what terminal type | ESC [ c |
ident DA |
Identify what terminal type (another) | ESC [ 0c |
gettype DA |
(Response) terminal type code n | ESC [ ?1; n 0c |
reset RIS |
Reset terminal to initial state | ESC c |
align DECALN |
Screen alignment display | ESC # 8 |
testpu DECTST |
Confidence power up test | ESC [ 2;1y |
testlb DECTST |
Confidence loopback test | ESC [ 2;2y |
testpurep DECTST |
Repeat power up test | ESC [ 2;9y |
testlbrep DECTST |
Repeat loopback test | ESC [ 2;10y |
ledsoff DECLL0 |
Turn off all four leds | ESC [ 0q |
led1 DECLL1 |
Turn on LED #1 | ESC [ 1q |
led2 DECLL2 |
Turn on LED #2 | ESC [ 2q |
led3 DECLL3 |
Turn on LED #3 | ESC [ 3q |
led4 DECLL4 |
Turn on LED #4 | ESC [ 4q |
Name | Description | Esc Code |
---|---|---|
setansi | Enter/exit ANSI mode (VT52) | ESC < |
altkeypad | Enter alternate keypad mode | ESC = |
numkeypad | Exit alternate keypad mode | ESC > |
setgr | Use special graphics character set | ESC F |
resetgr | Use normal US/UK character set | ESC G |
cursorup | Move cursor up one line | ESC A |
cursordn | Move cursor down one line | ESC B |
cursorrt | Move cursor right one char | ESC C |
cursorlf | Move cursor left one char | ESC D |
cursorhome | Move cursor to upper left corner | ESC H |
cursorpos(v,h) | Move cursor to v,h location | ESC vh |
revindex | Generate a reverse line-feed | ESC I |
cleareol | Erase to end of current line | ESC K |
cleareos | Erase to end of screen | ESC J |
ident | Identify what the terminal is | ESC Z |
identresp | Correct response to ident | ESC /Z |
These are sent from the terminal back to the computer when the particular key is pressed. Note that the numeric keypad keys send different codes in numeric mode than in alternate mode. See escape codes above to change keypad mode.
PF1 | ESC O P |
PF2 | ESC O Q |
PF3 | ESC O R |
PF4 | ESC O S |
Reset | Set | |
---|---|---|
Up | ESC A |
ESC O A |
Down | ESC B |
ESC O B |
Right | ESC C |
ESC O C |
Left | ESC D |
ESC O D |
Keypad Key | Numeric | Alternate |
---|---|---|
0 | 0 |
ESC O p |
1 | 1 |
ESC O q |
2 | 2 |
ESC O r |
3 | 3 |
ESC O s |
4 | 4 |
ESC O t |
5 | 5 |
ESC O u |
6 | 6 |
ESC O v |
7 | 7 |
ESC O w |
8 | 8 |
ESC O x |
9 | 9 |
ESC O y |
- (minus) | - |
ESC O m |
, (comma) | , |
ESC O l |
. (period) | . |
ESC O n |
Enter | ^M |
ESC O M |
Author: | Alexandr Shavykin |
---|---|
Contact: | 0.delameter@gmail.com |
Date: | 23-Jul-24 14:25:30 PDT |
Origin: | https://www.csie.ntu.edu.tw/~r92094/c++/VT100.html |