TerminalCapabilities
Detects terminal capabilities from the `TERM` / `TERM_PROGRAM` environment variables and the ` kitty keyboard protocol` negotiation response. The PHP analog of pi-tui's capability detection in `terminal.ts` / `terminal-image.ts`. Lets a TUI bootstrap decide, without spawning subprocesses, whether to: - emit Kitty/iTerm2 inline-image escapes (`ImageRenderer`) - emit the Kitty keyboard protocol query (`KeyMatcher`) - emit OSC 11 background-color query (`TerminalColor`) - emit the synchronized-output mode toggles (`SynchronizedOutput`) Pure utility — no I/O. The caller reads env vars once and hands them in via the constructor; {@see detect()} then returns an immutable snapshot of what this terminal is known to support.
TerminalCapabilities::__construct()
public function __construct(string $term = '', string $termProgram = '', string $colorTerm = ''):Parameters
| Name | Type | Description |
|---|---|---|
| $term | string | |
| $termProgram | string | |
| $colorTerm | string |
TerminalCapabilities::fromEnvironment()
public static function fromEnvironment(): selfBuilds a capabilities snapshot from the current `$_ENV` / `getenv()` state. The caller usually wants this at bootstrap.
TerminalCapabilities::imageProtocol()
public function imageProtocol(): stringReturns the inline-image protocol this terminal is known to support: {@see IMAGES_KITTY} for Kitty/Ghostty/WezTerm, {@see IMAGES_ITERM2} for iTerm2, {@see IMAGES_NONE} otherwise.
TerminalCapabilities::supportsKittyKeyboard()
public function supportsKittyKeyboard(): boolWhether the terminal supports the Kitty keyboard protocol. The caller still has to negotiate it at runtime by emitting the query and reading the flags from the response; this is just the static hint that the negotiation is worth doing.
TerminalCapabilities::supportsSynchronizedOutput()
public function supportsSynchronizedOutput(): boolWhether the terminal is known to support the synchronized-output mode (CSI 2026). Most modern terminals do; the notable holdout is the macOS Terminal.app, which ignores the escapes but still works fine without atomic writes.
TerminalCapabilities::supportsOsc11()
public function supportsOsc11(): boolWhether the terminal is known to support OSC 11 background-color queries. Used by {@see TerminalColor} to decide whether to emit the query at startup. Conservative: returns true unless we know for a fact the terminal does not answer (e.g. dumb terminals).
TerminalCapabilities::supportsTruecolor()
public function supportsTruecolor(): boolWhether the terminal is known to support 24-bit color (truecolor). Matches the `COLORTERM=truecolor` convention xterm/Kitty/WezTerm set, plus the known-truecolor terminal program names.