These sequences define functions that change display graphics, control cursor movement, and reassign keys.
ANSI escape sequence is a sequence of ASCII characters, the first two of which are the ASCII "Escape" character 27 (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.
| Esc[Line;ColumnH
Esc[Line;Columnf | Cursor Position:
Moves the cursor to the specified position (coordinates).
If you do not specify a position, the cursor moves to the home position at the upper-left corner of the screen (line 0, column 0). This escape sequence works the same way as the following Cursor Position escape sequence. |
| Esc[ValueA | Cursor Up:
Moves the cursor up by the specified number of lines without changing columns. If the cursor is already on the top line, ANSI.SYS ignores this sequence. |
| Esc[ValueB | Cursor Down:
Moves the cursor down by the specified number of lines without changing columns. If the cursor is already on the bottom line, ANSI.SYS ignores this sequence. |
| Esc[ValueC | Cursor Forward:
Moves the cursor forward by the specified number of columns without changing lines. If the cursor is already in the rightmost column, ANSI.SYS ignores this sequence. |
| Esc[ValueD | Cursor Backward:
Moves the cursor back by the specified number of columns without changing lines. If the cursor is already in the leftmost column, ANSI.SYS ignores this sequence. |
| Esc[s | Save Cursor Position:
Saves the current cursor position. You can move the cursor to the saved cursor position by using the Restore Cursor Position sequence. |
| Esc[u | Restore Cursor Position:
Returns the cursor to the position stored by the Save Cursor Position sequence. |
| Esc[2J | Erase Display:
Clears the screen and moves the cursor to the home position (line 0, column 0). |
| Esc[K | Erase Line:
Clears all characters from the cursor position to the end of the line (including the character at the cursor position). |
| Esc[Value;...;Valuem | 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[=Valueh | Set Mode:
Changes the screen width or type to the mode specified by one of the following values:
| Screen resolution |
| --- |
| 0 | 40 x 25 monochrome (text) |
| 1 | 40 x 25 color (text) |
| 2 | 80 x 25 monochrome (text) |
| 3 | 80 x 25 color (text) |
| 4 | 320 x 200 4-color (graphics) |
| 5 | 320 x 200 monochrome (graphics) |
| 6 | 640 x 200 monochrome (graphics) |
| 7 | Enables line wrapping |
| 13 | 320 x 200 color (graphics) |
| 14 | 640 x 200 color (16-color graphics) |
| 15 | 640 x 350 monochrome (2-color graphics) |
| 16 | 640 x 350 color (16-color graphics) |
| 17 | 640 x 480 monochrome (2-color graphics) |
| 18 | 640 x 480 color (16-color graphics) |
| 19 | 320 x 200 color (256-color graphics) |
|
| Esc[=Valuel | 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). |
| Esc[Code;String;...p | Set Keyboard Strings:
Redefines a keyboard key to a specified string.
The parameters for this escape sequence are defined as follows:
Code is one or more of the values listed in the following table. These values represent keyboard keys and key combinations. When using these values in a command, you must type the semicolons shown in this table in addition to the semicolons required by the escape sequence. The codes in parentheses are not available on some keyboards. ANSI.SYS will not interpret the codes in parentheses for those keyboards unless you specify the /X switch in the DEVICE command for ANSI.SYS.
String is either the ASCII code for a single character or a string contained in quotation marks. For example, both 65 and "A" can be used to represent an uppercase A.
IMPORTANT: Some of the values in the following table are not valid for all computers. Check your computer's documentation for values that are different.
(ANSI Escape codes)
These sequences define functions that change display graphics, control cursor movement, and reassign keys.
ANSI escape sequence is a sequence of ASCII characters, the first two of which are the ASCII "Escape" character 27 (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.
Information is also available on VT100 / VT52 ANSI escape sequences.
| Esc[Line;ColumnH
Esc[Line;Columnf | Cursor Position:
Moves the cursor to the specified position (coordinates).
If you do not specify a position, the cursor moves to the home position at the upper-left corner of the screen (line 0, column 0). This escape sequence works the same way as the following Cursor Position escape sequence. | | Esc[ValueA | Cursor Up:
Moves the cursor up by the specified number of lines without changing columns. If the cursor is already on the top line, ANSI.SYS ignores this sequence. | | Esc[ValueB | Cursor Down:
Moves the cursor down by the specified number of lines without changing columns. If the cursor is already on the bottom line, ANSI.SYS ignores this sequence. | | Esc[ValueC | Cursor Forward:
Moves the cursor forward by the specified number of columns without changing lines. If the cursor is already in the rightmost column, ANSI.SYS ignores this sequence. | | Esc[ValueD | Cursor Backward:
Moves the cursor back by the specified number of columns without changing lines. If the cursor is already in the leftmost column, ANSI.SYS ignores this sequence. | | Esc[s | Save Cursor Position:
Saves the current cursor position. You can move the cursor to the saved cursor position by using the Restore Cursor Position sequence. | | Esc[u | Restore Cursor Position:
Returns the cursor to the position stored by the Save Cursor Position sequence. | | Esc[2J | Erase Display:
Clears the screen and moves the cursor to the home position (line 0, column 0). | | Esc[K | Erase Line:
Clears all characters from the cursor position to the end of the line (including the character at the cursor position). | | Esc[Value;...;Valuem | 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[=Valueh | Set Mode:
Changes the screen width or type to the mode specified by one of the following values: | Screen resolution | | --- | | 0 | 40 x 25 monochrome (text) | | 1 | 40 x 25 color (text) | | 2 | 80 x 25 monochrome (text) | | 3 | 80 x 25 color (text) | | 4 | 320 x 200 4-color (graphics) | | 5 | 320 x 200 monochrome (graphics) | | 6 | 640 x 200 monochrome (graphics) | | 7 | Enables line wrapping | | 13 | 320 x 200 color (graphics) | | 14 | 640 x 200 color (16-color graphics) | | 15 | 640 x 350 monochrome (2-color graphics) | | 16 | 640 x 350 color (16-color graphics) | | 17 | 640 x 480 monochrome (2-color graphics) | | 18 | 640 x 480 color (16-color graphics) | | 19 | 320 x 200 color (256-color graphics) |
| | Esc[=Valuel | 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). | | Esc[Code;String;...p | Set Keyboard Strings:
Redefines a keyboard key to a specified string.
The parameters for this escape sequence are defined as follows:
Code is one or more of the values listed in the following table. These values represent keyboard keys and key combinations. When using these values in a command, you must type the semicolons shown in this table in addition to the semicolons required by the escape sequence. The codes in parentheses are not available on some keyboards. ANSI.SYS will not interpret the codes in parentheses for those keyboards unless you specify the /X switch in the DEVICE command for ANSI.SYS.
String is either the ASCII code for a single character or a string contained in quotation marks. For example, both 65 and "A" can be used to represent an uppercase A.
IMPORTANT: Some of the values in the following table are not valid for all computers. Check your computer's documentation for values that are different.
http://ascii-table.com/ansi-escape-sequences.php