Home > Commands A-M > Configuration A

ANSI.SYS


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Defines functions that change display graphics, control cursor movement, and reassign keys. The ANSI.SYS device driver supports ANSI terminal emulation of escape sequences to control your system's screen and keyboard. 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.

This device driver must be loaded by a DEVICE or DEVICEHIGH command in your CONFIG.SYS file.

Note: In this topic bold letters in syntax and ANSI escape sequences indicate text you must type exactly as it appears.


Syntax

DEVICE=[drive:][\path\]ANSI.SYS [[/K] | [/X]] [/R]


Parameters
drive: (v4.00 NT3.5)
Specifies the drive (if other than the current drive) location of the ANSI.SYS file.
\path\ (v4.00 NT3.5)
Specifies the directory location of the ANSI.SYS file.

Switches
/K (v5.0 NT4.0)
Causes ANSI.SYS to treat a 101-key keyboard like an 84-key keyboard. This is equivalent to the command SWITCHES=/K. If you usually use the SWITCHES=/K command, you will need to use the /K switch with ANSI.SYS.
/R (v5.0 NT4.0)
Adjusts line scrolling to improve readability when ANSI.SYS is used with screen-reading programs (which make computers more accessible to people with disabilities).
/X (v5.0 NT4.0)
Remaps extended keys independently on 101-key keyboards.

Related

none.


Notes
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 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[PL;PcH
Cursor Position: Moves the cursor to the specified position (coordinates). If you do not specify a position, the cursor moves to the home position -- the upper-left corner of the screen (line 0, column 0). This escape sequence works the same way as the Cursor Position escape sequence.
ESC[PL;Pcf
Cursor Position: Works the same way as the preceding Cursor Position escape sequence.
ESC[PnA
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[PnB
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[PnC
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[PnD
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[Ps;...;Psm
Set Graphics Mode: Calls the graphics functions specified by the 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.
ESC[=psh
Set Mode: Changes the screen width or type to the mode specified by one of:
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.
ESC[code;string;...p
Set Keyboard Strings: Redefines a keyboard key to a specified string. The parameters for this escape sequence are defined as: IMPORTANT: Some of the values in the table are not valid for all computers. Check your computer's documentation for values that are different.
        Key, Code,  SHIFT-code, CTRL-code, ALT-code
        F1,   0;59,  0;84,       0;94,     0;104
        F2,   0;60,  0;85,       0;95,     0;105
        F3,   0;61,  0;86,       0;96,     0;106
        F4,   0;62,  0;87,       0;97,     0;107
        F5,   0;63,  0;88,       0;98,     0;108

        F6,   0;64,  0;89,       0;99,     0;109
        F7,   0;65,  0;90,      0;100,     0;110
        F8,   0;66,  0;91,      0;101,     0;111
        F9,   0;67,  0;92,      0;102,     0;112
        F10,  0;68,  0;93,      0;103,     0;113

        F11, 0;133, 0;135,      0;137,     0;139
        F12, 0;134, 0;136,      0;138,     0;140
        Key, Code,  SHIFT-code, CTRL-code, ALT-code

        Key (num keypad), Code,   SHIFT-code, CTRL-code, ALT-code
        HOME,              0;71,       55,      0;119,      none
        UP ARROW,          0;72,       56,    (0;141),      none
        PAGE UP,           0;73,       57,      0;132,      none
        LEFT ARROW,        0;75,       52,      0;115,      none
        RIGHT ARROW,       0;77,       54,      0;116,      none

        END,               0;79,       49,      0;117,      none
        DOWN ARROW,        0;80,       50,    (0;145),      none
        PAGE DOWN,         0;81,       51,      0;118,      none
        INSERT,            0;82,       48,    (0;146),      none
        DELETE,            0;83,       46,    (0;147),      none

        ENTER,               13,     none,         10,   (0;166)
        /,                   47,       47,    (0;142),    (0;74)
        *,                   42,  (0;144),     (0;78),      none
        -,                   45,       45,    (0;149),   (0;164)
        +,                   43,       43,    (0;150),    (0;55)

        5,                (0;76),      53,    (0;143),      none
        Key (num keypad), Code,   SHIFT-code, CTRL-code, ALT-code

        Key,         Code,     SHIFT-code, CTRL-code, ALT-code
        HOME         (224;71), (224;71),   (224;119), (224;151)
        UP ARROW     (224;72), (224;72),   (224;141), (224;152)
        PAGE UP      (224;73), (224;73),   (224;132), (224;153)
        LEFT ARROW   (224;75), (224;75),   (224;115), (224;155)
        RIGHT ARROW  (224;77), (224;77),   (224;116), (224;157)

        END          (224;79), (224;79),   (224;117), (224;159)
        DOWN ARROW   (224;80), (224;80),   (224;145), (224;154)
        PAGE DOWN    (224;81), (224;81),   (224;118), (224;161)
        INSERT       (224;82), (224;82),   (224;146), (224;162)
        DELETE       (224;83), (224;83),   (224;147), (224;163)

        PRINT SCREEN     none,     none,       0;114,      none
        PAUSE/BREAK      none,     none,         0;0,      none
        BACKSPACE           8,        8,         127,       (0)
        ENTER              13,     none,          10,       (0)
        TAB                 9,     0;15,     (0;148),   (0;165)

        NULL              0;3,     none,        none,      none
        Key,         Code,     SHIFT-code, CTRL-code, ALT-code

        Key, Code, SHIFT-code, CTRL-code, ALT-code
        A,    97,   65,           1,        0;30
        B,    98,   66,           2,        0;48
        C,    99,   66,           3,        0;46
        D,   100,   68,           4,        0;32
        E,   101,   69,           5,        0;18

        F,   102,   70,           6,        0;33
        G,   103,   71,           7,        0;34
        H,   104,   72,           8,        0;35
        I,   105,   73,           9,        0;23
        J,   106,   74,          10,        0;36

        K,   107,   75,          11,        0;37
        L,   108,   76,          12,        0;38
        M,   109,   77,          13,        0;50
        N,   110,   78,          14,        0;49
        O,   111,   79,          15,        0;24

        P,   112,   80,          16,        0;25
        Key, Code, SHIFT-code, CTRL-code, ALT-code

        Key, Code, SHIFT-code, CTRL-code, ALT-code
        Q,   113,   81,          17,        0;16
        R,   114,   82,          18,        0;19
        S,   115,   83,          19,        0;31
        T,   116,   84,          20,        0;20
        U,   117,   85,          21,        0;22

        V,   118,   86,          22,        0;47
        W,   119,   87,          23,        0;17
        X,   120,   88,          24,        0;45
        Y,   121,   89,          25,        0;21
        Z,   122,   90,          26,        0;44

        1,    49,   33,        none,       0;120
        2,    50,   64,           0,       0;121
        3,    51,   35,        none,       0;122
        4,    52,   36,        none,       0;123

        5,    53,   37,        none,       0;124
        6,    54,   94,          30,       0;125
        Key, Code, SHIFT-code, CTRL-code, ALT-code

        Key, Code, SHIFT-code, CTRL-code, ALT-code
        7,    55,   38,        none,       0;126
        8,    56,   42,        none,       0;126
        9,    57,   40,        none,       0;127
        0,    48,   41,        none,       0;129
        -,    45,   95,          31,       0;130

        =,    61,   43,        none,       0;131
        [,    91,  123,          27,        0;26
        ],    93,  125,          29,        0;27
        \,    92,  124,          28,        0;43
        ;,    59,   58,        none,        0;39

        ',    39,   34,        none,        0;40
        ,,    44,   60,        none,        0;51
        .,    46,   62,        none,        0;52
        /,    47,   63,        none,        0;53
        `,    96,  126,        none,      (0;41)
        Key, Code, SHIFT-code, CTRL-code, ALT-code

Remapping extended keys

If you have a keyboard with 101 keys, you may want to use the /X switch to remap certain extended keys. For example, there are two HOME keys on keyboards with 101 keys: One on the numeric keypad and the other in the block of cursor-control keys. Unless you specify the /X switch, the two HOME keys are treated the same.


Ignoring extended keys

If you have a program that does not correctly interpret input from an enhanced keyboard, use the /K switch with ANSI.SYS. Your enhanced keyboard will then use conventional keyboard functions.


Using both the /X switch and the /K switch

You cannot specify ANSI.SYS with both the /K switch and the /X switch.


Examples

To exchange the backslash and question-mark keys by using literal strings:

    ESC["\";"?"pESC["?";"\"p

To exchange the backslash and question-mark keys by using each key's ASCII value:

    ESC[92;63pESC[63;92p

To restore the backslash and question-mark keys to their original meanings:

    ESC[92;92pESC[63;63p

To specify that MS-DOS display a directory listing when you press the F2 key:

    PROMPT $e[0;60;"dir";13p

To specify a black screen background color and a high-intensity screen foreground color:

    PROMPT $e[1;32;40m$p$g

Errorlevels

none.


Availability
External
DOS
v4.0 v4.01 v4.01A v5.0 v5.0A v5.00.02 v5.001A v5.01 v5.02 v6.0 v6.10 v6.2 v6.21 v6.22 v6.23 v7.00 v7.0R1 v7.10 v8.00
Windows
none
Windows NT
NT3.5 NT4