ANSI escape code

来源:互联网 发布:洛丽塔淘宝店铺 编辑:程序博客网 时间:2024/05/17 21:59

前一段时间在处理telnet的一些控制字符,遇到了比较纠结的事情。

自己通过socket发送命令到交换机上,获取相关字符,瞎猜,还是宣告失败,后面维基百科了一下。果然全部搞定。。。

现,献上ANSI escape code的相关解码。

 

Some ANSI escape sequences (not a complete list)CodeNameEffectCSI n ACUU – Cursor UpMoves the cursor n (default 1) cells in the given direction. If the cursor is already at the edge of the screen, this has no effect.CSI n BCUD – Cursor DownCSI n CCUF – Cursor ForwardCSI n DCUB – Cursor BackCSI n ECNL – Cursor Next LineMoves cursor to beginning of the line n (default 1) lines down.CSI n FCPL – Cursor Previous LineMoves cursor to beginning of the line n (default 1) lines up.CSI n GCHA – Cursor Horizontal AbsoluteMoves the cursor to column n.CSI n ; m HCUP – Cursor PositionMoves the cursor to row n, column m. The values are 1-based, and default to 1 (top left corner) if omitted. A sequence such as CSI ;5H is a synonym for CSI 1;5H as well as CSI 17;H is the same as CSI 17H and CSI 17;1HCSI n JED – Erase DataClears part of the screen. If n is zero (or missing), clear from cursor to end of screen. Ifn is one, clear from cursor to beginning of the screen. If n is two, clear entire screen (and moves cursor to upper left on MS-DOS ANSI.SYS).CSI n KEL – Erase in LineErases part of the line. If n is zero (or missing), clear from cursor to the end of the line. Ifn is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.CSI n SSU – Scroll UpScroll whole page up by n (default 1) lines. New lines are added at the bottom. (not ANSI.SYS)CSI n TSD – Scroll DownScroll whole page down by n (default 1) lines. New lines are added at the top. (not ANSI.SYS)CSI n ; m fHVP – Horizontal and Vertical PositionMoves the cursor to row n, column m. Both default to 1 if omitted. Same as CUPCSI n [;k] mSGR – Select Graphic RenditionSets SGR parameters, including text color. After CSI can be zero or more parameters separated with ;. With no parameters, CSI m is treated as CSI 0 m (reset / normal), which is typical of most of the ANSI escape sequences.CSI 6 nDSR – Device Status ReportReports the cursor position to the application as (as though typed at the keyboard) ESC[n;mR, wheren is the row and m is the column. (May not work on MS-DOS.)CSI sSCP – Save Cursor PositionSaves the cursor position.CSI uRCP – Restore Cursor PositionRestores the cursor position.CSI ?25lDECTCEMHides the cursor. (Note: the trailing character is lowercase L.)CSI ?25hDECTCEMShows the cursor.SGR (Select Graphic Rendition) parametersCodeEffectNote0Reset / Normalall attributes off1Bright (increased intensity) or Bold 2Faint (decreased intensity)not widely supported3Italic: onnot widely supported. Sometimes treated as inverse.4Underline: Single 5Blink: Slowless than 150 per minute6Blink: RapidMS-DOS ANSI.SYS; 150 per minute or more; not widely supported7Image: Negativeinverse or reverse; swap foreground and background8Concealnot widely supported9Crossed-outCharacters legible, but marked for deletion. Not widely supported.10Primary(default) font 11–19n-th alternate fontSelect the n-th alternate font. 14 being the fourth alternate font, up to 19 being the 9th alternate font.20Frakturhardly ever supported21Bright/Bold: off or Underline: Doublebold off not widely supported, double underline hardly ever22Normal color or intensityneither bright, bold nor faint23Not italic, not Fraktur 24Underline: Nonenot singly or doubly underlined25Blink: off 26Reserved 27Image: Positive 28Revealconceal off29Not crossed out 30–37Set text color30 + x, where x is from the color table below38Set xterm-256 text color[dubious]next arguments are 5;x where x is color index (0..255)39Default text colorimplementation defined (according to standard)40–47Set background color40 + x, where x is from the color table below48Set xterm-256 background colornext arguments are 5;x where x is color index (0..255)49Default background colorimplementation defined (according to standard)50Reserved 51Framed 52Encircled 53Overlined 54Not framed or encircled 55Not overlined 56–59Reserved 60ideogram underline or right side linehardly ever supported61ideogram double underline or double line on the right sidehardly ever supported62ideogram overline or left side linehardly ever supported63ideogram double overline or double line on the left sidehardly ever supported64ideogram stress markinghardly ever supported90–99Set foreground color, high intensityaixterm (not in standard)100–109Set background color, high intensityaixterm (not in standard)

 http://en.wikipedia.org/wiki/ANSI_escape_code

原创粉丝点击