分类: BSD
2008-11-21 13:38:25
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.
Query Device Code[c
Report Device Code
response from
the device.
Report Device Code[{code}0c
Query Device
Code
request.
Query Device Status[5n
Report Device Status
response
from the device.
Report Device OK[0n
Query Device
Status
request; indicates that device is functioning
correctly.
Report Device Failure[3n
Query Device
Status
request; indicates that device is functioning
improperly.
Query Cursor Position[6n
Report Cursor Position
response
from the device.
Report Cursor Position[{ROW};{COLUMN}R
Query Cursor
Position
request; reports current cursor position.
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 Devicec
Enable Line Wrap[7h
Disable Line Wrap[7l
Font Set G0(
Font Set G1)
Cursor Home[{ROW};{COLUMN}H
[H
),
the cursor will move to the home position, at the upper left
of the screen.
Cursor Up[{COUNT}A
Cursor Down[{COUNT}B
Cursor Forward[{COUNT}C
Cursor Backward[{COUNT}D
Force Cursor Position[{ROW};{COLUMN}f
Cursor Home
.
Save Cursor[s
Unsave Cursor[u
Save Cursor
.
Save Cursor & Attrs7
Restore Cursor & Attrs8
Save Cursor
.
Scroll Screen[r
Scroll Screen[{start};{end}r
{start}
to row
{end}
.
Scroll DownD
Scroll UpM
Set TabH
Clear Tab[g
Clear All Tabs[3g
Erase End of Line[K
Erase Start of Line[1K
Erase Line[2K
Erase Down[J
Erase Up[1J
Erase Screen[2J
Print Screen[i
Print Line[1i
Stop Print Log[4i
Start Print Log[5i
Set Key Definition[{key};"{string}"p
{key}
indicates the key by its ASCII value in decimal.
Set Attribute Mode[{attr1};...;{attrn}m
0 Reset all attributes
1 Bright
2 Dim
4 Underscore
5 Blink
7 Reverse
8 Hidden
Foreground Colours
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
Background Colours
40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White