Skip to main content

Probe

Struct Probe 

Source
pub struct Probe {
    pub eaw_width: bool,
    pub modes: Vec<Mode>,
    pub kitty_keyboard: bool,
    pub terminal_name: bool,
    pub modify_other_keys: bool,
    pub termcap: Option<Vec<String>>,
    pub foreground_color: bool,
    pub background_color: bool,
    pub cursor_color: bool,
    pub palette_colors: Vec<u8>,
    pub program_status: bool,
    /* private fields */
}
Expand description

Select the terminal queries to write.

new captures environment restrictions and selects session modes, keyboard protocols, terminal identity, and truecolor support. Cursor measurements and color-value queries remain opt-in.

query_capabilities returns an application-owned record. Pass matching events to Capabilities::record, then call Program::apply_defaults to apply the core results according to ProgramOptions.

Fields§

§eaw_width: bool

Measure East Asian Ambiguous width with one cursor position request.

This writes U+2026 at column zero, requests the cursor position, then erases two cells. Select it on a blank row with at least three columns. The cursor finishes at column zero. The caller updates its screen’s tracked cursor and invalidates the erased content before rendering.

§modes: Vec<Mode>

Request these ANSI and DEC modes in list order, including duplicates.

Apple Terminal skips these requests. A record keeps every mode reply. Program::apply_defaults applies supported defaults according to the program options.

§kitty_keyboard: bool

Query the active Kitty keyboard enhancements.

§terminal_name: bool

Request the terminal name and version with XTVERSION.

Apple Terminal skips this request.

§modify_other_keys: bool

Query the active xterm modifyOtherKeys mode.

Apple Terminal skips this request.

§termcap: Option<Vec<String>>

Select XTGETTCAP requests.

None automatically requests RGB and Tc when the captured environment does not establish truecolor support. Some(names) requests exactly those names in list order, including duplicates. An empty list skips all termcap requests. Explicit names are requested even when detection reports truecolor. Apple Terminal skips these requests.

§foreground_color: bool

Query the terminal’s default foreground color.

§background_color: bool

Query the terminal’s default background color.

§cursor_color: bool

Query the cursor color.

§palette_colors: Vec<u8>

Query these palette entries in list order, including duplicates.

§program_status: bool

Query the accepted OSC 7501 program states and kinds.

Implementations§

Source§

impl Probe

Source

pub fn new(env: &dyn Env) -> Self

Select common session queries using the supplied environment.

Selects synchronized output, Unicode core, in-band resize, Kitty keyboard, terminal name, and modifyOtherKeys. Selects RGB/Tc termcap queries when Profile::detect_from with is_tty = true reports a profile below truecolor. Program color overrides do not affect selection. Set flags to false, clear mode lists, or set termcap to Some(vec![]) to omit selected queries. Cursor measurements and color-value queries start disabled.

The probe owns the relevant values read from env. The caller can release the environment borrow before it borrows an output writer. Create another probe to use a changed environment.

Source

pub fn query_capabilities<W: Write>( &self, writer: &mut W, terminator: bool, ) -> Result<Capabilities>

Write selected queries and return a record initialized for their replies.

The order is ambiguous width, Kitty keyboard, modes, terminal name, modifyOtherKeys, XTGETTCAP, foreground, background, cursor color, palette entries, and program status. Apple Terminal skips mode, terminal-name, modifyOtherKeys, and XTGETTCAP requests.

Set terminator on the last probe in a batch to append Primary DA. The caller flushes the writer once after all probes have written. Errors propagate from the writer; an error can follow a partial write. The probe’s configuration stays unchanged.

Read replies through the application’s input loop with a deadline. Route cursor reports to their records in request order. The selected width query takes the first cursor report routed to this record. On DA1, pass the event to every record before ending initial collection. Identified replies can update a record after that point.

Cursor reports and DA1 carry no request ID. Finish earlier requests before this batch and keep unrelated cursor requests out of it. A timeout leaves outstanding requests active. Multiplexer forwarding can also deliver an extension reply after DA1.

On row one, a standard cursor reply can also decode as modified F3. See Event::CursorPosition for the input ambiguity and application handling.

let mut program = Program::stdio()?;
let mut probe = Probe::new(program.env());
probe.background_color = true;
let mut caps = probe.query_capabilities(program.screen_mut(), true)?;
program.screen_mut().flush()?;

Trait Implementations§

Source§

impl Clone for Probe

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Probe

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Probe

§

impl RefUnwindSafe for Probe

§

impl Send for Probe

§

impl Sync for Probe

§

impl Unpin for Probe

§

impl UnsafeUnpin for Probe

§

impl UnwindSafe for Probe

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
§

impl<T> ErasedDestructor for T
where T: 'static,

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.