Skip to main content

Term

Struct Term 

Source
pub struct Term { /* private fields */ }
Expand description

Owns the authoritative screen state and applies VT actions to it.

Implementations§

Source§

impl Term

Source

pub fn new(cols: usize, rows: usize) -> Self

Source

pub fn with_scrollback( cols: usize, rows: usize, scrollback_limit: usize, ) -> Self

Source

pub fn damage(&self) -> TermDamage

What changed since the last reset_damage() — line ranges, each with a changed column span. See ADR-0003.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn scrollback_len(&self) -> usize

Number of lines currently held in scrollback history.

Source

pub fn synchronized_output(&self) -> bool

Whether the app has an open synchronized-output block (DEC ?2026, #73).

Source

pub fn color_scheme_updates(&self) -> bool

Whether the app enabled color-scheme-update notifications (DEC ?2031, #85).

Source

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.

Source

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

Source

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.

Source

pub fn scroll_up(&mut self, n: usize)

Scroll the viewport up by n lines into history (clamped to the oldest).

Source

pub fn scroll_down(&mut self, n: usize)

Scroll the viewport down by n lines toward the live screen.

Source

pub fn scroll_to_bottom(&mut self)

Jump the viewport back to the live screen (follow the bottom).

Source

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.

Source

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

Source

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.

Source

pub fn selection_begin( &mut self, row: usize, col: usize, side: Side, ty: SelectionType, )

Begin a selection of ty at viewport (row, col), side.

Source

pub fn selection_extend(&mut self, row: usize, col: usize, side: Side)

Extend the live selection’s focus to viewport (row, col), side.

Source

pub fn selection_clear(&mut self)

Clear the selection.

Source

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.

Source

pub fn selection_text(&self) -> Option<String>

The selected text (for copy), or None when nothing is selected.

Source

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.

Source

pub fn grid(&self) -> &Grid

Source

pub fn cursor(&self) -> &Cursor

Source

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.

Source

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

Source

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.

Source

pub fn encode_paste(&self, text: &str) -> Vec<u8>

Encode pasted text, wrapping it in bracketed-paste markers when ?2004 is on.

Source

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.

Source

pub fn drain_events(&mut self) -> Vec<TermEvent>

Take the consumer events queued since the last drain, emptying the queue.

Source

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.

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

Source§

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 print(&mut self, c: char)

Draw a character to the screen and update states.
Source§

fn execute(&mut self, byte: u8)

Execute a C0 or C1 control function.
Source§

fn csi_dispatch( &mut self, params: &Params, intermediates: &[u8], _ignore: bool, action: char, )

A final character has arrived for a CSI sequence Read more
Source§

fn esc_dispatch(&mut self, intermediates: &[u8], _ignore: bool, byte: u8)

The final character of an escape sequence has arrived. Read more
Source§

fn hook( &mut self, _params: &Params, _intermediates: &[u8], _ignore: bool, _action: char, )

Invoked when a final character arrives in first part of device control string. Read more
Source§

fn put(&mut self, _byte: u8)

Pass bytes as part of a device control string to the handle chosen in hook. C0 controls will also be passed to the handler.
Source§

fn unhook(&mut self)

Called when a device control string is terminated. Read more
Source§

fn terminated(&self) -> bool

Whether the parser should terminate prematurely. Read more

Auto Trait Implementations§

§

impl Freeze for Term

§

impl RefUnwindSafe for Term

§

impl Send for Term

§

impl Sync for Term

§

impl Unpin for Term

§

impl UnsafeUnpin for Term

§

impl UnwindSafe for Term

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.