pub struct Capabilities { /* private fields */ }Expand description
What the terminal told us about itself.
This holds the replies themselves, not a summary of them: the
ModeSetting reported for every mode that was asked about, the raw
device-attribute lists, the reported colors, and so on. A reply that says
“I do not recognize that” is recorded too, so None from an accessor
generally means the terminal never answered, which is different from
answering no. termcap is the exception, folding both
into None; use termcap_reports to separate
them.
Capability values are what the terminal reported, not what the facade
told it. The two are easy to confuse where both exist: a
background_color recorded here stays the
terminal’s own default even after
set_background_color overrides
it.
Capability values come from replies, so questions the environment can
also answer are deliberately absent. Direct-color support is the example:
COLORTERM and TERM establish it as readily as an XTGETTCAP reply does.
The answer is Screen::color_profile,
which folds in both, and what remains here is the reply itself via
supports_termcap.
The application owns this record.
Probe::query_capabilities sends the
queries and returns a record for that batch. The record also keeps the
modes queried by the probe. Pass events from your own read loop, sync or
async, to record. The record keeps
each core reply about the terminal. The application detects the final
Primary DA event, then calls
apply_defaults to act on the record.
The record accepts every reply that describes the terminal, whichever way
the question was put. An individual request_* method fills a single
entry, and a few reports arrive unprompted once their mode is on, such as
a color-scheme change under DEC mode 2031. A Default record has no
pending measurement, so it collects identified replies.
Implementations§
Source§impl Capabilities
impl Capabilities
Sourcepub fn record(&mut self, event: &Event)
pub fn record(&mut self, event: &Event)
Update the core results from event.
The event is only read, so your loop still handles it as usual. Pass each relevant event once, in arrival order. The application owns the deadline and detects Primary DA. Pass Primary DA here before ending initial collection so it closes the pending width measurement.
Cursor and Primary DA replies carry no request ID. The record takes
the first cursor report routed here as the pending width measurement.
The caller routes cursor reports according to its query order. See
Probe::query_capabilities for the
request order that this needs.
Keep calling this after the batch is complete to record late replies,
mid-session request_* replies, and unprompted reports. A DECRPSS
Event::SettingReport is not recorded: it does not say which
setting it answers, so match it against your own DECRQSS request.
Sourcepub fn eaw_width(&self) -> Option<u8>
pub fn eaw_width(&self) -> Option<u8>
Measured East Asian Ambiguous width: one or two terminal columns.
None means the probe has not returned a valid width.
Probe::query_capabilities
measures U+2026 (HORIZONTAL ELLIPSIS) when selected.
Program::apply_defaults
applies the result to Screen::set_ambiguous_wide.
Sourcepub fn queried_modes(&self) -> &[Mode]
pub fn queried_modes(&self) -> &[Mode]
Modes queried by the probe that created this record, in request order.
This list includes duplicates and contains only this probe’s mode queries. Apple Terminal skips the probe’s mode queries, so its list is empty. A default record has an empty list. Recording later replies does not change this list.
Sourcepub fn mode(&self, mode: Mode) -> Option<ModeSetting>
pub fn mode(&self, mode: Mode) -> Option<ModeSetting>
The ModeSetting the terminal reported for mode, or None if it
never reported on that mode.
Use this when the distinction matters: ModeSetting::Set means the
mode is currently on, ModeSetting::PermanentlySet means it cannot
be turned off, and ModeSetting::NotRecognized is a definite “no”
rather than silence.
Sourcepub fn supports(&self, mode: Mode) -> bool
pub fn supports(&self, mode: Mode) -> bool
Whether the terminal reported mode as available, in any state.
use uncurses::ansi::mode::Mode;
if caps.supports(Mode::MOUSE_SGR_PIXEL) {
// pixel-accurate mouse reporting is available
}Sourcepub fn modes(&self) -> &BTreeMap<Mode, ModeSetting>
pub fn modes(&self) -> &BTreeMap<Mode, ModeSetting>
Every mode report recorded so far, keyed by mode.
Sourcepub fn primary_device_attributes(&self) -> Option<&[Option<u32>]>
pub fn primary_device_attributes(&self) -> Option<&[Option<u32>]>
The raw Primary DA (CSI c) attribute list, or None if the terminal
never answered. Entries are None where the terminal sent an empty
parameter.
The first parameter is the terminal’s architectural service class, not
a capability: 6 identifies a VT102 and 64 a VT420. Capability
numbers live in the parameters after it in modern replies. VT100-style
replies use different meanings for those parameters. Modern terminals
may also report extensions with class 61.
The capability numbers are assigned by DEC and extended by terminal authors, so they are reported unparsed.
Sourcepub fn clipboard_write(&self) -> bool
pub fn clipboard_write(&self) -> bool
Whether a Primary DA reply with class 61 or greater reports OSC 52 writes.
This reports the clipboard extension for the system clipboard or an
empty selector. It does not confirm clipboard reads. false means
support is unconfirmed.
Sourcepub fn secondary_device_attributes(&self) -> Option<&[Option<u32>]>
pub fn secondary_device_attributes(&self) -> Option<&[Option<u32>]>
The raw Secondary DA (CSI > c) attribute list, or None if the
terminal never answered. Conventionally terminal type, firmware
version, and hardware option, but the meaning of each entry varies by
terminal, so it is reported unparsed.
Sourcepub fn tertiary_device_attributes(&self) -> Option<&str>
pub fn tertiary_device_attributes(&self) -> Option<&str>
The Tertiary DA (CSI = c) terminal unit ID, or None if the
terminal never answered.
Sourcepub fn program_status(&self) -> Option<&ProgramStatusCapabilities>
pub fn program_status(&self) -> Option<&ProgramStatusCapabilities>
Accepted OSC 7501 states and kinds, or None before a reply.
None means support remains unconfirmed. A reply confirms support
even when both lists are empty. The decoder supplies fixed defaults
for absent fields and preserves names from protocol extensions.
Send a query with Program::request_program_status.
Sourcepub fn kitty_keyboard(&self) -> Option<KittyKeyboardFlags>
pub fn kitty_keyboard(&self) -> Option<KittyKeyboardFlags>
The Kitty keyboard enhancements the terminal reported, or None if it
never answered CSI ? u. An answer of
empty means the protocol is supported
with no enhancements currently active.
Sourcepub fn modify_other_keys(&self) -> Option<ModifyOtherKeysMode>
pub fn modify_other_keys(&self) -> Option<ModifyOtherKeysMode>
The xterm modifyOtherKeys mode the terminal reported, or None if it
never answered CSI ? 4 m.
Sourcepub fn terminal_name(&self) -> Option<&str>
pub fn terminal_name(&self) -> Option<&str>
The terminal’s self-reported name from XTVERSION (for example
"XTerm(380)"), or None if it never answered.
Sourcepub fn termcap(&self, name: &str) -> Option<&str>
pub fn termcap(&self, name: &str) -> Option<&str>
The value the terminal reported for the XTGETTCAP capability name,
or None if it reported the capability as unsupported or was never
asked. Boolean capabilities report an empty string, so use
supports_termcap to test for presence.
Sourcepub fn supports_termcap(&self, name: &str) -> bool
pub fn supports_termcap(&self, name: &str) -> bool
Whether the terminal reported the XTGETTCAP capability name as
supported. false both for a capability reported unsupported and for
one never asked about; tell them apart with
termcap_reports.
Sourcepub fn termcap_reports(&self) -> &BTreeMap<String, Option<String>>
pub fn termcap_reports(&self) -> &BTreeMap<String, Option<String>>
Every XTGETTCAP reply recorded so far, keyed by capability name. A
value of None is the terminal reporting that capability as
unsupported, which is different from the key being absent.
Sourcepub fn foreground_color(&self) -> Option<Color>
pub fn foreground_color(&self) -> Option<Color>
The terminal’s default foreground color (OSC 10), or None if it
never answered.
Sourcepub fn background_color(&self) -> Option<Color>
pub fn background_color(&self) -> Option<Color>
The terminal’s default background color (OSC 11), or None if it
never answered.
Sourcepub fn cursor_color(&self) -> Option<Color>
pub fn cursor_color(&self) -> Option<Color>
The terminal’s cursor color (OSC 12), or None if it never
answered.
Sourcepub fn palette_color(&self, index: u8) -> Option<Color>
pub fn palette_color(&self, index: u8) -> Option<Color>
The color the terminal reported for palette entry index
(OSC 4 ; index ; ?), or None if it never answered for that entry.
Sourcepub fn palette(&self) -> &BTreeMap<u8, Color>
pub fn palette(&self) -> &BTreeMap<u8, Color>
Every palette color reported so far, keyed by index.
Sourcepub fn color_scheme(&self) -> Option<ColorScheme>
pub fn color_scheme(&self) -> Option<ColorScheme>
Whether the terminal is in its dark or light scheme (DEC mode 2031),
or None if it never reported one. Updated as the scheme changes
while enable_color_scheme_updates
is on. This is the terminal’s own preference flag, which a terminal
can report independently of the colors it uses; when it is absent,
background_color is the fallback.