ANSI/VT100 Terminal Control escape sequences (operations on control terminals)

Source: Internet
Author: User

Your computer terminals and terminal emulators support color 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 color standard, including vt100.

The following is a partial listing of the VT100 control set.

<ESC>Represents the ASCII "escape" character, 0x1b. Bracketed tags represent modifiable decimal parameters; eg.{ROW}Wocould 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<ESC>[c
  • RequestsReport Device CodeResponse from the device.

Report Device Code<ESC>[{code}0c
  • Generated by the device in responseQuery Device CodeRequest.

Query Device Status<ESC>[5n
  • RequestsReport Device StatusResponse from the device.

Report Device OK<ESC>[0n
  • Generated by the device in response toQuery Device StatusRequest; indicates that device is functioning correctly.

Report Device Failure<ESC>[3n
  • Generated by the device in response toQuery Device StatusRequest; indicates that device is functioning improperly.

Query Cursor Position<ESC>[6n
  • RequestsReport Cursor PositionResponse from the device.

Report Cursor Position<ESC>[{ROW};{COLUMN}R
  • Generated by the device in response toQuery Cursor PositionRequest; Reports current cursor position.

Terminal setup

ThehAndlCodes
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<ESC>c
  • Reset all terminal settings to default.

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

Disable Line Wrap<ESC>[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<ESC>(
  • Set default font.

Font Set G1<ESC>)
  • Set alternate font.

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

Cursor Up<ESC>[{COUNT}A
  • Moves the cursor upCountRows; the default count is 1.

Cursor Down<ESC>[{COUNT}B
  • Moves the cursor downCountRows; the default count is 1.

Cursor Forward<ESC>[{COUNT}C
  • Moves the cursorForwardByCountColumns; the default count is 1.

Cursor Backward<ESC>[{COUNT}D
  • Moves the cursorBackwardByCountColumns; the default count is 1.

Force Cursor Position<ESC>[{ROW};{COLUMN}f
  • IdenticalCursor Home.

Save Cursor<ESC>[s
  • Save current cursor position.

Unsave Cursor<ESC>[u
  • Restores cursor position afterSave Cursor.

Save Cursor & Attrs<ESC>7
  • Save current cursor position.

Restore Cursor & Attrs<ESC>8
  • Restores cursor position afterSave Cursor.

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

Scroll Screen<ESC>[{start};{end}r
  • Enable scrolling from row{start}To row{end}.

Scroll Down<ESC>D
  • Scroll display down one line.

Scroll Up<ESC>M
  • Scroll display up one line.

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

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

Clear All Tabs <ESC>[3g
  • Clears all tabs.

Erasing text
Erase End of Line<ESC>[K
  • Erases from the current cursor position to the end of the current line.

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

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

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

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

Erase Screen<ESC>[2J
  • Erases the screen with the background color and moves the cursorHome.

Printing

Some terminals support local printing:

Print Screen<ESC>[i
  • Print the current screen.

Print Line<ESC>[1i
  • Print the current line.

Stop Print Log<ESC>[4i
  • Disable log.

Start Print Log<ESC>[5i
  • Start log; all encoded ed text is echoed to a printer.

Define key
Set Key Definition<ESC>[{key};"{string}"p
  • AssociatesStringOf text to a keyboard key.{key}Indicates the key by its ASCII value in decimal.

Set display attributes
Set Attribute Mode<ESC>[{attr1};...;{attrn}m
  • Sets Multiple display attribute settings. The following lists standard attributes:

    0Reset all attributes1Bright2Dim4Underscore5Blink7Reverse8HiddenForeground Colours30Black31Red32Green33Yellow34Blue35Magenta36Cyan37WhiteBackground Colours40Black41Red42Green43Yellow44Blue45Magenta46Cyan47White
    Address: http://www.termsys.demon.co.uk/vtansi.htm

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.