Skip to content
docsv0.3.0

TerminalThemeInterface

The one ANSI/theme contract both TUI runtimes (the retained tree and {@see \Milpa\Live\Tui\TuiAnsiPainter}) share for turning semantic roles/symbol names into terminal output, so color and glyph choices live in one place instead of being hardcoded ANSI escapes scattered across node renderers.

TerminalThemeInterface::ansiEnabled()

abstract public function ansiEnabled(): bool

Whether this theme actually emits ANSI escape sequences. Implementations that answer `false` MUST make {@see style()} return `$text` unchanged, so callers never need to branch on this before calling `style()`/`symbol()` — a disabled theme is a safe, styling-free default, not a separate code path.

TerminalThemeInterface::style()

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

Applies the color/style associated with a semantic role (e.g. `'title'`, `'success'`, `'error'`, `'muted'`) to `$text`. An unrecognized `$role`, or {@see ansiEnabled()} being `false`, MUST return `$text` unchanged rather than throwing.

Parameters

Parameters of style()
NameTypeDescription
$textstring
$rolestring

TerminalThemeInterface::symbol()

abstract public function symbol(string $name): string

Resolves a named glyph (e.g. `'selected'`, `'trend-up'`) to the character(s) this theme displays for it. Implementations SHOULD return a sensible ASCII fallback for an unrecognized `$name` rather than throwing, since symbol names may grow over time.

Parameters

Parameters of symbol()
NameTypeDescription
$namestring