免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2093 | 回复: 0
打印 上一主题 下一主题

ANSI Terminal Control Escape Sequences [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-21 13:38 |只看该作者 |倒序浏览
ANSI/VT100 Terminal Control Escape Sequences
        
        
        
        [
Status
|
Setup
|
        
Fonts
|
Cursor
|
        
Scrolling
|
Tabs
|
        
Erasing
|
Printing
|
        
Keyboard
|
Colours
]
         
        
        
        
Many computer terminals and terminal emulators support colour and
          cursor control through a system of escape sequences. One such standard
          is commonly referred to as ANSI Colour. Several terminal
          specifications are based on the ANSI colour standard, including VT100.
        
        
        
The following is a partial listing of the VT100 control set.
        
        
represents the ASCII "escape"
          character, 0x1B. Bracketed tags represent modifiable decimal
          parameters; eg. {ROW} would be replaced by a row
          number.
        
        

        
        Device Status The following codes are
        used for reporting terminal/display settings, and vary depending on the
        implementation:
Query Device Code        [c
        
        
  • Requests a Report Device Code response from
                the device.

        
        

Report Device Code        [{code}0c
        
        
  • Generated by the device in response to Query Device
                Code
    request.

        
        

Query Device Status        [5n
        
        
  • Requests a Report Device Status response
                from the device.

        
        

Report Device OK        [0n
        
        
  • Generated by the device in response to a Query Device
                Status
    request; indicates that device is functioning
                correctly.

        
        

Report Device Failure        [3n
        
        
  • Generated by the device in response to a Query Device
                Status
    request; indicates that device is functioning
                improperly.

        
        

Query Cursor Position        [6n
        
        
  • Requests a Report Cursor Position response
                from the device.

        
        

Report Cursor Position        [{ROW};{COLUMN}R
        
        
  • Generated by the device in response to a Query Cursor
                Position
    request; reports current cursor position.

        
        

        
        Terminal Setup The
        h and l codes are used for
        setting terminal/display mode, and vary depending on the implementation.
        Line Wrap is one of the few setup codes that tend to be used
        consistently:
        
        
Reset Device                c
        
        
  • Reset all terminal settings to default.

        
        

Enable Line Wrap        [7h
        
        
  • Text wraps to next line if longer than the length of the display
                area.

        
        

Disable Line Wrap        [7l
        
        
  • Disables line wrapping.

        
        

        
        Fonts Some terminals support multiple
        fonts: normal/bold, swiss/italic, etc. There are a variety of special
        codes for certain terminals; the following are fairly standard:
        
        
Font Set G0                (
        
        
  • Set default font.

        
        
Font Set G1                )
        
        
  • Set alternate font.

        
        

        
        Cursor Control
Cursor Home                 [{ROW};{COLUMN}H
        
        
  • Sets the cursor position where subsequent text will begin. If no
                row/column parameters are provided (ie. [H),
                the cursor will move to the home position, at the upper left
                of the screen.

        
        

Cursor Up                [{COUNT}A
        
        
  • Moves the cursor up by COUNT rows; the default count is
                1.

        
        

Cursor Down                [{COUNT}B
        
        
  • Moves the cursor down by COUNT rows; the default count is
                1.

        
        

Cursor Forward                [{COUNT}C
        
        
  • Moves the cursor forward by COUNT columns; the
                default count is 1.

        
        

Cursor Backward                [{COUNT}D
        
        
  • Moves the cursor backward by COUNT columns; the
                default count is 1.

        
        

Force Cursor Position        [{ROW};{COLUMN}f
        
        
  • Identical to Cursor Home.

        
        

Save Cursor                [s
        
        
  • Save current cursor position.

        
        

Unsave Cursor                [u
        
        
  • Restores cursor position after a Save Cursor.
             

        
        

Save Cursor & Attrs        7
        
        
  • Save current cursor position.

        
        

Restore Cursor & Attrs        8
        
        
  • Restores cursor position after a Save Cursor.
             

        
        

        
        Scrolling
Scroll Screen                [r
        
        
  • Enable scrolling for entire display.

        
        

Scroll Screen                [{start};{end}r
        
        
  • Enable scrolling from row {start} to row
                {end}.

        
        

Scroll Down                D
        
        
  • Scroll display down one line.

        
        

Scroll Up                M
        
        
  • Scroll display up one line.

        
        

        
        Tab Control
Set Tab                 H
        
        
  • Sets a tab at the current position.

        
        

Clear Tab                 [g
        
        
  • Clears tab at the current position.

        
        

Clear All Tabs                 [3g
        
        
  • Clears all tabs.

        
        

        
        Erasing Text
Erase End of Line        [K
        
        
  • Erases from the current cursor position to the end of the current
                line.

        
        

Erase Start of Line        [1K
        
        
  • Erases from the current cursor position to the start of the
                current line.

        
        

Erase Line                [2K
        
        
  • Erases the entire current line.

        
        

Erase Down                [J
        
        
  • Erases the screen from the current line down to the bottom of the
                screen.

        
        

Erase Up                [1J
        
        
  • Erases the screen from the current line up to the top of the
                screen.

        
        

Erase Screen                [2J
        
        
  • Erases the screen with the background colour and moves the cursor
                to home.

        
        

        
        Printing Some terminals support local
        printing:
Print Screen                [i
        
        
  • Print the current screen.

        
        

Print Line                [1i
        
        
  • Print the current line.

        
        

Stop Print Log                [4i
        
        
  • Disable log.

        
        

Start Print Log                [5i
        
        
  • Start log; all received text is echoed to a printer.

        
        

        
        Define Key
Set Key Definition        [{key};"{string}"p
        
        
  • Associates a string of text to a keyboard key. {key}
                indicates the key by its ASCII value in decimal.

        
        

        
        Set Display Attributes
Set Attribute Mode        [{attr1};...;{attrn}m
        
        
  • Sets multiple display attribute settings. The following lists
                standard attributes:
    0        Reset all attributes
    1        Bright
    2        Dim
    4        Underscore       
    5        Blink
    7        Reverse
    8        Hidden
            Foreground Colours
    30        Black
    31        Red
    32        Green
    33        Yellow
    34        Blue
    35        Magenta
    36        Cyan
    37        White
            Background Colours
    40        Black
    41        Red
    42        Green
    43        Yellow
    44        Blue
    45        Magenta
    46        Cyan
    47        White

               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/29188/showart_1656999.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP