Skip to main content

Screen

Struct Screen 

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

One pane screen, including scrollback, alternate-screen state, cursor position, modes, tab stops, and hyperlink storage.

Implementations§

Source§

impl Screen

Source

pub fn capture_transcript( &self, range: ScreenCaptureRange, options: GridRenderOptions, ) -> Vec<u8>

Captures a tmux-style line range over the current grid contents.

Source

pub fn capture_transcript_lines_independent( &self, range: ScreenCaptureRange, options: GridRenderOptions, ) -> Vec<Vec<u8>>

Captures physical lines with each line rendered from a fresh ANSI state.

This is intended for renderers that repaint individual terminal rows: a row must carry its own SGR state instead of depending on a previous captured row having been emitted first.

Source

pub fn visible_line_revision(&self, row: usize) -> Option<u64>

Returns the monotonic mutation revision for one visible row.

Source

pub fn render_visible_line_independent( &self, row: usize, options: GridRenderOptions, ) -> Option<Vec<u8>>

Renders one visible row from a fresh ANSI state.

Source

pub fn render_visible_line_independent_with_default_style( &self, row: usize, options: GridRenderOptions, style: &Style, ) -> Option<Vec<u8>>

Renders one visible row from a fresh ANSI state after applying pane default-style to default cells only.

Source

pub fn capture_saved_transcript( &self, range: ScreenCaptureRange, options: GridRenderOptions, ) -> Option<Vec<u8>>

Captures the saved pre-alternate-screen copy when alternate mode is active.

Source§

impl Screen

Source

pub fn tmux_history_bytes(&self) -> usize

Returns tmux-compatible grid allocation bytes for #{history_bytes}.

Source

pub fn tmux_history_all_bytes(&self) -> String

Returns tmux-compatible grid allocation counters for #{history_all_bytes}.

Source§

impl Screen

Source

pub fn has_selected_cells(&self) -> bool

Returns whether any visible cell is currently marked as selected.

Source

pub fn mark_selected_row_range(&mut self, row: u32, start_x: u32, end_x: u32)

Marks one visible row range as selected.

Source

pub fn clear_selected_cells(&mut self)

Clears all visible selected-cell markers.

Source

pub fn overlay_style_on_selected(&mut self, style_input: &str)

Overlays style_input onto all selected visible cells.

Source§

impl Screen

Source

pub fn overlay_style_on_default_cells(&mut self, style_input: &str)

Applies style_input only where the application left cell styling unset.

Source

pub fn overlay_default_style(&mut self, style: &Style)

Applies style only where the application left cell styling unset.

Source§

impl Screen

Source

pub fn visit_visible_line_cells( &self, row: usize, cols: usize, visit: impl FnMut(ScreenCellRef<'_>), ) -> bool

Visits borrowed cells for one visible row, padding to cols cells.

Returns false when row is outside the visible viewport. Plain ASCII compact rows are visited directly from their compact text storage, so callers that only need the visible viewport can avoid the owned ScreenLineView allocation path.

Source

pub fn absolute_line_view(&self, absolute_y: usize) -> Option<ScreenLineView>

Returns a read-only copy of one absolute line.

Source

pub fn clone_viewport( &self, top_line: usize, cursor_x: u32, cursor_absolute_y: usize, ) -> Self

Clones the screen as a standalone viewport over its absolute lines.

Source§

impl Screen

Source

pub fn new(size: TerminalSize, history_limit: usize) -> Self

Creates a new screen with the given geometry and history limit.

Source

pub const fn mode(&self) -> u32

Returns the current terminal mode flags.

Source

pub const fn cursor_style(&self) -> u32

Returns the most recent DECSCUSR cursor style parameter.

Source

pub const fn scroll_region(&self) -> (u32, u32)

Returns the DECSTBM scroll region as (top, bottom) rows, 0-based and inclusive. A full-screen region is (0, rows - 1).

Source

pub fn size(&self) -> TerminalSize

Returns the screen size.

Source

pub fn title(&self) -> &str

Returns the current screen title.

Source

pub fn set_title(&mut self, title: impl Into<String>)

Sets the current screen title.

Source

pub fn set_title_rename_enabled(&mut self, enabled: bool)

Enables or disables title changes requested by pane output.

Source

pub fn set_alternate_screen_enabled(&mut self, enabled: bool)

Enables or disables DEC alternate-screen entry for this screen.

Exit sequences are still honored by the writer so disabling the option while a pane is already in alternate screen does not trap it there.

Source

pub fn path(&self) -> &str

Returns the most recent OSC 7 path.

Source

pub fn is_alternate(&self) -> bool

Returns whether the alternate screen is active.

Source

pub fn history_limit(&self) -> usize

Returns the configured history limit.

Source

pub fn history_size(&self) -> usize

Returns the current history size in rows.

Source

pub const fn cursor_position(&self) -> (u32, u32)

Returns the current cursor position within the visible viewport.

Source

pub fn cursor_absolute_y(&self) -> usize

Returns the absolute cursor row including history.

Source

pub fn absolute_line_count(&self) -> usize

Returns the total number of absolute lines retained by the screen.

Source

pub fn delete_visible_line(&mut self, y: u32) -> bool

Deletes one visible line and scrolls the remaining viewport content up.

This clears any pending wrap state because deleting a visible row invalidates the previous cursor edge condition.

Source

pub fn delete_absolute_line(&mut self, absolute_y: usize) -> bool

Deletes one absolute line from history or the visible viewport.

Source

pub fn trim_below_cursor(&mut self) -> bool

Trims all lines below the cursor and pulls history into the viewport.

Source

pub fn history_bytes(&self) -> usize

Returns the current retained history size in bytes.

Source

pub fn take_bell_count(&mut self) -> u64

Drains and returns the number of BEL notifications observed since the last drain.

Source

pub fn take_terminal_passthrough(&mut self) -> Vec<TerminalPassthrough>

Drains terminal passthrough events observed since the last drain.

Source

pub fn take_terminal_passthrough_dropped_count(&mut self) -> u64

Drains the count of terminal passthrough events dropped by safety limits.

Returns the stored OSC 8 URI for a hyperlink inner ID.

Source

pub fn set_history_limit(&mut self, limit: usize)

Updates the history limit.

Source

pub fn set_utf8_config(&mut self, utf8_config: Utf8Config)

Updates the tmux-style UTF-8 width and combining configuration.

Source

pub fn resize(&mut self, size: TerminalSize)

Resizes the screen and resets the scroll region.

Clears history and optionally resets stored hyperlinks.

Trait Implementations§

Source§

impl Clone for Screen

Source§

fn clone(&self) -> Screen

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 Screen

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Screen

Source§

impl PartialEq for Screen

Source§

fn eq(&self, other: &Screen) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ScreenWriter for Screen

Source§

fn collect_add(&mut self, ch: char, cell: &CellState)

Add a printable character with current cell attributes.
Source§

fn collect_add_with_charset(&mut self, ch: char, cell: &CellState, acs: bool)

Add a printable character, applying ACS charset if acs is true.
Source§

fn collect_add_ascii_run(&mut self, bytes: &[u8], cell: &CellState, acs: bool)

Add a run of printable ASCII bytes with the current cell attributes.
Source§

fn cursor_up(&mut self, n: u32)

Move cursor up by n rows.
Source§

fn cursor_down(&mut self, n: u32)

Move cursor down by n rows.
Source§

fn cursor_left(&mut self, n: u32)

Move cursor left by n columns.
Source§

fn cursor_right(&mut self, n: u32)

Move cursor right by n columns.
Source§

fn cursor_move(&mut self, col: i32, row: i32, origin_mode: bool)

Move cursor to absolute position. -1 means “don’t change”.
Source§

fn insert_line(&mut self, n: u32, bg: i32)

Insert n blank lines at cursor, scrolling down.
Source§

fn delete_line(&mut self, n: u32, bg: i32)

Delete n lines at cursor, scrolling up.
Source§

fn scroll_up(&mut self, n: u32, bg: i32)

Scroll up by n lines.
Source§

fn scroll_down(&mut self, n: u32, bg: i32)

Scroll down by n lines.
Source§

fn linefeed(&mut self, wrapped: bool, bg: i32)

Line feed.
Source§

fn reverse_index(&mut self, bg: i32)

Reverse index (scroll down or move up).
Source§

fn carriage_return(&mut self)

Carriage return.
Source§

fn backspace(&mut self)

Backspace.
Source§

fn insert_character(&mut self, n: u32, bg: i32)

Insert n blank characters at cursor.
Source§

fn delete_character(&mut self, n: u32, bg: i32)

Delete n characters at cursor.
Source§

fn clear_character(&mut self, n: u32, bg: i32)

Erase (clear) n characters at cursor.
Source§

fn clear_end_of_screen(&mut self, bg: i32)

Clear to end of screen.
Source§

fn clear_start_of_screen(&mut self, bg: i32)

Clear from start of screen.
Source§

fn clear_screen(&mut self, _bg: i32)

Clear entire screen.
Source§

fn clear_history(&mut self)

Clear scrollback history.
Source§

fn clear_end_of_line(&mut self, bg: i32)

Clear to end of line.
Source§

fn clear_start_of_line(&mut self, bg: i32)

Clear from start of line.
Source§

fn clear_line(&mut self, bg: i32)

Clear entire line.
Source§

fn mode_set(&mut self, mode_bits: u32)

Set mode bits.
Source§

fn mode_clear(&mut self, mode_bits: u32)

Clear mode bits.
Source§

fn set_scroll_region(&mut self, top: u32, bottom: u32)

Set scroll region (top and bottom margins, 0-based).
Source§

fn alternate_on(&mut self, bg: i32, save_cursor: bool)

Switch to alternate screen. save_cursor = true for 1049.
Source§

fn alternate_off(&mut self, _bg: i32, restore_cursor: bool)

Switch back from alternate screen.
Source§

fn tab(&mut self)

Handle a horizontal tab.
Source§

fn cursor_backward_tab(&mut self, n: u32)

Move cursor backward n tab stops (CBT).
Source§

fn set_tab_stop(&mut self)

Set a tab stop at the current cursor column.
Source§

fn clear_tab_stop(&mut self)

Clear a tab stop at the current cursor column.
Source§

fn clear_all_tab_stops(&mut self)

Clear all tab stops.
Source§

fn set_title(&mut self, title: &str)

Set the pane/window title.
Source§

fn set_window_name(&mut self, name: &str)

Set the window name (from rename string).
Source§

fn set_path(&mut self, path: &str)

Set the current directory path (OSC 7).
Source§

fn save_cursor(&mut self)

Save cursor state (DECSC).
Source§

fn restore_cursor(&mut self)

Restore cursor state (DECRC).
Source§

fn alignment_test(&mut self)

Fill screen with ‘E’ characters (DECALN).
Source§

fn full_reset(&mut self)

Full terminal reset (RIS).
Source§

fn start_sync(&mut self)

Start synchronized output.
Source§

fn stop_sync(&mut self)

Stop synchronized output and redraw.
Source§

fn set_cursor_style(&mut self, n: u32)

Set cursor style (DECSCUSR). n is the Ps value 0-6.
Handle OSC 8 hyperlink.
Returns the active OSC 8 hyperlink inner ID.
Source§

fn bell(&mut self)

Ring the bell (BEL).
Source§

fn apc_passthrough(&mut self, data: &[u8])

Handle an opaque APC passthrough string.
Source§

fn dcs_passthrough(&mut self, data: &[u8])

Handle DCS passthrough string.
Source§

fn sixel_passthrough(&mut self, data: &[u8])

Handle an opaque SIXEL DCS passthrough string.
Source§

fn screen_size_x(&self) -> u32

Get screen width in columns.
Source§

fn screen_size_y(&self) -> u32

Get screen height in rows.
Source§

fn cursor_x(&self) -> u32

Get current cursor column (0-based).
Source§

fn cursor_y(&self) -> u32

Get current cursor row (0-based).
Source§

fn current_mode(&self) -> u32

Get current screen mode flags.
Source§

fn push_title(&mut self)

Push current title onto the stack.
Source§

fn pop_title(&mut self)

Pop title from the stack.
Source§

fn osc_palette(&mut self, _data: &str, _end: InputEndType)

Handle OSC 4 palette colour.
Source§

fn osc_notification(&mut self, _data: &str)

Handle OSC 9 notification.
Source§

fn osc_fg_colour(&mut self, _data: &str, _end: InputEndType)

Handle OSC 10 fg colour query/set.
Source§

fn osc_bg_colour(&mut self, _data: &str, _end: InputEndType)

Handle OSC 11 bg colour query/set.
Source§

fn osc_cursor_colour(&mut self, _data: &str, _end: InputEndType)

Handle OSC 12 cursor colour query/set.
Source§

fn osc_clipboard(&mut self, data: &str, end: InputEndType)

Handle OSC 52 clipboard.
Source§

fn osc_reset_palette(&mut self, _data: &str)

Handle OSC 104 reset palette.
Source§

fn osc_reset_fg(&mut self)

Handle OSC 110 reset fg.
Source§

fn osc_reset_bg(&mut self)

Handle OSC 111 reset bg.
Source§

fn osc_reset_cursor(&mut self)

Handle OSC 112 reset cursor colour.
Source§

fn osc_shell_integration(&mut self, _data: &str)

Handle OSC 133 shell integration.
Source§

fn collect_end(&mut self)

End character collection (flush). Called before non-print transitions.
Source§

fn reset_attributes(&mut self)

Reset cell attributes to default.
Source§

fn notify_pane_title_changed(&mut self)

Signal that the pane title changed.
Source§

impl StructuralPartialEq for Screen

Auto Trait Implementations§

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