pub struct ScrollBuffer { /* private fields */ }Expand description
Ring buffer for storing lines with scrollback.
The scroll buffer maintains a fixed number of lines in memory, automatically discarding old lines when capacity is exceeded.
Implementations§
Source§impl ScrollBuffer
impl ScrollBuffer
Sourcepub fn current_line(&self) -> &StyledLine
pub fn current_line(&self) -> &StyledLine
Get the current line (the line being appended to).
§Panics
Panics if the buffer is empty (which should never happen).
Sourcepub fn current_line_mut(&mut self) -> &mut StyledLine
pub fn current_line_mut(&mut self) -> &mut StyledLine
Get a mutable reference to the current line.
§Panics
Panics if the buffer is empty (which should never happen).
Sourcepub fn append(&mut self, cells: impl IntoIterator<Item = Cell>)
pub fn append(&mut self, cells: impl IntoIterator<Item = Cell>)
Append cells to the current line.
Sourcepub fn get(&self, index: usize) -> Option<&StyledLine>
pub fn get(&self, index: usize) -> Option<&StyledLine>
Get a line by index from the top of the buffer.
Sourcepub fn visible_lines(
&self,
viewport_height: usize,
) -> impl Iterator<Item = &StyledLine>
pub fn visible_lines( &self, viewport_height: usize, ) -> impl Iterator<Item = &StyledLine>
Get visible lines for a given viewport height.
Returns an iterator over lines that should be visible, accounting for scroll offset.
Sourcepub const fn scroll_down(&mut self, lines: usize)
pub const fn scroll_down(&mut self, lines: usize)
Scroll down by the given number of lines.
Sourcepub const fn scroll_to_bottom(&mut self)
pub const fn scroll_to_bottom(&mut self)
Scroll to the bottom (latest content).
Sourcepub fn current_line_len(&self) -> usize
pub fn current_line_len(&self) -> usize
Get the length of the current line in characters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScrollBuffer
impl RefUnwindSafe for ScrollBuffer
impl Send for ScrollBuffer
impl Sync for ScrollBuffer
impl Unpin for ScrollBuffer
impl UnwindSafe for ScrollBuffer
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