Console_Color
[ class tree: Console_Color ] [ index: Console_Color ] [ all elements ]

Class: Console_Color2

Source Location: /Console_Color2-0.1.2/Console/Color2.php

Class Overview


A simple class to use ANSI Colorcodes.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 49]
A simple class to use ANSI Colorcodes.

Of all the functions, you probably only want to use convert() and escape(). They are easier to use. However, if you want to access colorcodes more directly, look into the other functions.



[ Top ]


Class Variables

$color_codes =

[line 52]

  • Access: protected

Type:   mixed


[ Top ]



Method Detail

__construct (Constructor)   [line 54]

Console_Color2 __construct( )

  • Access: public

[ Top ]

bgcolor   [line 175]

string bgcolor( string $name)

Returns a style controlcode

Parameters:

string   $name   —  Name of controlcode

[ Top ]

color   [line 120]

string color( [mixed $color = null], [string $style = null], [string $background = null])

Returns an ANSI-Controlcode

Takes 1 to 3 Arguments: either 1 to 3 strings containing the name of the FG Color, style and BG color, or one array with the indices color, style or background.

  • Access: public

Parameters:

mixed   $color   —  Optional. Either a string with the name of the foreground color, or an array with the indices 'color', 'style', 'background' and corresponding names as values.
string   $style   —  Optional name of the style
string   $background   —  Optional name of the background color

[ Top ]

convert   [line 215]

string convert( string $string, [bool $colored = true])

Converts colorcodes in the format %y (for yellow) into ansi-control codes. The conversion table is: ('bold' meaning 'light' on some terminals). It's almost the same conversion table irssi uses.

                  text      text            background
      ------------------------------------------------
      %k %K %0    black     dark grey       black
      %r %R %1    red       bold red        red
      %g %G %2    green     bold green      green
      %y %Y %3    yellow    bold yellow     yellow
      %b %B %4    blue      bold blue       blue
      %m %M %5    magenta   bold magenta    magenta
      %p %P       magenta (think: purple)
      %c %C %6    cyan      bold cyan       cyan
      %w %W %7    white     bold white      white

      %F     Blinking, Flashing
      %U     Underline
      %8     Reverse
      %_,%9  Bold

      %n     Resets the color
      %%     A single %
First param is the string to convert, second is an optional flag if colors should be used. It defaults to true, if set to false, the colorcodes will just be removed (And %% will be transformed into %)

  • Access: public

Parameters:

string   $string   —  String to convert
bool   $colored   —  Should the string be colored?

[ Top ]

escape   [line 279]

string escape( string $string)

Escapes % so they don't get interpreted as color codes
  • Access: public

Parameters:

string   $string   —  String to escape

[ Top ]

fgcolor   [line 161]

string fgcolor( string $name)

Returns a FG color controlcode
  • Access: public

Parameters:

string   $name   —  Name of controlcode

[ Top ]

getColorCodes   [line 98]

void getColorCodes( )

  • Access: public

[ Top ]

setColorCodes   [line 93]

void setColorCodes( $color_codes)

  • Access: public

Parameters:

   $color_codes   — 

[ Top ]

strip   [line 292]

string strip( string $string)

Strips ANSI color codes from a string
  • Access: public

Parameters:

string   $string   —  String to strip

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:51:04 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.