ANSI escape sequences affect output to the screen device, giving programs control of the screen's cursor, colors, and display modes. (An escape sequence is one or more characters preceded by the escape character ASCII 1Bh.) When a program writes an escape sequence to the screen, the screen device translates the sequence into its corresponding action, such as positioning the cursor or changing colors.
The following list summarizes the ANSI escape sequences supported by the ANSI.SYS driver. ANSI escape sequences are available only if this driver has been installed. Parameters shown in italic type are ASCII strings representing integers.
ESC[2J |
Clears the entire screen and moves the cursor to upper-left corner (home). |
ESC[K |
Clears the screen from cursor to end of line. |
ESC[rowsA |
Moves the cursor up the specified number of rows without changing the column. If rows is omitted, the cursor moves one row. |
ESC[rowsB |
Moves the cursor down the specified number of rows without changing the column. If rows is omitted, the cursor moves one row. |
ESC[colsC |
Moves the cursor to the right the specified number of columns without changing the row. If cols is omitted, the cursor moves one column. |
ESC[colsD |
Moves the cursor to the left the specified number of columns without changing the row. If cols is omitted, the cursor moves one column. |
ESC[row;colH |
Moves the cursor to an absolute position. For example, ESC[1;1H moves the cursor to the upper-left corner, and ESC[25;80H moves the cursor to the lower-right corner on a 25-character by 80-character screen. Either row or col can be omitted. |
ESC[s |
Saves the current cursor position. |
ESC[u |
Moves the cursor to the position most recently saved by ESC[s. |
ESC[6n |
Returns the current cursor position in the format ESC[row;colR. A program should read the cursor position from standard input immediately after writing the escape sequence. |
ESC[attrm |
Selects from the following character attributes and colors. If more than one attribute or color is specified, values are separated by semicolons. The ability to display certain attributes and colors depends on the screen device. |
Value |
Attribute |
0 |
40 columns by 25 rows, 16-color text (color burst off) |
1 |
40 columns by 25 rows, 16-color text |
2 |
80 columns by 25 rows, 16-color text (color burst off) |
3 |
80 columns by 25 rows, 16-color text |
4 |
320 pixels by 200 pixels, 4-color graphics |
5 |
320 pixels by 200 pixels, 4-color graphics (color burst off) |
6 |
640 pixels by 200 pixels, 2-color graphics |
7 |
Enable line wrap |
14 |
640 pixels by 200 pixels, 16-color graphics (EGA/VGA, MS-DOS version 4.0 and later) |
15 |
640 pixels by 350 pixels, 2-color graphics (EGA/VGA, MS-DOS version 4.0 and later) |
16 |
640 pixels by 350 pixels, 16-color graphics (EGA/VGA, MS-DOS version 4.0 and later) |
17 |
640 pixels by 480 pixels, 2-color graphics (MCGA/VGA, MS-DOS version 4.0 and later) |
18 |
640 pixels by 480 pixels, 16-color graphics (VGA, MS-DOS version 4.0 and later) |
19 |
320 pixels by 200 pixels, 256-color graphics (MCGA/VGA, MS-DOS version 4.0 and later) |