Skip to content
docsv0.3.0

TerminalTheme

The default {@see TerminalThemeInterface}: a fixed role => SGR-code mapping and a fixed symbol => glyph mapping, both overridable per instance (symbols via `$symbols`; roles are not currently caller-configurable). Ships with `ansi` disabled by default, so constructing one with no arguments is always a safe, styling-free theme.

TerminalTheme::__construct()

public function __construct(bool $ansi = false, array $symbols = []):

Parameters

Parameters of __construct()
NameTypeDescription
$ansiboolWhether to actually emit ANSI escapes; when `false`, {@see style()} always returns its input unchanged.
$symbolsarray<string, string>Overrides for specific symbol names, consulted before the built-in defaults in {@see symbol()}.

TerminalTheme::ansiEnabled()

public function ansiEnabled(): bool

TerminalTheme::style()

public function style(string $text, string $role): string

The text wrapped in the ANSI styling this theme assigns to the semantic role.

Parameters

Parameters of style()
NameTypeDescription
$textstring
$rolestring

TerminalTheme::symbol()

public function symbol(string $name): string

The glyph this theme uses for the named symbol, so a renderer never hardcodes one.

Parameters

Parameters of symbol()
NameTypeDescription
$namestring