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: boolMeasure 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: boolQuery the active Kitty keyboard enhancements.
terminal_name: boolRequest the terminal name and version with XTVERSION.
Apple Terminal skips this request.
modify_other_keys: boolQuery 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: boolQuery the terminal’s default foreground color.
background_color: boolQuery the terminal’s default background color.
cursor_color: boolQuery the cursor color.
palette_colors: Vec<u8>Query these palette entries in list order, including duplicates.
program_status: boolQuery the accepted OSC 7501 program states and kinds.
Implementations§
Source§impl Probe
impl Probe
Sourcepub fn new(env: &dyn Env) -> Self
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.
Sourcepub fn query_capabilities<W: Write>(
&self,
writer: &mut W,
terminator: bool,
) -> Result<Capabilities>
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()?;