Skip to main content

TerminalCapabilities

Struct TerminalCapabilities 

Source
pub struct TerminalCapabilities {
Show 17 fields pub true_color: bool, pub colors_256: bool, pub unicode_box_drawing: bool, pub unicode_emoji: bool, pub double_width: bool, pub sync_output: bool, pub osc8_hyperlinks: bool, pub scroll_region: bool, pub in_tmux: bool, pub in_screen: bool, pub in_zellij: bool, pub in_wezterm_mux: bool, pub kitty_keyboard: bool, pub focus_events: bool, pub bracketed_paste: bool, pub mouse_sgr: bool, pub osc52_clipboard: bool, /* private fields */
}
Expand description

Terminal capability model.

This struct describes what features a terminal supports. Use detect to auto-detect from the environment, or basic for a minimal fallback.

§Predefined Profiles

For testing and simulation, use predefined profiles:

Fields§

§true_color: bool

True color (24-bit RGB) support.

§colors_256: bool

256-color palette support.

§unicode_box_drawing: bool

Unicode box-drawing support.

§unicode_emoji: bool

Emoji glyph support.

§double_width: bool

Double-width glyph support (CJK/emoji).

§sync_output: bool

Synchronized output (DEC mode 2026) to reduce flicker.

§osc8_hyperlinks: bool

OSC 8 hyperlinks support.

§scroll_region: bool

Scroll region support (DECSTBM).

§in_tmux: bool

Running inside tmux.

§in_screen: bool

Running inside GNU screen.

§in_zellij: bool

Running inside Zellij.

§in_wezterm_mux: bool

Running inside a WezTerm mux-served session.

Detected via WEZTERM_UNIX_SOCKET and WEZTERM_PANE, which WezTerm exports for pane processes and mux-attached clients.

§kitty_keyboard: bool

Kitty keyboard protocol support.

§focus_events: bool

Focus event reporting support.

§bracketed_paste: bool

Bracketed paste mode support.

§mouse_sgr: bool

SGR mouse protocol support.

§osc52_clipboard: bool

OSC 52 clipboard support (best-effort, security restricted in some terminals).

Implementations§

Source§

impl TerminalCapabilities

Source

pub fn with_overrides() -> TerminalCapabilities

Detect capabilities and apply any active thread-local overrides.

This is the recommended way to get capabilities in code that may be running under test with overrides.

Source

pub fn with_overrides_from( self, base: TerminalCapabilities, ) -> TerminalCapabilities

Apply overrides to these capabilities.

Source§

impl TerminalCapabilities

Source

pub const fn profile(&self) -> TerminalProfile

Get the profile identifier for this capability set.

Source

pub fn profile_name(&self) -> Option<&'static str>

Get the profile name as a string.

Returns None for detected capabilities (use profile() to distinguish between profiles).

Source

pub fn from_profile(profile: TerminalProfile) -> TerminalCapabilities

Create capabilities from a profile identifier.

Source

pub const fn modern() -> TerminalCapabilities

Modern terminal with all features enabled.

Represents terminals like WezTerm, Alacritty, Ghostty, Kitty, iTerm2. All advanced features are enabled.

Source

pub const fn xterm_256color() -> TerminalCapabilities

xterm with 256-color support.

Standard xterm-256color profile with common features. No true color, no sync output, no hyperlinks.

Source

pub const fn xterm() -> TerminalCapabilities

Basic xterm with 16 colors only.

Minimal xterm without 256-color or advanced features.

Source

pub const fn vt100() -> TerminalCapabilities

VT100 terminal (minimal capabilities).

Classic VT100 with basic cursor control, no colors.

Source

pub const fn dumb() -> TerminalCapabilities

Dumb terminal with no capabilities.

Alias for basic() with the Dumb profile identifier.

Source

pub const fn screen() -> TerminalCapabilities

GNU Screen multiplexer.

Screen with 256 colors but multiplexer-safe settings. Sync output and scroll region disabled for passthrough safety.

Source

pub const fn tmux() -> TerminalCapabilities

tmux multiplexer.

tmux with 256 colors and multiplexer detection. Advanced features disabled for passthrough safety.

Source

pub const fn zellij() -> TerminalCapabilities

Zellij multiplexer.

Zellij with true color (it has better passthrough than tmux/screen).

Source

pub const fn windows_console() -> TerminalCapabilities

Windows Console Host.

Windows Terminal with good color support but some quirks.

Source

pub const fn kitty() -> TerminalCapabilities

Kitty terminal.

Kitty with full feature set including keyboard protocol.

Source

pub const fn linux_console() -> TerminalCapabilities

Linux console (framebuffer console).

Linux console with no colors and basic features.

Source

pub fn builder() -> CapabilityProfileBuilder

Create a builder for custom capability profiles.

Start with all capabilities disabled and enable what you need.

Source§

impl TerminalCapabilities

Source

pub fn detect() -> TerminalCapabilities

Detect terminal capabilities from the environment.

This examines environment variables to determine what features the current terminal supports. When in doubt, capabilities are disabled for safety.

Source

pub const fn basic() -> TerminalCapabilities

Create a minimal fallback capability set.

This is safe to use on any terminal, including dumb terminals. All advanced features are disabled.

Source

pub const fn in_any_mux(&self) -> bool

Check if running inside any terminal multiplexer.

This includes tmux, GNU screen, Zellij, and WezTerm mux.

Source

pub const fn has_color(&self) -> bool

Check if any color support is available.

Source

pub const fn color_depth(&self) -> &'static str

Get the maximum color depth as a string identifier.

Source

pub const fn use_sync_output(&self) -> bool

Whether synchronized output (DEC 2026) should be used.

Disabled in multiplexers because passthrough is unreliable for mode-setting sequences. Also disabled for all WezTerm sessions as a safety fallback due observed DEC 2026 instability in mux workflows.

Source

pub const fn use_scroll_region(&self) -> bool

Whether scroll-region optimization (DECSTBM) is safe to use.

Disabled in multiplexers due to inconsistent scroll margin handling across tmux/screen/zellij and WezTerm mux sessions.

Whether OSC 8 hyperlinks should be emitted.

Disabled in mux environments because passthrough for OSC sequences is fragile and behavior varies by mux implementation.

Source

pub const fn use_clipboard(&self) -> bool

Whether OSC 52 clipboard access should be used.

Gated by mux detection in detect(), and re-checked here to keep policy behavior consistent for overridden/custom capability sets.

Source

pub const fn needs_passthrough_wrap(&self) -> bool

Whether the passthrough wrapping is needed for this environment.

Returns true if running in tmux or screen, which require DCS passthrough for escape sequences to reach the inner terminal. Zellij handles passthrough natively and doesn’t need wrapping.

Trait Implementations§

Source§

impl Clone for TerminalCapabilities

Source§

fn clone(&self) -> TerminalCapabilities

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TerminalCapabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for TerminalCapabilities

Source§

fn default() -> TerminalCapabilities

Returns the “default value” for a type. Read more
Source§

impl PartialEq for TerminalCapabilities

Source§

fn eq(&self, other: &TerminalCapabilities) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for TerminalCapabilities

Source§

impl Eq for TerminalCapabilities

Source§

impl StructuralPartialEq for TerminalCapabilities

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.