colorize
colorize function: COLORIZEs a string
$color = colorize( |
str
) ; |
Replaces color codes (see below) in the string with ANSI escape sequences,so that the string can be echoed in the terminal, for example. Returns the colorized string.
Color code table (based on colors used by the Smaug server):
&0 (number zero) - Reset all attributes and colors to default Normal colors: &x - Black &r - Red &g - Green &O - Yellow &b - Blue &p - Magenta &c - Cyan &w - White &d - Default foreground Bold colors: &z - Bold Black &R - Bold Red &G - Bold Green &Y - Bold Yellow &B - Bold Blue &P - Bold Magenta &C - Bold Cyan &W - Bold White &D - Default bold foreground Background colors: ^x - Black ^r - Red ^g - Green ^O - Yellow ^b - Blue ^p - Magenta ^c - Cyan ^w - White ^d - Default background Light background colors (sometimes causes blinking): ^z - Light Black ^R - Light Red ^G - Light Green ^Y - Light Yellow ^B - Light Blue ^P - Light Magenta ^C - Light Cyan ^W - Light White ^D - Default light background Attributes: (may not work on other clients) &_ - Underline on ^_ - All underline off &= - Double underline on &| - Strikethrough on ^| - Strikethrough off &/ - Italics on ^/ - Italics off &i - Inverse video on ^i - Inverse video off &h - Hidden mode on ^h - Hidden mode off
Note: if you want to set both the foreground and the background, the code for the foreground should come first. If you want to set the foreground and/or background and one or more attributes (underline, italics, etc), the attribute settings should come after the color.
Note: to insert a & or ^ character, use && and ^^, respectively.
You can also also use colorize()
to display
text in any color of a 6x6x6 RGB color cube. To do so, use
&
and ^rgbX to set the foreground and background, respectively.
r
g
b
Xr
, g
, and
b
are integers between 0 and 5 representing the
amount of red, green and blue. X is really the letter X, it is used to
close the code.
Finally, to select one of the 24 shades of gray available, use
&
and
n
G^
for the foreground and
background, respectively, where n
Gn
is an integer
from 0 to 23, and G is really the letter G.
You can use the kc256 (see Section 13.3.4, “kc256”) plugin to display all the colors for you to choose from.