pub struct ScreenBuffer { /* private fields */ }Expand description
A 2D grid of terminal cells representing one frame of terminal content.
Implementations§
Source§impl ScreenBuffer
impl ScreenBuffer
Sourcepub fn resize(&mut self, size: Size)
pub fn resize(&mut self, size: Size)
Resize the buffer. Contents are lost (filled with blanks).
Sourcepub fn get(&self, x: u16, y: u16) -> Option<&Cell>
pub fn get(&self, x: u16, y: u16) -> Option<&Cell>
Get a reference to the cell at (x, y), or None if out of bounds.
Sourcepub fn get_mut(&mut self, x: u16, y: u16) -> Option<&mut Cell>
pub fn get_mut(&mut self, x: u16, y: u16) -> Option<&mut Cell>
Get a mutable reference to the cell at (x, y), or None if out of bounds.
Sourcepub fn set(&mut self, x: u16, y: u16, cell: Cell)
pub fn set(&mut self, x: u16, y: u16, cell: Cell)
Set a cell at (x, y). If the cell is wide (width > 1), the next cell is automatically set to a continuation cell. No-op if out of bounds.
This method handles wide character edge cases:
- If writing over a continuation cell, the preceding wide character’s primary cell is blanked to avoid leaving a half-rendered glyph.
- If writing over a wide character’s primary cell, the old continuation cell at x+1 is blanked.
- If a wide character would place its continuation cell beyond the last column, the wide character is replaced with a single space instead.
Sourcepub fn diff(&self, previous: &ScreenBuffer) -> Vec<CellChange>
pub fn diff(&self, previous: &ScreenBuffer) -> Vec<CellChange>
Compute the differences between this buffer and a previous buffer. Returns a list of cell changes needed to update the terminal.
Trait Implementations§
Source§impl Clone for ScreenBuffer
impl Clone for ScreenBuffer
Source§fn clone(&self) -> ScreenBuffer
fn clone(&self) -> ScreenBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ScreenBuffer
impl RefUnwindSafe for ScreenBuffer
impl Send for ScreenBuffer
impl Sync for ScreenBuffer
impl Unpin for ScreenBuffer
impl UnwindSafe for ScreenBuffer
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