Ansi Codes define functions that change display graphics, control cursor movement, and reassign keys. An ANSI escape sequence is a sequence of ASCII characters, the first two of which are the escape character (1Bh) and the left-bracket character (5Bh). The character or characters following the escape and left-bracket characters specify an alphanumeric code that controls a keyboard or display function. ANSI escape sequences distinguish between uppercase and lowercase letters; for example, "A" and "a" have completely different meanings.
Parameters used in ANSI escape sequences:
Pn - Numeric parameter. Specifies a decimal number.
Ps - Selective parameter. Specifies a decimal number that you use to select a function. You can specify more than one function by separating the parameters with semicolons.
PL - Line parameter. Specifies a decimal number that represents one of the lines on your display or on another device.
Pc - Column parameter. Specifies a decimal number that represents one of the columns on your screen or on another device.
ANSI escape sequences for cursor movement, graphics, and keyboard settings:
In the following list of ANSI escape sequences, the abbreviation ESC represents the ASCII escape character 27 (1Bh), which appears at the beginning of each escape sequence.
ESC[Ps;...;Psm - Set Graphics Mode: Calls the graphics functions specified by the following values. These specified functions remain active until the next occurrence of this escape sequence. Graphics mode changes the colors and attributes of text (such as bold and underline) displayed on the screen.
Text attributes
0 All attributes off
1 Bold on
4 Underscore (on monochrome display adapter only)
5 Blink on
7 Reverse video on
8 Concealed on
Foreground colors
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
Background colors
40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White
Parameters 30 through 47 meet the ISO 6429 standard.
ESC[=psh - Set Mode: Changes the screen width or type to the mode specified by one of the following values:
0 40 x 148 x 25 monochrome (text)
1 40 x 148 x 25 color (text)
2 80 x 148 x 25 monochrome (text)
3 80 x 148 x 25 color (text)
4 320 x 148 x 200 4-color (graphics)
5 320 x 148 x 200 monochrome (graphics)
6 640 x 148 x 200 monochrome (graphics)
7 Enables line wrapping
13 320 x 148 x 200 color (graphics)
14 640 x 148 x 200 color (16-color graphics)
15 640 x 148 x 350 monochrome (2-color graphics)
16 640 x 148 x 350 color (16-color graphics)
17 640 x 148 x 480 monochrome (2-color graphics)
18 640 x 148 x 480 color (16-color graphics)
19 320 x 148 x 200 color (256-color graphics)
ESC[=Psl - Reset Mode: Resets the mode by using the same values that Set Mode uses, except for 7, which disables line wrapping. The last character in this escape sequence is a lowercase L.