How to Use the ANSI. SYS Program

Source: Internet
Author: User

ANSI. SYS is a very useful device driver in the MS-DOS, which we can achieve unexpected display. So how should we use it? The following is an introduction.

Note: In this section, uppercase letters in the syntax and ANSI escape sequence must be typed as is.

ANSI. SYS defines a series of functions that are used to change the display graphics, control cursor movement, and key redefinition, ANSI. SYS device drivers support ANSI terminal simulation of escape sequences to control the screen and keyboard of the system.

The DEVICE driver must be loaded by the DEVICE or DEVICEHIGH command located in the CONFIG. SYS file.

Syntax

DEVICE (HIGH) = [drive:] [path] ANSI. SYS [/X] [/K] [/R]

Parameters

[Drive:] [path]

Specifies the location of the ANSI. SYS file.

Option

/X

Remap the extended keys other than the 101 key and keyboard.

/K

Let the ANSI. SYS file treat the 101-key keyboard as the 84-key keyboard, which is equivalent to the command SWITCHES =/K. If you usually use the SWITCHES =/K Command, you need to use option/K when using ANSI. SYS.

/R

This option is used to adjust row scrolling for readability when ANSI. SYS is used together with the screen reader program (which makes it easier for people with disabilities to use computers.

Parameters used in the ANSI escape sequence:

Number Parameter, used to specify a decimal number.

Optional. Specify a decimal number for selecting a function. You can specify multiple functions, which must be separated by semicolons.

PL

Line parameters. Specify a decimal number, which represents a line on the display or other devices.

Pc

Column parameters. Specifies a decimal number, which represents a column on the screen or other devices.

Settings for cursor movement, graphics, and keyboard in the ANSI escape sequence:

In the following list of ANSI escape sequences, ESC stands for the 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 (coordinates). If no position is specified, the cursor moves to the starting position, that is, the upper left corner of the screen (0 rows, 0 columns ).

The escape sequence works in the same way as the escape sequence at the cursor position below.

ESC [PL; Pcf

Cursor Position: It works in the same way as the escape sequence of the cursor position.

ESC [PnA

Move cursor up: move the cursor up the specified number of rows without changing the column. If the cursor is already in the first line, ANSI. SYS ignores this sequence.

ESC [PnB

Move cursor down: move the cursor down the specified number of rows without changing the column. If the cursor is already in the last row, ANSI. SYS ignores this sequence.

ESC [PnC

Move the cursor right: move the cursor right to the specified number of columns without changing the row. If the cursor is already in the rightmost column, ANSI. SYS ignores this sequence.

ESC [PnD

Move cursor left: move the cursor left to the specified number of columns without changing the row. If the cursor is already in the leftmost column, ANSI. SYS ignores this sequence.

ESC [s

Save cursor position: Save the current cursor position. With the "Restore cursor position" sequence, you can move the cursor to the saved cursor position.

ESC [u

Restore cursor position: return the cursor position to the saved position in save cursor position.

ESC [2J

Clear display: Clear the screen and move the cursor position to the starting position (0 rows, 0 columns ).

ESC [K

Clear rows: Clear all characters (including characters at the cursor position) from the cursor position to the end of the line ).

ESC [Ps;...; Psm

Set the graphic mode: Call the graphic functions specified by the following values. The specified functions remain active until the sequence appears again. The graphic mode changes the color and text properties displayed on the screen (for example, the black body and underline font.

Text attributes

Value Function

------------------------------------

0 No attribute

1 black body

4-underline font (only applicable to monochrome display adapters)

5. Flashing font

7. Reversed font

8. Hide the font

Foreground

Value Function

------------------------------------

30 black

31 red

32 green

33 yellow

34 blue

35 purple red

36 cyan

37 white

Background Color

Value Function

------------------------------------

40 black

41 red

42 green

43 yellow

44 blue

45 purple red

46 cyan

47 white

Parameters 30 to 47 comply with ISO 6429 standards.

ESC [= psh

Set mode: Change the screen width or type to a value specified by the following values.

0 40x148x25 monochrome (text)

1 40x148x25 color (text)

2 80x148x25 monochrome (text)

3 80x148x25 color (text)

4 320x148x200 4 colors (image)

5 320x148x200 monochrome (graphics)

6 640x148x200 monochrome (graphics)

7. Enable the line feed function

13 320x148x200 color (graphic)

14 640x148x200 color (16-color graphics)

15 640x148x350 monochrome (2-color image)

16 640x148x350 color (16 color graphics)

17 640x148x480 monochrome (2-color image)

18 640x148x480 color (16-color graphics)

19 320x148x200 color (256 color graphics)

ESC [= Psl

Reset mode: use the same value of the "set mode" sequence to reset the mode, except for 7. Using 7 will invalidate the line feed function.

Note: The last character in the escape sequence is lowercase L.

ESC [code; string;... p

Set the keyboard string: redefines the keyboard key as the specified string. The parameters of the escape sequence are defined as follows:

"Code" is one or more values listed in the following table. These values represent a combination of keyboard keys and keys. When using these values in the command, in addition to the number required by the sequence, you must also enter the semicolon displayed in the table. The code in the brackets does not exist on some keyboards. Unless option/X is specified in the DEVICE command of ANSI. SYS, ANSI. SYS will not translate the code in the brackets for these keyboards.

"String" is an ASCII code for a single character or a string contained in quotation marks. For example, both 65 and "A" are used to represent uppercase letters.

Important: some values in the following table are not valid for all computers. For different values, 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

F5 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, a backslash (\) is displayed and the cursor is moved to the next line. in this case, you can use the PROMPT command. if the current dos prompt is $ P $ G and you want to clear the screen, type: PROMPT = $ E [2J $ P $ G. Here $ E Indicates pressing the ESC key, then change the prompt back to $ P $ G. Otherwise, the screen will be cleared before each command is executed.

You can use the following method to enter the ESC character when editing a batch file: press Ctrl and P at the same time, and then press square brackets. A left arrow (? It indicates that the ESC character has been entered. After that, you must press Ctrl again to start the ANSI command.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.