|
Cursor Up |
{ESC}[<row>A Moves the cursor up the specified number of rows without changing the column. |
|
<row> is a number from 1 through 24 that specifies how many rows the cursor is to be moved up. If you omit <row>, DOS moves the cursor up one row. |
examples |
{ESC}[13A |
Move the cursor up 13 rows |
|
{ESC}[A |
Move the cursor up 1 row |
|
Cursor Down |
{ESC}[<row>B Moves the cursor down the specified number of rows without changing the column. |
|
<row> is a number from 1 through 24 that specifies how many rows the cursor is to be moved down. If you omit <row>, DOS moves the cursor down one row. |
examples |
{ESC}[8B |
Move the cursor down eight rows. |
|
{ESC}[B |
Move the cursor down one row. |
|
Cursor Right |
{ESC}[<col>C Moves the cursor right the specified number of columns without changing the row. |
|
<col> is a number from 1 through 79 that specifies how many columns that cursor is to be moved right. If you omit <col>, DOS moves the cursor right one column. |
examples |
{ESC}[40C |
Move the cursor right 40 columns. |
|
{ESC}[C |
Move the cursor right one column. |
|
Cursor Left |
{ESC}[<col>D Moves the cursor left the specified number of columns without changing the row. |
|
<col> is a number from 1 through 79 that specifies how many columns the cursor is to be moved left. If you omit <col>, DOS moves the cursor left one column. |
examples |
{ESC}10[D |
Move the cursor left ten columns. |
|
{ESC}[D |
Move the cursor left one column. |
|
Move Cursor |
{ESC}[<row>;<col>H or {ESC}<row>;<col>f Moves the cursor to the specified row and column. |
|
<row> is a number from 1 through 25 that specifies the row to which the cursor is to be moved. If you omit <row>, DOS moves the cursor to row 1. To omit <row> but specify <col>, enter the semicolon to show the <row> is omitted. <col> is a number from 1 through 80 that specifies the column to which the cursor is to be moved. If you omit <col>, DOS moves the cursor to column 1. If you omit both <row> and <col>, DOS moves the cursor to the home position (row 1, column 1--the upper left corner of the screen). |
examples |
{ESC}[;10H |
Move the cursor to column 10, row 1. |
|
{ESC}[H |
Move the cursor to row 1, column 1. |
|
Save Cursor Position |
{ESC}[s Stores the current row and column position of the cursor. |
|
You can move the cursor to this location with a Restore Cursor Position command. |
examples |
{ESC}[s |
Save the current cursor position. |
|
Report Cursor Position |
{ESC}[6n Returns the current row and column position of the cursor in the form {ESC}[<row>;<col>R. |
|
<row> is a number from 1 through 25 that specifies the row where the cursor is located. <col> is a number from 1 through 80 that specifies the column where the cursor is located. |
examples |
{ESC}[6n |
Report the current cursor position. |
|
Restore Cursor Position |
{ESC}[u Moves the cursor to the row and column position most recently saved with a Save Cursor Position command. |
examples |
{ESC}[u |
Move the cursor the row and column last saved with a Save Cursor Position command. |
|
|
Erase Display |
{ESC}[2J Erases the entire display (equivalent to the DOS Clear Screen or cls command). |
examples |
{ESC}[2J |
Erase the screen. |
|
Erase to End of Line |
{ESC}[K Erases from the current cursor position through the end of the line that contains the cursor. |
examples |
{ESC}[K |
Erase from the cursor to the end of the line. |
|
|
Set Attribute |
{ESC}[<attr>m Turns on a characteristic or attribute of the display, such as high intensity, blink, or foreground and background color. |
|
<attr> specifies the display attribute to be turned on. More than one attribute can be specified by using a semicolon to separate the attribute numbers. <attr> can be any of the following:
Text Attribute | Value |
---|
None | 0 |
High Intensity (bold) | 1 | Underline (monochrome display only) | 4 |
Blink | 5 | Reverse | 7 | Invisible | 8 |
| | Color Attribute | Foreground Value | Background Value |
---|
Black | 30 | 40 | Red | 31 | 41 |
Green | 32 | 42 | Yellow | 33 | 43 |
Blue | 34 | 44 | Magenta | 35 | 45 |
Cyan | 36 | 46 | White | 37 | 47 |
|
If you omit <attr>, all attributes are turned off (equivalent to specifying <attr> as 0). |
examples |
{ESC}[1m |
High intensity. |
|
{ESC}[1;5m |
High intensity and blink. |
|
{ESC}[30;46m |
Black foreground, cyan background. |
|
{ESC}[m |
Turn off all attributes. |
|
{ESC}[0m |
Turn off all attributes. |
|
{ESC}[0;1;36m |
Turn off all attributes, then turn on high-intensity cyan foreground. |
|
Set Display Mode |
{ESC}[=<mode>h Sets the width and color capability of the display (generally equivalent to the DOS MODE command). This command can also be used to cause lines longer than 80 characters to be broken at the 80th character and continued on the next line, rather than truncated at the 80th column; this is called line wrap. It can be turned off with the Turn Off Line Wrap command. Note the equal sign (=) that precedes <mode>. |
|
<mode> specifies the display mode. It can be one of the following:
Display Mode | Value |
---|
40 columns by 25 rows, black and white | 0 |
40 columns by 25 rows, color on | 1 | 80 columns by 25 rows, black and white | 2 |
80 columns by 25 rows, color on | 3 | 320 by 200 graphics, color on | 4 |
320 by 200 graphics, black and white | 5 | 640 by 200 graphics, black and white | 6 | Turn on line wrap | 7 |
|
|
examples |
{ESC}[=1h |
Set the display to 40 by 25 color on. |
|
{ESC}[=7h |
Continued lines longer than 80 characters, don't truncate them. |
|
Turn Off Line Wrap |
{ESC}[=7l Causes lines longer than 80 characters to be truncated at the 80th character, rather than continued to the next line. |
examples |
{ESC}[=7l |
Truncate lines longer than 80 characters. |
|
|
Define Key |
{ESC}[<key code>;<result>p Assigns one or more characters to be produced when you press a key. |
|
<key code> specifies the key to be defined. If the key is one of the standard ASCII characters, <key code> is a number from 1 through 127. If the key is a function key, keypad key, or a combination of the <Shift>, <Ctrl>, or <Alt> key and another key, <key code> is two numbers separated by a semicolon and can be found in the ANSI.SYS key code table. <result> is the character or characters to be produced when a key is pressed. It can be specified as an ASCII code, an ANSI.SYS key code, a string enclosed in quotation marks, or any combination of codes and strings separated by semicolons. To restore a key to its original meaning, enter a Define Key command that sets <result> equal to <key code>. |
examples |
{ESC}[126;92p |
Redefine the tilde <~> key as a backslash <\>. |
|
{ESC}[126;126p |
Restore the tilde <~> key to its original meaning. |
|
{ESC}[0;112;"dir|sort";13p |
Redefine <Alt><F9> as a Directory command piped to a Sort command, followed by a Carriage Return. |
|
{ESC}[0;112;0;112p |
Restore <Alt><F9> to its original meaning. |
Before using escape seqences, ANSI.SYS must be named as a device driver in the CONFIG system file.
Because ANSI.SYS commands control the console device, they must be typed at the keyboard or sent to the display.
SCREEN.BAT demonstrates some Display Attribute and Cursor commands.
Type the line below in a COMMAND.COM window to change the DOS command prompt.
No comments:
Post a Comment