发信人: totalcontrol (生产队的大萝卜), 信区: ASCIIart
标 题: ANSI的用途及使用方法(转载)
发信站: 武汉白云黄鹤站 (Sat Jan 2 15:46:44 1999) , 转信
发信人: STW (蓝快), 信区: SaveName
标 题: ANSI的用途及使用方法
发信站: 广州蓝天站 (Thu Nov 20 22:35:30 1997), 转信
ANSI的用途及使用方法
ANSI.SYS 驱动程序包含更改图形命令,移动光标命令和重新设置键盘功能的命令.
在使用这些命令之前,ANSI.SYS驱动程序必须通过CONFIG.SYS的设备行装入内存.
在CONFIG.SYS中加入:
DEVICE=C:\DOS\ANSI.SYS
或 DEVICEHIGH=C:\DOS\ANSI.SYS 将ANSI.SYS装入高端内存.
所有ANSI命令起始于一个换码符(ASCII码27),后跟一个左方括号[.(就是先按ESC
键,再按"[").这里,换码符用ESC表示.
移动光标命令
ESC[X;YH 或 ESC[X;Yf
将光标移到屏幕上第X行,第Y列.屏幕左上角是第0行第0列.
ESC[nA
将光标上移n行
ESC[nB
将光标下移n行
ESC[nC
将光标右移n列
ESC[nD
将光标左移n列
ESC[S
保存当前光标位置.用ESC[U命令可将光标恢复到该位置.
ESC[U
将光标恢复到ESC[S命令所保存的位置上.
清除显示命令
ESC[2J
清屏并将光标移至屏幕左上角.
ESC[K
将当前行的内容从光标所在位置开始直到行尾全部清除.
图形模式命令
ESC[code;code;...codem
用下面所列的数码替换code所在位置.注意该命令中最后的字母必须是小写的m.
文本属性
0 放弃任何属性(屏幕恢复到黑底白字)
1 粗体显示
4 下划线(只用于单色显示适配器)
5 闪烁显示
7 相反显示
8 对比显示
前景颜色
30 黑
31 红
32 绿
33 黄
34 蓝
35 品红
36 青
37 白
背景颜色
40 黑
41 红
42 绿
43 黄
44 蓝
45 品红
46 青
47 白
设定屏幕模式命令
ESC[=codeh
用下面所列数码替换code来建立屏幕模式
ESC[=codel(注意这里"l"是小写的L,而不是数字1.)
用下面所列数码替换code来重建屏幕模式
0 40 X 25 单色显示(文本模式)
1 40 X 25 彩色显示(文本模式)
2 80 X 25 单色显示(文本模式)
3 80 X 25 彩色显示(文本模式)
4 320 X 200 4色显示(图形)
5 320 X 200 单色显示(图形)
6 640 X 200 单色显示(图形)
13 320 X 200 彩色显示(图形)
14 640 X 200 彩色显示(16色图形)
15 640 X 350 单色显示(2色图形)
16 640 X 350 彩色显示(16色图形)
17 640 X 480 单色显示(2色图形)
18 640 X 480 彩色显示(16色图形)
19 320 X 200 彩色显示(256色图形)
ESC[=7h
行自动连接命令,当字符显示到一行的最右端时,下一个字符显示在屏幕最左端.
ESC[=7l(这是小写L)
行不连接命令,当字符显示到一行的最右端时,下一个字符覆盖这一行最右端的
字符.
键盘控制命令
ESC[=code;stringp
该命令是将一个字符或一个字符串赋值给一个键.code是键盘扫描码,string参
数既可以是一个ACSII码表示的字符,也可以是一引号引起来的字符串.注意该命令
中的最后字符必须是小写字母p.
在DOS提示符下按ESC键时,屏幕会显示一个反斜杠(\)并把光标移到下一行.这时
可以使用PROMPT命令.假如现在DOS提示符是$P$G,想要清屏,就可键入:
PROMPT=$E[2J $P$G
这里$E即表示按ESC键,然后再把提示符改回$P$G,不然在执行每条命令前就都要清屏
了.
在用EDIT编辑批处理文件时可用下列方法输入ESC字符.首先同时按下Ctrl和P键
然后再按下作方括号,此时屏幕出现一左箭头(�,说明已输入了ESC字符.之后必须放
开Ctrl再次按下方括号键开始ANSI命令.
先写这麽多,你自己试试就知道了...
--
※ 转载:.暨南园 BBS 站 bbs.sti.jnu.edu.cn.[FROM: 202.116.6.144]
--
※ 修改:·unknown 於 Jul 16 15:26:20 修改本文·[FROM: 10.64.5.133]
※ 来源:·日月光华站 bbs.fudan.edu.cn·[FROM: 10.64.5.40]
Sender: Big Carrot from totalcontrol production team, message area: ASCIIart
Title: Purpose and usage of ANSI Reprinted
Sending station: Wuhan Baiyun Huanghe Station Sat Jan 2 15:46:44 1999, forwarded
Sender: STW Lankuai, message area: SaveName
Title: The purpose and use of ANSI
Sending station: Guangzhou Lantian Station Thu Nov 20 22:35:30 1997, forwarded
The purpose and use of ANSI
The ANSI.SYS driver contains commands for changing graphics, moving the cursor, and resetting keyboard functionality.
Before using these commands, the ANSI.SYS driver must be loaded into memory via the device line of CONFIG.SYS.
Add to CONFIG.SYS:
DEVICE C: DOS ANSI.SYS
Or DEVICEHIGH C: DOS ANSI.SYS loads ANSI.SYS into high-end memory.
All ANSI commands start with an escape character ASCII code 27, followed by a left square bracket [. Just press ESC first
key, and then press "[". Here, the escape character is represented by ESC.
Move cursor command
ESC[X;YH or ESC[X;Yf
Move the cursor to row X and column Y on the screen. The upper left corner of the screen is row 0 and column 0.
ESC[nA
Move cursor up n lines
ESC[nB
Move cursor down n lines
ESC[nC
Move cursor right n columns
ESC[nD
Move cursor left n columns
ESC[S
Save the current cursor position. Use the ESC[U command to restore the cursor to this position.
ESC[U
Restore the cursor to the position saved by the ESC[S command.
clear display command
ESC[2J
Clear the screen and move the cursor to the upper left corner of the screen.
ESC[K
Clear the contents of the current line from the cursor position to the end of the line.
graphics mode commands
ESC[code;code;...codem
Replace the code position with the numbers listed below. Note that the last letter in the command must be a lowercase m.
text attribute
0 Give up any attributes and the screen returns to white text on a black background
1 bold
4 underscore only for monochrome display adapters
5 flashing display
7 shown in reverse
8 contrast display
foreground color
30 black
31 red
32 green
33 yellow
34 blue
35 magenta
36 green
37 white
background color
40 black
41 red
42 green
43 yellow
44 blue
45 magenta
46 green
47 white
Set screen mode command
ESC[codeh
Replace the code with the numbers listed below to create the screen mode
ESC[ codel Note that "l" here is a lowercase L, not the number 1.
Replace the code with the numbers listed below to recreate the screen mode
0 40 X 25 Monochrome display Text mode
1 40 X 25 color display text mode
2 80 X 25 monochrome display text mode
3 80 X 25 color display text mode
4 320 X 200 4 color display graphics
5 320 X 200 monochrome display graphics
6 640 X 200 monochrome display graphics
13 320 X 200 color display graphics
14 640 X 200 color display 16 color graphics
15 640 X 350 Monochrome display 2 color graphics
16 640 X 350 color display 16 color graphics
17 640 X 480 Monochrome display 2 color graphics
18 640 X 480 color display 16 color graphics
19 320 X 200 color display 256 color graphics
ESC[7h
Line automatic connection command, when a character is displayed to the right end of a line, the next character is displayed at the left end of the screen.
ESC[ 7l This is lower case L
Lines are not connected to commands. When a character is displayed to the right end of a line, the next character covers the right end of the line.
character.
keyboard control commands
ESC[code;stringp
This command assigns a character or a string to a key. code is the keyboard scan code, and the string parameter
The number can be either a character represented by ACSII code or a string enclosed in quotes. Pay attention to this command
The last character in must be the lowercase letter p.
When you press the ESC key 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 current DOS prompt is $P$G and you want to clear the screen, you can type:
PROMPT $E[2J $P$G
Here $E means press the ESC key, and then change 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 use the following method to enter the ESC character. First, press the Ctrl and P keys at the same time.
Then press to make square brackets. At this time, a left arrow � appears on the screen, indicating that the ESC character has been entered. You must then press
Open Ctrl and press the bracket key again to start the ANSI command.
I’ll write this much first, and you’ll know after you try it yourself...
Reprint: Jinanyuan BBS station bbs.sti.jnu.edu.cn [FROM: 202.116.6.144]
Modification: unknown modified this article on Jul 16 15:26:20 [FROM: 10.64.5.133]
Source: Sun and Moon Guanghua Station bbs.fudan.edu.cn [FROM: 10.64.5.40]