Ansi
class Ansi
| internal |
ANSI escape sequences for terminal colors, cursor control, and text formatting.
Constants
| private Colors |
|
Methods
Returns ANSI escape sequence for given color.
Wraps text with ANSI color sequence and color reset.
Returns ANSI sequence to turn on bold text.
Returns ANSI sequence to turn off bold text.
Returns ANSI sequence to show the cursor.
Returns ANSI sequence to hide the cursor.
Returns ANSI sequence to clear from cursor to end of line.
Removes all ANSI escape sequences from string (colors, cursor control, etc.).
Returns ANSI sequence to reset all attributes.
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').
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').
at line 52
static string
boldOn()
Returns ANSI sequence to turn on bold text.
at line 61
static string
boldOff()
Returns ANSI sequence to turn off bold text.
at line 70
static string
showCursor()
Returns ANSI sequence to show the cursor.
at line 79
static string
hideCursor()
Returns ANSI sequence to hide the cursor.
at line 88
static string
clearLine()
Returns ANSI sequence to clear from cursor to end of line.
at line 97
static string
stripAnsi(string $text)
Removes all ANSI escape sequences from string (colors, cursor control, etc.).
at line 106
static string
reset()
Returns ANSI sequence to reset all attributes.
at line 115
static int
textWidth(string $text)
Returns display width of string (number of terminal columns).