class Ansi

internal  
 

ANSI escape sequences for terminal colors, cursor control, and text formatting.

Constants

private Colors

Methods

static string
color(string $color)

Returns ANSI escape sequence for given color.

static string
colorize(string $text, string $color)

Wraps text with ANSI color sequence and color reset.

static string
boldOn()

Returns ANSI sequence to turn on bold text.

static string
boldOff()

Returns ANSI sequence to turn off bold text.

static string
showCursor()

Returns ANSI sequence to show the cursor.

static string
hideCursor()

Returns ANSI sequence to hide the cursor.

static string
clearLine()

Returns ANSI sequence to clear from cursor to end of line.

static string
stripAnsi(string $text)

Removes all ANSI escape sequences from string (colors, cursor control, etc.).

static string
reset()

Returns ANSI sequence to reset all attributes.

static int
textWidth(string $text)

Returns display width of string (number of terminal columns).

Details

at line 30
static string color(string $color)

Returns ANSI escape sequence for given color.

Color format: 'foreground' or 'foreground/background' (e.g. 'red', 'white/blue').

Parameters

string $color

Return Value

string

at line 43
static string colorize(string $text, string $color)

Wraps text with ANSI color sequence and color reset.

Color format: 'foreground' or 'foreground/background' (e.g. 'red', 'white/blue').

Parameters

string $text
string $color

Return Value

string

at line 52
static string boldOn()

Returns ANSI sequence to turn on bold text.

Return Value

string

at line 61
static string boldOff()

Returns ANSI sequence to turn off bold text.

Return Value

string

at line 70
static string showCursor()

Returns ANSI sequence to show the cursor.

Return Value

string

at line 79
static string hideCursor()

Returns ANSI sequence to hide the cursor.

Return Value

string

at line 88
static string clearLine()

Returns ANSI sequence to clear from cursor to end of line.

Return Value

string

at line 97
static string stripAnsi(string $text)

Removes all ANSI escape sequences from string (colors, cursor control, etc.).

Parameters

string $text

Return Value

string

at line 106
static string reset()

Returns ANSI sequence to reset all attributes.

Return Value

string

at line 115
static int textWidth(string $text)

Returns display width of string (number of terminal columns).

Parameters

string $text

Return Value

int