2010年12月18日星期六

ANSI Escape sequences [Color]

<read [Console2 + Cygwin + bash + Mercurial + style template] to support ANSI escape code to setup the environment first>

ANSI escape sequence is a sequence of ASCII characters, the first two of which are the ASCII "Escape" character 27 (1Bh) and the left-bracket character " [ " (5Bh). The character or characters following the escape and left-bracket characters specify an alphanumeric code that controls a keyboard or display function.
ANSI escape sequences distinguish between uppercase and lowercase letters.


  Esc[Value;...;Value

Set Graphics Mode:
Calls the graphics functions specified by the following values. These specified functions remain active until the next occurrence of this escape sequence. Graphics mode changes the colors and attributes of text (such as bold and underline) displayed on the screen.

Text attributes
0All attributes off
1Bold on
4Underscore (on monochrome display adapter only)
5Blink on
7Reverse video on
8Concealed on
Foreground colors
30Black
31Red
32Green
33Yellow
34Blue
35Magenta
36Cyan
37White
Background colors
40Black
41Red
42Green
43Yellow
44Blue
45Magenta
46Cyan
47White

Parameters 30 through 47 meet the ISO 6429 standard.


For example, cat a file color_ansi.txt in cygwin with TERM=ansi will display like this:

沒有留言:

發佈留言