LinuxSir.Org  
| 网站首页 | 注册账号 | 论坛帮助 |

欢迎来到LinuxSir.Org!
您还未登录,请登录后查看论坛,或者点击论坛上方的注册链接注册新账号。


发表新主题 回复
精华主题  
主题工具
旧 03-06-01, 15:34 第 1 帖
无双
 
无双 的头像
 
 
注册会员  
  注册日期: May 2003
  帖子: 1,799
  精华: 25
 

标题: VT100控制码


经常见大家在问printf("\027[10")等是什么意思
这种就是VT100控制码
用于控制屏幕等终端设备的属性 ,只要终端符合VT100类型那么就可以控制它
如光标移动、清屏等







VT100以ESC开始,在TELNET终端上同样可以使用VT100命令实现光标移动

现列出如下

Article 248 of comp.terminals:
Newsgroups: comp.terminals
Path: cs.utk.edu!gatech!udel!bogus.sura.net!opusc!usceast!chan
From: chan@ece.scarolina.edu (Simon Chan)
Subject: VT100 Reference Card !! ( if you are looking for....)
Message-ID: <chan.728236678@hertz>
Keywords: vt100 terminal escape codes
Sender: usenet@usceast.cs.scarolina.edu (USENET News System)
Organization: USC Department of Computer Science
Date: 28 Jan 93 15:57:58 GMT
Lines: 162



Taken from VT100 Programming Reference Card (DIGITAL)

ANSI Compatible Mode

Cursor Movement Commands
Cursor up ESC [ Pn A
Cursor down ESC [ Pn B
Cursor forward (right) ESC [ Pn C
Cursor backward (left) ESC [ Pn D
Direct cursor addressing ESC [ Pl; Pc H or
ESC [ Pl; Pc f
Index ESC D
Next Line ESC E
Reverse index ESC M
Save cursor and attributes ESC 7
Restore cursor and attributes ESC 8
* Pn = decimal parameter in string of ASCII digits.(default 1)
* Pl = line number (default 0); Pc = column number (default 0)

Line Size (Double-Height and Double-Width) Commands
Change this line to double-height top half ESC # 3
Change this line to double-height bottom half ESC # 4
Change this line to single-width single-height ESC # 5
Change this line to double-width single-height ESC # 6

Character Attributes
ESC [ Ps;Ps;Ps;...,Ps m
Ps = 0 or None All Attributes Off
1 Bold on
4 Underscore on
5 Blink on
7 Reverse video on
Any other parameter values are ignored.

Erasing
From cursor to end of line ESC [ K or ESC [ 0 K
From beginning of line to cursor ESC [ 1 K
Entire line containing cursor ESC [ 2 K
From cursor to end of screen ESC [ J or ESC [ 0 J
From beginning of screen to cursor ESC [ 1 J
Entire screen ESC [ 2 J

Programmable LEDs
ESC [ Ps;Ps;...Ps q
Ps = 0 or None All LEDs Off
1 L1 on
2 L2 on
3 L3 on
4 L4 on
Any other parameter values are ignored.

Character Set (G0 and G1 Designators)
Charactor Set G0 Designator G1 Designator
United Kingdom (UK) ESC ( A ESC ) A
United States (USASCII) ESC ( B ESC ) B
Special graphics characters ESC ( 0 ESC ) 0
and line drawing set
Alternate character ROM ESC ( 1 ESC ) 1
Alternate character ROM ESC ( 2 ESC ) 2
special graphics characters

Scrolling Region
ESC [ Pt ; Pb r
Pt is the number of the top line of the scrolling region;
Pb is the number of the bottom line of the scrolling region
and must be greater than Pt.
(The default for Pt is line 1, the default for Pb is the end
of the screen)

TAB stops
Set tab at current column ESC H
Clear tab at curent column ESC [ g or ESC [ 0 g
Clear all tabs ESC [ 3 g

Modes
To Set To Reset
Mode Name Mode Sequence Mode Sequence
Line feed/new line New line ESC [20h Line feed ESC [20l
Cursor key mode Application ESC [?1h Cursor ESC [?l
ANSI/VT52 mode ANSI N/A VT52 ESC [?2l
Column mode 132 Col ESC [?3h 80 Col ESC [?3l
Scrolling mode Smooth ESC [?4h Jump ESC [?4l
Screen mode Reverse ESC [?5h Normal ESC [?5l
Origin mode Relative ESC [?6h Absolute ESC [?6l
Wraparound On ESC [?7h Off ESC [?7l
Auto repeat On ESC [?8h Off ESC [?8l
Interlace On ESC [?9h Off ESC [?9l
Graphic proc. option On ESC 1 Off ESC 2
Keypad mode Application ESC = Numeric ESC >

Reports
Cursor Position Report
Invoked by ESC [ 6 n
Response is ESC [ Pl; Pc R
* Pl = line number; Pc = column number

Status Report
Invoked by ESC [ 5 n
Response is ESC [ 0 n (terminal ok)
ESC [ 3 n (terminal not ok)

What Are You
Invoked by ESC [ c or ESC [ O c
Response is ESC [ ?1 ; Ps C
Ps = 0 Base VT100, no options
1 Processor option (STP)
2 Advanced Video option (AVO)
3 AVO and STP
4 Graphocs processor option (GO)
5 GO and STP
6 GO and AVO
7 GO, STP, and AVO
Alternately invoked by ESC Z (not recommended.) Response is the same.

Reset
ESC c

Confidence Tests
Fill Screen with "Es" ESC # 8
Invoke Test(s) ESC [ 2 ; Ps y
Ps = 1 Power-up self test
(ROM checksum, RAM, NVR,
keyboard and AVO if installed)
2(loop back connector required) Data Loop Back
4(loop back connector required) ETA Modern Control Test
8 Repeat selected test(s)
indefinitely
(until failure or power off)

VT52 Compatible Mode
Cursor Up ESC A
Cursor Down ESC B
Cursor Right ESC C
Cursor Left ESC D
Select Special Graphics character set ESC F
Select ASCII character set ESC G
Cursor to home ESC H
Reverse line feed ESC I
Erase to end of screen ESC J
Erase to end of line ESC K
Direct cursor address ESC Ylc (see note 1)
Identify ESC Z (see note 2)
Enter alternate keypad mode ESC =
Exit alternate keypad mode ESC >
Enter ANSI mode ESC <

NOTE 1: Line and column numbers for direct cursor address are single
character codes whose values are the desired number plus
37 (in Octal). Line and column numbers start at 1.
NOTE 2: Response to ESC Z is ESC / Z.



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Simon Chan chan@ece.scarolina.edu
Department of Electrical & Computer Engineering
Swearingen Engineering Centre
University of South Carolina
Coulmbia, South Carolina 29208
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Article 269 of comp.terminals:
Path: cs.utk.edu!gatech!news.ans.net!cmcl2!adm!smoke!gwyn
From: gwyn@smoke.brl.mil (Doug Gwyn)
Newsgroups: comp.terminals
Subject: Re: VT100 Reference Card !!
Keywords: vt100 terminal escape codes
Message-ID: <19629@smoke.brl.mil>
Date: 1 Feb 93 15:01:49 GMT
References: <chan.728236678@hertz>
Organization: U.S. Army Ballistic Research Lab, APG MD.
Lines: 25

In article <chan.728236678@hertz> chan@ece.scarolina.edu (Simon Chan) writes:
>Taken from VT100 Programming Reference Card (DIGITAL)

Note that EK-VT100-RC-001 contains several errors and omissions.
The errors appear to all be fixed in the posted version.
Here are some additions:

Parameters to Direct cursor addressing can be omitted if 1.
"Index" is broken if NEWLINE is enabled (set-up).
"Reverse index" scrolls up retaining the same column.

CHARACTER SET DESIGNATORS: G0 = Shift-In, G1 = Shift-Out

> ANSI/VT52 mode ANSI N/A VT52 ESC [?2l
ANSI/VT52 mode ANSI ESC < VT52 ESC [?2l
Modes can be combined using ";", for example "ESC [ ? 3 ; 4 ; 7 h"

CONFIDENCE TESTS: Parameter bits are summed into one parameter.

Hardcopy ESC # 7
Graphic processor ON ESC 1
Graphic processor OFF ESC 2

The reference card showed incorrect graphics for octal code 140; its
correct graphic is ` (accent grave).
  无双 当前离线   回复时引用此帖
旧 03-06-01, 17:55 第 2 帖
colored
 
colored 的头像
 
 
注册会员  
  注册日期: Apr 2003
  我的住址: 南昌
  帖子: 158
  精华: 1
 

标题: 刚刚在google找到的


http://www.cyut.edu.tw/~ckhung/olboo...textmode.shtml







__________________
C366/128M/20G+8G/tnt 16M
RH8.0/GNOME 2.4
  colored 当前离线   回复时引用此帖
旧 03-06-01, 21:04 第 3 帖
无双
 
无双 的头像
 
 
注册会员  
  注册日期: May 2003
  帖子: 1,799
  精华: 25
 

我也是在google上找到的

这个在控制台编程时还是很有用
如显示彩色字、控制屏幕光标等







__________________
loveunix.net

讨论技术的好地方

[IMG]http://www.loveunix.net/style_images/1/logo2.gif[/IMG]
欢迎参观我的论坛
  无双 当前离线   回复时引用此帖
旧 03-06-01, 21:30 第 4 帖
libinary
 
libinary 的头像
 
 
退役版主  
  注册日期: Feb 2003
  我的住址: 西安
  帖子: 1,502
  精华: 4
 

www.vt100.net上有VT100 User Guide下
  libinary 当前离线   回复时引用此帖
旧 03-06-01, 21:43 第 5 帖
无双
 
无双 的头像
 
 
注册会员  
  注册日期: May 2003
  帖子: 1,799
  精华: 25
 

那里面的资料是很全
舍得推荐
  无双 当前离线   回复时引用此帖
旧 04-06-17, 11:47 第 6 帖
kj501
 
kj501 的头像
 
 
★☆版★主☆★  
  注册日期: Sep 2002
  我的住址: 贵州贵阳
  帖子: 5,317
  精华: 36
 

让光标上升5行。
代码:
/*向终端输出ESC[5A 会使光标上移5行 */ #include <stdio.h> int main() { printf("\33[5A"); /* \033为8进制数,十进制为27,是ESC的ASCII码 */ }







__________________
希望大家提问前先 google 关键词
希望大家提问前先看论坛的精华和置项的贴子
希望大家提问前先搜索论坛的相关内容
希望大家提问时把标题写清楚
希望大家贴代码时能保持缩进
LFS ID:8158

此帖于 04-06-17 11:49 被 kj501 编辑.
  kj501 当前离线   回复时引用此帖
发表新主题 回复


主题工具

发帖规则
您 [不可以] 发表新主题
您 [不可以] 回复主题
您 [不可以] 上传附件
您 [不可以] 编辑您的帖子

已 [启用] BB 代码
已 [启用] 表情符号
已 [启用] IMG 代码
已 [禁用] HTML 代码
[论坛跳转…]


所有时间均为[北京时间]。现在的时间是 16:56


Powered by vBulletin 版本 3.6.8
版权所有 ©2000 - 2010, Jelsoft Enterprises Ltd.
官方中文技术支持: vBulletin 中文
版权所有 ©2002 - 2009, LinuxSir.Org