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 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 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 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_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 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 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.