pub struct Term { /* private fields */ }Expand description
Owns the authoritative screen state and applies VT actions to it.
Implementations§
Source§impl Term
impl Term
pub fn new(cols: usize, rows: usize) -> Self
pub fn with_scrollback( cols: usize, rows: usize, scrollback_limit: usize, ) -> Self
Sourcepub fn damage(&self) -> TermDamage
pub fn damage(&self) -> TermDamage
What changed since the last reset_damage() — line ranges, each with a
changed column span. See ADR-0003.
Sourcepub fn reset_damage(&mut self)
pub fn reset_damage(&mut self)
Clear accumulated damage. The consumer calls this after applying a frame
(the ack); the next damage() reflects only changes since.
Sourcepub fn mark_fully_damaged(&mut self)
pub fn mark_fully_damaged(&mut self)
Mark the whole screen damaged (alt switch / clear / flood, and a consumer
reattach that needs a full re-sync — see crate::Engine::mark_fully_damaged).
Sourcepub fn scroll_delta(&self) -> Option<ScrollOp>
pub fn scroll_delta(&self) -> Option<ScrollOp>
The first-class scroll recorded since the last reset_damage, if any.
Suppressed while scrolled up — a content scroll must not shift the frozen
viewport.
Sourcepub fn frame(&self) -> Frame
pub fn frame(&self) -> Frame
Build a serializable Frame from the current damage + grid + grapheme
pool (#6). Full ships every row; Partial ships the damaged spans. The
global side-table is remapped to frame-local indices — the engine pool
is append-only and leaky, so a frame carries only the clusters its cells
reference, renumbered, with each cell’s extra rewritten to the local id.
Sourcepub fn scrollback_len(&self) -> usize
pub fn scrollback_len(&self) -> usize
Number of lines currently held in scrollback history.
Sourcepub fn synchronized_output(&self) -> bool
pub fn synchronized_output(&self) -> bool
Whether the app has an open synchronized-output block (DEC ?2026, #73).
Sourcepub fn color_scheme_updates(&self) -> bool
pub fn color_scheme_updates(&self) -> bool
Whether the app enabled color-scheme-update notifications (DEC ?2031, #85).
Sourcepub fn grapheme_clustering(&self) -> bool
pub fn grapheme_clustering(&self) -> bool
Whether the app enabled grapheme-cluster mode (DEC ?2027, #295): emoji ZWJ / skin-tone / flag / VS16 sequences are clustered into one cell. OFF (default) is per-char, wcwidth-compat.
Sourcepub fn win32_input_mode(&self) -> bool
pub fn win32_input_mode(&self) -> bool
Whether the app enabled win32-input-mode (DEC ?9001, #86). The engine does not encode the raw key-records itself (a non-goal); a ConPTY consumer reads this to decide whether to emit them.
Sourcepub fn report_color_scheme(&mut self, dark: bool)
pub fn report_color_scheme(&mut self, dark: bool)
Queue a color-scheme report (CSI ? 997 ; 1 n dark / ; 2 n light) on the
reply channel. The consumer calls this to answer a ColorSchemeQuery event
or, when its scheme changes and color_scheme_updates() is set, to send the
unsolicited notification. The engine never stores or interprets the scheme
(#85).
Sourcepub fn report_palette_color(&mut self, index: u8, spec: &str)
pub fn report_palette_color(&mut self, index: u8, spec: &str)
Answer an OSC 4 palette query (#122): wrap the consumer-supplied spec for
index in the OSC 4 reply envelope, ST-terminated.
Sourcepub fn report_foreground(&mut self, spec: &str)
pub fn report_foreground(&mut self, spec: &str)
Answer an OSC 10 foreground query (#122): wrap the consumer-supplied spec in the OSC 10 reply envelope, ST-terminated.
Sourcepub fn report_background(&mut self, spec: &str)
pub fn report_background(&mut self, spec: &str)
Answer an OSC 11 background query (#122): wrap the consumer-supplied spec (it knows its palette) in the OSC 11 reply envelope, ST-terminated. The engine formats the envelope only — it never knows the colour.
Sourcepub fn viewport_line(&self, i: usize) -> &[Cell]
pub fn viewport_line(&self, i: usize) -> &[Cell]
The cells of visible row i (0..rows) at the current scroll position.
The viewport windows into [history.. ; screen..]: rows above
scrollback.len() come from history, the rest from the live screen.
Sourcepub fn scroll_up(&mut self, n: usize)
pub fn scroll_up(&mut self, n: usize)
Scroll the viewport up by n lines into history (clamped to the oldest).
Sourcepub fn scroll_down(&mut self, n: usize)
pub fn scroll_down(&mut self, n: usize)
Scroll the viewport down by n lines toward the live screen.
Sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Jump the viewport back to the live screen (follow the bottom).
Sourcepub fn viewport_logical_lines(&self) -> Vec<LogicalLine>
pub fn viewport_logical_lines(&self) -> Vec<LogicalLine>
The viewport’s logical lines (#113/ADR-0017): each line’s text plus a
per-char map to its viewport (row, col). Wide-char spacers are skipped
and trailing blanks trimmed (so the text is 1:1 with cells). Empty rows
are dropped. The cell-aware assembly the consumer can’t do in frame mode.
Sourcepub fn search(&self, query: &str) -> Vec<Match>
pub fn search(&self, query: &str) -> Vec<Match>
Literal search over the whole buffer ([scrollback ++ screen]), returning
every non-overlapping match top-to-bottom in absolute coordinates. Matches
cross soft-wrapped rows (one logical line) and skip wide-char spacers.
Smart-case: a query with no uppercase matches case-insensitively.
Sourcepub fn search_with(&self, query: &str, opts: SearchOptions) -> Vec<Match>
pub fn search_with(&self, query: &str, opts: SearchOptions) -> Vec<Match>
Search with explicit SearchOptions — regex, whole-word, and a case-sensitivity override
on top of the literal + smart-case search (#314). Same coordinates,
soft-wrap join, spacer skip, and grapheme-mark inclusion (#304) as search.
Sourcepub fn search_scroll_to(&mut self, m: &Match)
pub fn search_scroll_to(&mut self, m: &Match)
Scroll the viewport so a match’s start line is visible (placed at the top when it sits in history; the live view when it is already on screen).
Sourcepub fn match_spans(&self, m: &Match) -> Vec<SelectionSpan>
pub fn match_spans(&self, m: &Match) -> Vec<SelectionSpan>
Project a match onto the current viewport as inclusive-column spans, one
per visible row (off-screen parts dropped) — for the renderer to
highlight, like selection_range.
Sourcepub fn set_search_highlights(&mut self, matches: Vec<Match>)
pub fn set_search_highlights(&mut self, matches: Vec<Match>)
Set the active search highlights to paint (#108). The consumer owns the
Vec<Match> (it drives next/prev); handing it back here lets frame()
project the highlights onto the viewport. An empty vec clears them.
pub fn add_marker(&mut self, row: usize) -> MarkerId
Sourcepub fn command_marks(&self) -> Vec<(MarkerId, usize, MarkerKind)>
pub fn command_marks(&self) -> Vec<(MarkerId, usize, MarkerKind)>
The OSC 133 command-boundary marks in buffer order — (id, absolute line, kind) (#158). Plain decoration markers (#118) are excluded. The consumer
pairs prompt/command/finished marks and drives navigation/announce policy
(#160); core only parses and anchors them.
Sourcepub fn command_lines(&self) -> Vec<CommandLine>
pub fn command_lines(&self) -> Vec<CommandLine>
The executed shell commands recovered from OSC-133 marks, in buffer order
(#166) — the data behind screen-reader command navigation. Each
CommandLine pairs a CommandStart(B) with the following OutputStart(C)
to extract the typed command (the prompt before B and the output after C
excluded via the captured columns, VSCode extractCommandLine parity), and
attaches the trailing CommandFinished(D) exit. A command still being typed
(B with no C yet) is not navigable — its text has no bound — so it is
omitted until output starts.
Sourcepub fn remove_marker(&mut self, id: MarkerId)
pub fn remove_marker(&mut self, id: MarkerId)
Remove a marker by id (#118). Disposing it fires MarkerDisposed so the
consumer’s cleanup is one path whether the marker left by eviction or by
this explicit call (xterm’s dispose() likewise always fires onDispose).
A no-op for an unknown/already-disposed id.
Sourcepub fn selection_begin(
&mut self,
row: usize,
col: usize,
side: Side,
ty: SelectionType,
)
pub fn selection_begin( &mut self, row: usize, col: usize, side: Side, ty: SelectionType, )
Begin a selection of ty at viewport (row, col), side.
Sourcepub fn selection_extend(&mut self, row: usize, col: usize, side: Side)
pub fn selection_extend(&mut self, row: usize, col: usize, side: Side)
Extend the live selection’s focus to viewport (row, col), side.
Sourcepub fn selection_clear(&mut self)
pub fn selection_clear(&mut self)
Clear the selection.
Sourcepub fn selection_range(&self) -> Vec<SelectionSpan>
pub fn selection_range(&self) -> Vec<SelectionSpan>
The selection projected onto the current viewport: one inclusive-column
span per visible row. Rows scrolled off-screen (above or below) are
dropped. Empty when nothing is selected. See SelectionSpan.
Sourcepub fn selection_text(&self) -> Option<String>
pub fn selection_text(&self) -> Option<String>
The selected text (for copy), or None when nothing is selected.
Sourcepub fn accessible_text(&self) -> String
pub fn accessible_text(&self) -> String
The whole buffer as one text document (#150): scrollback + screen assembled
into logical lines (soft-wrap joined, wide-spacers skipped, trailing blanks
trimmed at the logical end) — the accessible-view a screen reader reads as
a document, distinct from the viewport row tree (#119). Reuses the
selection extraction (extract_lines) over the full
range. On the alt screen only the alt buffer is shown — its “scrollback” is
the primary buffer’s, not this app’s — mirroring viewport_logical_lines’
alt floor.
Sourcepub fn resize(&mut self, cols: usize, rows: usize)
pub fn resize(&mut self, cols: usize, rows: usize)
Resize the screen to cols x rows. Rows dropped off the top (on shrink)
enter scrollback. Column reflow of soft-wrapped lines is layered on top
separately (#7). The whole screen is damaged.
pub fn grid(&self) -> &Grid
pub fn cursor(&self) -> &Cursor
Sourcepub fn bracketed_paste(&self) -> bool
pub fn bracketed_paste(&self) -> bool
Whether bracketed-paste mode (DEC ?2004) is enabled. The input encoder (#11) reads this to decide whether to wrap pasted text in markers.
Sourcepub fn encode_key(&self, ev: KeyEvent) -> Option<Vec<u8>>
pub fn encode_key(&self, ev: KeyEvent) -> Option<Vec<u8>>
Encode a key event to bytes using the active cursor-key mode (DECCKM)
and the kitty keyboard-protocol flags (encode_key consults both).
Sourcepub fn encode_mouse(&self, ev: MouseEvent) -> Option<Vec<u8>>
pub fn encode_mouse(&self, ev: MouseEvent) -> Option<Vec<u8>>
Encode a mouse event using the active tracking mode + encoding. None
when reporting is off or the event is filtered by the mode.
Sourcepub fn encode_paste(&self, text: &str) -> Vec<u8> ⓘ
pub fn encode_paste(&self, text: &str) -> Vec<u8> ⓘ
Encode pasted text, wrapping it in bracketed-paste markers when ?2004 is on.
Sourcepub fn encode_focus(&self, focused: bool) -> Option<Vec<u8>>
pub fn encode_focus(&self, focused: bool) -> Option<Vec<u8>>
Encode a focus change (CSI I/CSI O), or None when focus reporting
(?1004) is off.
Sourcepub fn drain_events(&mut self) -> Vec<TermEvent>
pub fn drain_events(&mut self) -> Vec<TermEvent>
Take the consumer events queued since the last drain, emptying the queue.
Sourcepub fn drain_replies(&mut self) -> Vec<u8> ⓘ
pub fn drain_replies(&mut self) -> Vec<u8> ⓘ
Take the reply bytes queued since the last drain (DA/DSR/DECRQM answers), emptying the buffer. The consumer writes them back to the PTY.
Sourcepub fn hyperlink(&self, link: NonZeroU32) -> Option<&str>
pub fn hyperlink(&self, link: NonZeroU32) -> Option<&str>
Resolve a cell’s link index (OSC 8) to its URI, or None if the index
is out of range. The renderer reads Cell.link, then this, to make a
cell clickable (#26).
Trait Implementations§
Source§impl Perform for Term
impl Perform for Term
Source§fn osc_dispatch(&mut self, params: &[&[u8]], _bell_terminated: bool)
fn osc_dispatch(&mut self, params: &[&[u8]], _bell_terminated: bool)
OSC dispatch (#12 event surface): title (0/2), cwd (7). OSC 8 hyperlink is per-cell state, handled in its own slice (#26), not here.
Source§fn csi_dispatch(
&mut self,
params: &Params,
intermediates: &[u8],
_ignore: bool,
action: char,
)
fn csi_dispatch( &mut self, params: &Params, intermediates: &[u8], _ignore: bool, action: char, )
Source§fn esc_dispatch(&mut self, intermediates: &[u8], _ignore: bool, byte: u8)
fn esc_dispatch(&mut self, intermediates: &[u8], _ignore: bool, byte: u8)
Source§fn hook(
&mut self,
_params: &Params,
_intermediates: &[u8],
_ignore: bool,
_action: char,
)
fn hook( &mut self, _params: &Params, _intermediates: &[u8], _ignore: bool, _action: char, )
Source§fn put(&mut self, _byte: u8)
fn put(&mut self, _byte: u8)
hook. C0 controls will also be passed to the handler.