ANSI Color Codes in brief:
0 to restore default color
1 for brighter colors
4 for underlined text
5 for flashing text
30 for black foreground
31 for red foreground
32 for green foreground
33 for yellow (or brown) foreground
34 for blue foreground
35 for purple foreground
36 for cyan foreground
37 for white (or gray) foreground
40 for black background
41 for red background
42 for green background
43 for yellow (or brown) background
44 for blue background
45 for purple background
46 for cyan background
47 for white (or gray) backgroundyou use the above codes together with an escape sequence like this (replace the '#' with the colour code of your choice) :
\e[#m
Once you've used an escape all subsequent text will be affected until you use the reset escape
\e[0m
so if I want to format a part of a line of text, instead of:
print "This boring old line of text was supposed to have red text\n";
do this:
print "This new improved, brighter, more interesting line of text has \e[31mred text\e[0m\n" ;
or maybe even liberally chucking in a bit of '\e[5m' to really endear you to users, if you want to use two escapes on the same piece of text use one of these ';' :
\e[#;#m
print "This \e[5m new improved \e[0m, \e[5m brighter \e[0m, more \e[5minteresting \e[0m line of text has \e[31;5mflashing red text\e[0m\n" ;
A fuller listing of ANSI ecapes can be found here:
http://en2.wikipedia.org/wiki/ANSI_escape_code
Note the implmentation of ANSI varies wildly, so expect colour and (possibly) formatting but not consistency. Especially from Mircrosoft :).
HTH
Robin
On Sunday, January 18, 2004, at 01:54 pm, gohaku wrote:
Hi everyone, I have a question about the following script: use Term::ANSIColor; print color("red on_white"), "Danger, Will Robinson!\n"; print color("red on_white"), "Danger, Will Robinson!\n"; print color("red on_white"), "Danger, Will Robinson!\n"; print color("reset");
For some reason, the 1st line has only Red Text on a White Background, while the last 2 lines have only Red Text.
There doesn't seem to be any problems with lynx and colored text.
I am using v1.07 of Term::ANSIColor.
Has anybody experienced the same problem or is there a problem with my script?
Thanks in advance.
-Gohaku
