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: usizeDECSTBM scroll region: (top_row, bottom_row) inclusive, 0-indexed.
scroll_bottom: usize§window_title: StringWindow title set by OSC 0/1/2.
Implementations§
Source§impl TerminalBuffer
impl TerminalBuffer
pub fn new(rows: usize, cols: usize, max_scrollback: usize) -> Self
Sourcepub fn write_char(&mut self, ch: char)
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).
fn write_combining(&mut self, ch: char)
fn write_normal(&mut self, ch: char)
fn write_wide(&mut self, ch: char)
Sourcefn advance_row(&mut self)
fn advance_row(&mut self)
Advance one row within the current scroll region, scrolling if needed.
Sourcepub fn scroll_up(&mut self)
pub fn scroll_up(&mut self)
Scroll the active scroll region up by n lines.
Displaced top lines move to the scrollback buffer.
Sourcepub fn scroll_region_up(&mut self, n: usize)
pub fn scroll_region_up(&mut self, n: usize)
Scroll the scroll region up by n lines (CSI Ps S).
Sourcepub fn scroll_region_down(&mut self, n: usize)
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.
pub fn cursor(&self) -> (usize, usize)
pub fn cell(&self, row: usize, col: usize) -> &Cell
pub fn resize(&mut self, rows: usize, cols: usize)
pub fn clear(&mut self)
pub fn dimensions(&self) -> (usize, usize)
pub fn scrollback_len(&self) -> usize
pub fn set_cursor(&mut self, row: usize, col: usize)
Sourcepub fn set_scroll_region(&mut self, top: usize, bottom: usize)
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.
pub fn scroll_top(&self) -> usize
pub fn scroll_bottom(&self) -> usize
pub fn set_cell_styled( &mut self, row: usize, col: usize, ch: char, fg: Color, bg: Color, bold: bool, italic: bool, underline: bool, )
pub fn clear_below(&mut self)
pub fn clear_above(&mut self)
pub fn clear_line(&mut self)
pub fn clear_line_right(&mut self)
pub fn clear_line_left(&mut self)
Auto Trait Implementations§
impl Freeze for TerminalBuffer
impl RefUnwindSafe for TerminalBuffer
impl Send for TerminalBuffer
impl Sync for TerminalBuffer
impl Unpin for TerminalBuffer
impl UnsafeUnpin for TerminalBuffer
impl UnwindSafe for TerminalBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn 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>
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)
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)
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.