TermUI.Capabilities (TermUI v0.2.0)
View SourceTerminal capability detection and management.
Detects terminal capabilities through multiple methods:
- Environment variables ($TERM, $COLORTERM, $TERM_PROGRAM, $LANG)
- Terminfo database queries
- Conservative VT100 fallbacks
Results are cached in ETS for fast concurrent access.
Summary
Functions
Clears the cached capabilities.
Returns the color mode.
Detects terminal capabilities and caches them in ETS.
Returns cached capabilities, detecting if not yet cached.
Returns the maximum number of colors supported.
Returns true if terminal supports 256 colors or better.
Returns true if terminal supports alternate screen buffer.
Returns true if terminal supports bracketed paste mode.
Returns true if terminal supports focus event reporting.
Returns true if terminal supports mouse tracking.
Returns true if terminal supports true-color (24-bit RGB).
Returns true if terminal supports Unicode.
Types
@type color_mode() :: :true_color | :color_256 | :color_16 | :monochrome
@type t() :: %TermUI.Capabilities{ alternate_screen: boolean(), bracketed_paste: boolean(), color_mode: color_mode(), focus_events: boolean(), max_colors: non_neg_integer(), mouse: boolean(), terminal_program: String.t() | nil, terminal_type: String.t() | nil, unicode: boolean() }
Functions
@spec clear_cache() :: :ok
Clears the cached capabilities.
@spec color_mode() :: color_mode()
Returns the color mode.
@spec detect() :: t()
Detects terminal capabilities and caches them in ETS.
Returns the detected capabilities struct.
@spec get() :: t()
Returns cached capabilities, detecting if not yet cached.
@spec max_colors() :: non_neg_integer()
Returns the maximum number of colors supported.
@spec supports_256_color?() :: boolean()
Returns true if terminal supports 256 colors or better.
@spec supports_alternate_screen?() :: boolean()
Returns true if terminal supports alternate screen buffer.
@spec supports_bracketed_paste?() :: boolean()
Returns true if terminal supports bracketed paste mode.
@spec supports_focus_events?() :: boolean()
Returns true if terminal supports focus event reporting.
@spec supports_mouse?() :: boolean()
Returns true if terminal supports mouse tracking.
@spec supports_true_color?() :: boolean()
Returns true if terminal supports true-color (24-bit RGB).
@spec supports_unicode?() :: boolean()
Returns true if terminal supports Unicode.