How to use ansi.sys program

Time:2021-12-8

Ansi.sys is a very useful device driver in MS-DOS. Using it, we can achieve unexpected display effects. So how should it be used? Let’s introduce it.
Note: in this section, syntax and   ANSI   Uppercase letters in the escape sequence must be typed as is.
ANSI.SYS   A series of functions are defined, which are used to change the display graphics, control cursor movement and key redefinition, ANSI. Sys   The device driver supports escape sequences   ANSI   Terminal simulation to control the screen and keyboard of the system.
The device driver must be located by   CONFIG.SYS   The device or devicehigh command in the file is loaded.
grammar
DEVICE(HIGH)=[   Driver  :] [   route  ] ANSI.SYS   [/X]   [/K]   [/R]
parameter
[   Driver  :] [   route  ]
appoint   ANSI.SYS   The location of the file.
option
/X

Remapping   one hundred and one   An extension key other than the keyboard.
/K

send   ANSI.SYS   File will   one hundred and one   Keyboard as   eighty-four   Keyboard, which is equivalent to commands   SWITCHES=/K。 If you usually use   Switches = / K command, then ansi.sys is used   When, you need to use the option  / K。
/R

When   ANSI.SYS   When used with a screen reading program that makes it easier for people with disabilities to use the computer, this option is used to adjust the scrolling of lines to improve readability.
stay   ANSI   Parameters used in escape sequence:

A numeric parameter that specifies a decimal number.

Optional parameters. Specifies a decimal number for selecting functions. You can specify more than one function. You must use a semicolon   (;)   Separate parameters.
PL

Row parameters. Specifies a decimal number that represents a line on a display or other device.
Pc

Column parameters. Specifies a decimal number that represents a column on the screen or other device.
ANSI   Settings about cursor movement, graphics and keyboard in escape sequence:
Below   ANSI   List of escape sequences, abbreviations   ESC   representative   ASCII escape character   27 (1bH), which is located at the beginning of each escape sequence.
ESC[PL;PcH

Cursor position: move the cursor to the specified position (coordinate). If the position is not specified, the cursor will move to the starting position, that is, the upper left corner of the screen (0)   Row, 0   Column).
The escape sequence works in the same way as the cursor position escape sequence below.
ESC[PL;Pcf

Cursor position: works in the same way as the previous cursor position escape sequence.
ESC[PnA

Move cursor up: moves the cursor up a specified number of rows without changing the column. If the cursor is already on the first line, then   ANSI.SYS   Ignore this sequence.
ESC[PnB

Move cursor down: moves the cursor down the specified number of rows without changing the column. If the cursor is already on the last line, then   ANSI.SYS   Ignore this sequence.
ESC[PnC

Move cursor right: move the cursor to the right by the specified number of columns without changing rows. If the cursor is already in the rightmost column, the   ANSI.SYS   Ignore this sequence.
ESC[PnD

Move cursor left: move the cursor to the left by the specified number of columns without changing rows. If the cursor is already in the leftmost column, the   ANSI.SYS   Ignore this sequence.
ESC[s

Save cursor position: saves the current cursor position. Using the restore cursor position sequence, you can move the cursor to a saved cursor position.
ESC[u

Restore cursor position: returns the cursor position to the position stored in save cursor position.
ESC[2J

Clear display: clear the screen and move the cursor position to the starting position (0   Row, 0   Column).
ESC[K

Clear line: clears all characters from the cursor position to the end of the line(   Including characters at the cursor position).
ESC[Ps;…;Psm

Set graphics mode: call the graphics functions specified by the following values, and these specified functions remain active until the sequence occurs again. Graphic mode changes the color and text (such as bold and underline fonts) properties displayed on the screen.
Text properties
Value function
————————————

0   No attribute
one   Blackbody
four   Underline font (monochrome display adapter only)
five   Flashing font
seven   Inverted font
eight   Hide font
Foreground
Value function
————————————

thirty   black
thirty-one   gules
thirty-two   green
thirty-three   yellow
thirty-four   blue
thirty-five   Purplish red
thirty-six   Cyan
thirty-seven   white
Background color
Value function
————————————

forty   black
forty-one   gules
forty-two   green
forty-three   yellow
forty-four   blue
forty-five   Purplish red
forty-six   Cyan
forty-seven   white
parameter   thirty   reach   forty-seven   accord with   ISO   six thousand four hundred and twenty-nine   Standard.
ESC[=psh

Setting mode: change the screen width or type to one of the following values.
0   forty   x   one hundred and forty-eight   x   twenty-five   Monochrome (text)
one   forty   x   one hundred and forty-eight   x   twenty-five   Color (text)
two   eighty   x   one hundred and forty-eight   x   twenty-five   Monochrome (text)
three   eighty   x   one hundred and forty-eight   x   twenty-five   Color (text)
four   three hundred and twenty   x   one hundred and forty-eight   x   two hundred   four   Color (Graphic)
five   three hundred and twenty   x   one hundred and forty-eight   x   two hundred   Monochrome (Graphic)
six   six hundred and forty   x   one hundred and forty-eight   x   two hundred   Monochrome (Graphic)
seven   Enable line feed
thirteen   three hundred and twenty   x   one hundred and forty-eight   x   two hundred   Color (Graphic)
fourteen   six hundred and forty   x   one hundred and forty-eight   x   two hundred   Color (16)   Color graphics)
fifteen   six hundred and forty   x   one hundred and forty-eight   x   three hundred and fifty   Monochrome (2)   Color graphics)
sixteen   six hundred and forty   x   one hundred and forty-eight   x   three hundred and fifty   Color (16)   Color graphics)
seventeen   six hundred and forty   x   one hundred and forty-eight   x   four hundred and eighty   Monochrome (2)   Color graphics)
eighteen   six hundred and forty   x   one hundred and forty-eight   x   four hundred and eighty   Color (16)   Color graphics)
nineteen   three hundred and twenty   x   one hundred and forty-eight   x   two hundred   Color (256)   Color graphics)
ESC[=Psl

Reset mode: resets the mode using the same value used in the set mode sequence, but   seven   Except, use   seven   Will disable the line feed function.
Note: the last character in the escape sequence is a lowercase character   L。
ESC[code;string;…p

Set keyboard string: redefines the keyboard key to the specified string. The parameters of the escape sequence are defined as follows:
“Code” is one or more values listed in the table below, which represent keyboard keys and key combinations. When using these values in a command, you must type the semicolon shown in the table in addition to the semicolon required by the sequence. The code in parentheses does not exist on some keyboards unless the option is selected  / X   stay   ANSI.SYS   Device for   Command, otherwise ansi.sys   The code in parentheses will not be translated for these keyboards.
“String” is valid for a single character   ASCII   Code, or a string enclosed in quotation marks. For example: 65   And “a” are used to represent capital letters   A。
Important: some values in the following table are not valid for all computers. For those different values, please check your computer documentation.
     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

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

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          —         0;120

2   50     64          0          0;121

3   51     35          —         0;122

4   52     36          —         0;123

5   53     37          —         0;124

6   54     94          30         0;125

7   55     38          —         0;126

8   56     42          —         0;126

9   57     40          —         0;127

0   48     41          —         0;129

–   45     95          31         0;130

=   61     43          —         0;131

[   91     123         27         0;26

]   93     125         29         0;27

    92     124         28         0;43

;   59     58          —         0;39

’   39     34          —         0;40

,   44     60          —         0;51

.   46     62          —         0;52

/   47     63          —         0;53

`   96     126         —         0;41 

Usually, when you press ESC at the DOS prompt, the screen will display a backslash (\) and move the cursor to the next line. At this time, you can use the prompt command. If the DOS prompt is $p $g and you want to clear the screen, you can type:   PROMPT=$E[2J  $ P$G   Here $e means pressing ESC, and then changing the prompt back to $p $g, otherwise the screen will be cleared before executing each command
When editing a batch file with edit, you can enter ESC characters in the following ways. First press Ctrl and P at the same time   Then press the button below to make square brackets. At this time, a left arrow (?) appears on the screen, indicating that ESC characters have been entered. It must be placed after that   Open Ctrl and press the lower bracket key again to start the ANSI command

Recommended Today

Heavyweight Tencent cloud open source industry’s first etcd one-stop governance platform kstone

​ Kstone open source At the kubecon China Conference held by CNCF cloud native foundation on December 9, 2021,Tencent cloud container tke team released the open source project of kstone etcd governance platform. KstoneIt was initiated by the TKE team of Tencent cloud containerCloud native one-stop etcd governance project based on kubernetes。 The project originates […]