| 1 |
lars |
1 |
PEAR PACKAGE: Console_Color
|
|
|
2 |
Version: 0.0.2
|
|
|
3 |
Author: Stefan Walk <post@fuer-et.de>
|
|
|
4 |
License: PHP License
|
|
|
5 |
|
|
|
6 |
Console_Color is a simple class to use ANSI Colorcodes.
|
|
|
7 |
Of all the functions, you probably only want to use convert() and escape().
|
|
|
8 |
They are easier to use. However, if you want to access colorcodes more
|
|
|
9 |
directly, look into the other functions.
|
|
|
10 |
|
|
|
11 |
Class method list:
|
|
|
12 |
color - Returns an ANSI-Controlcode
|
|
|
13 |
fgcolor - Returns an ANSI-Controlcode for foreground color
|
|
|
14 |
bgcolor - Returns an ANSI-Controlcode for background color
|
|
|
15 |
style - Returns an ANSI-Controlcode for text style (bold, underlined...)
|
|
|
16 |
convert - Transforms Colorcodes like %y into ANSI Control codes
|
|
|
17 |
escape - Escape %s in text so they don't get interpreted as colorcodes
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
Console_Color::color() - Returns an ANSI-Controlcode
|
|
|
21 |
Takes 1 to 3 Arguments: either 1 to 3 strings containing the name of the
|
|
|
22 |
FG Color, style and BG color, or one array with the indices color, style
|
|
|
23 |
or background.
|
|
|
24 |
|
|
|
25 |
Console_Color::fgcolor() - Returns an ANSI-Controlcode for foreground color
|
|
|
26 |
Takes the name of a foreground color as an argument and returns the ANSI
|
|
|
27 |
control code.
|
|
|
28 |
|
|
|
29 |
Console_Color:bfgcolor() - Returns an ANSI-Controlcode for background color
|
|
|
30 |
Takes the name of a background color as an argument and returns the ANSI
|
|
|
31 |
control code.
|
|
|
32 |
|
|
|
33 |
Console_Color::fgcolor() - Returns an ANSI-Controlcode for text style
|
|
|
34 |
Takes the name of a text style as an argument and returns the ANSI
|
|
|
35 |
control code.
|
|
|
36 |
|
|
|
37 |
Console_Color::convert() - Transform Colorcodes into ANSI Control Codes
|
|
|
38 |
Converts colorcodes in the format %y (for yellow) into ansi-control
|
|
|
39 |
codes. The conversion table is: ('bold' meaning 'light' on some
|
|
|
40 |
terminals). It's almost the same conversion table irssi uses.
|
|
|
41 |
|
|
|
42 |
text text background
|
|
|
43 |
------------------------------------------------
|
|
|
44 |
%k %K %0 black dark grey black
|
|
|
45 |
%r %R %1 red bold red red
|
|
|
46 |
%g %G %2 green bold green green
|
|
|
47 |
%y %Y %3 yellow bold yellow yellow
|
|
|
48 |
%b %B %4 blue bold blue blue
|
|
|
49 |
%m %M %5 magenta bold magenta magenta
|
|
|
50 |
%p %P magenta (think: purple)
|
|
|
51 |
%c %C %6 cyan bold cyan cyan
|
|
|
52 |
%w %W %7 white bold white white
|
|
|
53 |
%F Blinking, Flashing
|
|
|
54 |
%U Underline
|
|
|
55 |
%8 Reverse
|
|
|
56 |
%_,%9 Bold
|
|
|
57 |
%n Resets the color
|
|
|
58 |
%% A single %
|
|
|
59 |
|
|
|
60 |
First param is the string to convert, second is an optional flag if
|
|
|
61 |
colors should be used. It defaults to true, if set to false, the
|
|
|
62 |
colorcodes will just be removed (And %% will be transformed into %)
|
|
|
63 |
The transformed string is returned.
|
|
|
64 |
|
|
|
65 |
Console_Color::escape() - Escapes % so they don't get interpreted as color codes
|
|
|
66 |
Takes a string as an argument and returns the escaped string.
|