Skip to main content

TerminalBuffer

Struct TerminalBuffer 

Source
pub struct TerminalBuffer {
    cells: Vec<Vec<Cell>>,
    cursor_row: usize,
    cursor_col: usize,
    rows: usize,
    cols: usize,
    scrollback: Vec<Vec<Cell>>,
    max_scrollback: usize,
    scroll_top: usize,
    scroll_bottom: usize,
    pub window_title: String,
}

Fields§

§cells: Vec<Vec<Cell>>§cursor_row: usize§cursor_col: usize§rows: usize§cols: usize§scrollback: Vec<Vec<Cell>>§max_scrollback: usize§scroll_top: usize

DECSTBM scroll region: (top_row, bottom_row) inclusive, 0-indexed.

§scroll_bottom: usize§window_title: String

Window title set by OSC 0/1/2.

Implementations§

Source§

impl TerminalBuffer

Source

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

Source

pub fn write_char(&mut self, ch: char)

Write a single character, applying Unicode width rules.

  • Width-0 (combining): appended to the previous cell’s combining stack.
  • Width-1: normal single-column write.
  • Width-2 (wide): occupies current column (left half) and marks column+1 as a wide_continuation cell. If only one column remains on the line the wide character is rendered in the last column and no continuation is written (truncation — simplest safe choice; the alternative is wrapping half-chars).
Source

fn write_combining(&mut self, ch: char)

Source

fn write_normal(&mut self, ch: char)

Source

fn write_wide(&mut self, ch: char)

Source

fn advance_row(&mut self)

Advance one row within the current scroll region, scrolling if needed.

Source

pub fn scroll_up(&mut self)

Scroll the active scroll region up by n lines. Displaced top lines move to the scrollback buffer.

Source

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

Scroll the scroll region up by n lines (CSI Ps S).

Source

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

Scroll the scroll region down by n lines (CSI Ps T). Top lines are blank-filled; bottom lines are discarded.

Source

pub fn cursor(&self) -> (usize, usize)

Source

pub fn cell(&self, row: usize, col: usize) -> &Cell

Source

pub fn resize(&mut self, rows: usize, cols: usize)

Source

pub fn clear(&mut self)

Source

pub fn dimensions(&self) -> (usize, usize)

Source

pub fn scrollback_len(&self) -> usize

Source

pub fn set_cursor(&mut self, row: usize, col: usize)

Source

pub fn set_scroll_region(&mut self, top: usize, bottom: usize)

DECSTBM: set scroll region. Both values are 1-indexed; we store 0-indexed. Passes through silently on invalid ranges.

Source

pub fn scroll_top(&self) -> usize

Source

pub fn scroll_bottom(&self) -> usize

Source

pub fn set_cell_styled( &mut self, row: usize, col: usize, ch: char, fg: Color, bg: Color, bold: bool, italic: bool, underline: bool, )

Source

pub fn clear_below(&mut self)

Source

pub fn clear_above(&mut self)

Source

pub fn clear_line(&mut self)

Source

pub fn clear_line_right(&mut self)

Source

pub fn clear_line_left(&mut self)

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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.