class
Tput::Emulator
- Tput::Emulator
- Reference
- Object
Overview
Class for terminal emulator program detection.
Best-effort only: detection relies on environment variables, which are inherited by child processes. E.g. opening an xterm inside an lxterminal propagates xterm-specific env vars into lxterm, confusing the detection.
Included Modules
- Crystallabs::Helpers::Boolean
- Crystallabs::Helpers::Logging
- JSON::Serializable
Defined in:
tput/dump.crtput/emulator.cr
Constant Summary
-
Log =
::Log.for((self.name.gsub("::", '.')).underscore) -
OCTANT_SUPPORT =
Hash(String, String | ::Nil) {"iTerm2" => nil, "Apple Terminal" => nil, "kitty" => "0.40.0", "Ghostty" => "1.1.0", "WezTerm" => nil, "foot" => "1.19.0"} -
Per-terminal octant (U+1CD00) support; same format as
SEXTANT_SUPPORT. Octants are Unicode 16.0 (2024), so even self-rendering terminals only gained them recently — encode those asidentity => "min.version". -
SEXTANT_SUPPORT =
Hash(String, String | ::Nil) {"iTerm2" => nil, "Apple Terminal" => nil} -
Per-terminal sextant (U+1FB00) support. Key is
#identity; value is the minimum#versionthat supports it, ornilfor "not supported at any version". Terminals absent from the table are trusted (optimistic default).
Constructors
- .new(pull : JSON::PullParser)
-
.new(tput : Tput)
Creates an instance of
Featuresand performs the autodetection.
Class Method Summary
-
.modern_font_env?(env = ENV) : Bool
Whether env alone identifies one of the
#modern_font?terminals (kitty, WezTerm, Ghostty, iTerm2).
Instance Method Summary
-
#best_graphics : GraphicsProtocol
The most capable in-band graphics protocol this terminal advertises.
-
#detections : Hash(String, Tput::Detection)
{name => Detection}for every emulator flag, with provenance. -
#foot=(foot : Bool)
Is the emulator foot? (graphics-capable)
-
#foot? : Bool
Is the emulator foot? (graphics-capable)
-
#ghostty=(ghostty : Bool)
Is the emulator Ghostty? (graphics-capable)
-
#ghostty? : Bool
Is the emulator Ghostty? (graphics-capable)
- #graphics_detections : Hash(String, Tput::Detection)
-
#identity : String | Nil
Best-guess canonical product name, or
nilif nothing matched. - #inspect(io)
-
#iterm2=(iterm2 : Bool)
Is the emulator iTerm2?
-
#iterm2? : Bool
Is the emulator iTerm2?
-
#iterm_images? : Bool
Whether the terminal renders iTerm2 inline images (OSC 1337).
-
#kitty=(kitty : Bool)
Is the emulator kitty? (graphics-capable)
-
#kitty? : Bool
Is the emulator kitty? (graphics-capable)
-
#kitty_graphics? : Bool
Whether the terminal speaks the kitty graphics protocol.
-
#konsole=(konsole : Bool)
Is the emulator KDE Konsole? (graphics-capable)
-
#konsole? : Bool
Is the emulator KDE Konsole? (graphics-capable)
-
#legacy_computing_octant? : Bool
Whether the terminal reliably renders legacy-computing octants (U+1CD00…).
-
#legacy_computing_sextant? : Bool
Whether the terminal reliably renders legacy-computing sextants (U+1FB00…).
-
#lxterm=(lxterm : Bool)
Is the emulator LXDE's lxterm?
-
#lxterm? : Bool
Is the emulator LXDE's lxterm?
-
#mlterm=(mlterm : Bool)
Is the emulator mlterm? (graphics-capable)
-
#mlterm? : Bool
Is the emulator mlterm? (graphics-capable)
-
#modern_font? : Bool
Whether the terminal ships with (or is overwhelmingly configured with) a modern, well-covered monospace font — fancy dingbats, geometric shapes beyond the WGL4 set, emoji.
-
#multiplexer : String | Nil
The terminal multiplexer the program is running inside (
tmux/screen), ornil. -
#osxterm=(osxterm : Bool)
Is the emulator Mac OS X terminal?
-
#osxterm? : Bool
Is the emulator Mac OS X terminal?
-
#refine_from_probe! : Nil
Refines identity from the probed XTVERSION string.
-
#rxvt=(rxvt : Bool)
Is the emulator rxvt?
-
#rxvt? : Bool
Is the emulator rxvt?
-
#screen=(screen : Bool)
Is the emulator screen?
-
#screen? : Bool
Is the emulator screen?
- #self_reported? : Bool
-
#sixel? : Bool
Whether the terminal renders sixel graphics.
-
#sources : Hash(String, String)
For each emulator flag (by name), a description of how it was determined (env var, terminfo/TERM name, etc.).
-
#term_program : String
The raw
$TERM_PROGRAMvalue the emulator advertised (""if unset). -
#term_program_version : String
The raw
$TERM_PROGRAM_VERSIONvalue (""if unset). -
#terminator=(terminator : Bool)
Is the emulator terminator?
-
#terminator? : Bool
Is the emulator terminator?
-
#tmux=(tmux : Bool)
Is the emulator tmux?
-
#tmux? : Bool
Is the emulator tmux?
-
#version : String | Nil
Best-effort version string for the identified terminal, or
nil. -
#vte=(vte : Bool)
Is the emulator based on VTE?
-
#vte? : Bool
Is the emulator based on VTE?
-
#wezterm=(wezterm : Bool)
Is the emulator WezTerm? (graphics-capable)
-
#wezterm? : Bool
Is the emulator WezTerm? (graphics-capable)
-
#xfce=(xfce : Bool)
Is the emulator XFCE's terminal?
-
#xfce? : Bool
Is the emulator XFCE's terminal?
-
#xterm=(xterm : Bool)
Is the emulator xterm?
-
#xterm? : Bool
Is the emulator xterm?
Constructor Detail
Creates an instance of Features and performs the autodetection.
Class Method Detail
Whether env alone identifies one of the #modern_font? terminals
(kitty, WezTerm, Ghostty, iTerm2). The static counterpart for consumers
that must answer from an env snapshot with no live tty/Tput — e.g. a
headless layout pass choosing a glyph tier. The instance predicate is
sharper: it also folds in the terminal name and XTVERSION probe
refinement, so prefer it whenever a Tput exists.
Instance Method Detail
The most capable in-band graphics protocol this terminal advertises.
GraphicsProtocol::None means "no pixel graphics; use cell/glyph rendering".
{name => Detection} for every emulator flag, with provenance.
{name => Detection} for the derived graphics capabilities — computed
from the emulator flags above rather than detected directly, so they have
no #sources entry and carry a synthesized provenance instead.
Best-guess canonical product name, or nil if nothing matched. Concrete
products are preferred over generic families (vte/xterm); multiplexers
are reported separately via #multiplexer.
Whether the terminal reliably renders legacy-computing octants (U+1CD00…).
Whether the terminal reliably renders legacy-computing sextants (U+1FB00…).
Whether the terminal ships with (or is overwhelmingly configured with) a
modern, well-covered monospace font — fancy dingbats, geometric shapes
beyond the WGL4 set, emoji. Like the legacy-computing ranges above, font
coverage has no escape-sequence probe (a missing glyph is same-width
tofu), so this is decided from terminal identity: the self-rendering
emulators that bundle capable font stacks. Product flags are hardened by
#refine_from_probe! (XTVERSION), so a post-probe answer outranks env
leakage. Distinct from #legacy_computing_sextant?/octant?: iTerm2's
bundled fonts cover dingbats/emoji but not the legacy-computing ranges.
The terminal multiplexer the program is running inside (tmux/screen),
or nil. Separate from #identity since a multiplexer wraps, but doesn't
replace, the real terminal underneath.
Refines identity from the probed XTVERSION string. Called by Tput#probe!.
Whether #identity/#version rest on the terminal's own self-report
(XTVERSION, via Tput#probe!) rather than env/TERM heuristics.
Whether the terminal renders sixel graphics. True for known sixel
emulators, or when a DA1 probe reply lists sixel support (device
attribute 4). Plain xterm needs -ti vt340 and isn't detectable from
env alone, so probe it for certainty.
For each emulator flag (by name), a description of how it was determined
(env var, terminfo/TERM name, etc.). Surfaced via Tput#dump.
The raw $TERM_PROGRAM value the emulator advertised ("" if unset). Many
emulators (Apple Terminal, iTerm2, WezTerm, VS Code, …) self-identify here;
paired with #term_program_version.
Best-effort version string for the identified terminal, or nil. Prefers
the terminal's own XTVERSION self-report (populated by Tput#probe!),
falling back to $TERM_PROGRAM_VERSION. XTVERSION usually arrives as
name(1.2.3) or name 1.2.3; the bare version is extracted when present.