pub struct Scrollback { /* private fields */ }Expand description
Scrollback buffer with configurable line capacity.
Uses a VecDeque for O(1) push/pop. When over capacity, the oldest line
(front of the deque) is evicted.
Implementations§
Source§impl Scrollback
impl Scrollback
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new scrollback with the given line capacity.
A capacity of 0 means scrollback is disabled (all pushes are dropped).
Sourcepub fn set_capacity(&mut self, capacity: usize)
pub fn set_capacity(&mut self, capacity: usize)
Change the scrollback capacity.
If the new capacity is smaller than the current line count, the oldest lines are evicted.
Sourcepub fn push_row(
&mut self,
cells: &[Cell],
wrapped: bool,
) -> Option<ScrollbackLine>
pub fn push_row( &mut self, cells: &[Cell], wrapped: bool, ) -> Option<ScrollbackLine>
Push a row (as a cell slice) into scrollback.
wrapped indicates whether the row was a soft-wrap continuation.
If over capacity, the oldest line is evicted.
Sourcepub fn pop_newest(&mut self) -> Option<ScrollbackLine>
pub fn pop_newest(&mut self) -> Option<ScrollbackLine>
Pop the most recent (newest) line from scrollback.
Used when scrolling down to pull lines back into the viewport, or when the viewport grows taller and lines are reclaimed.
Sourcepub fn peek_newest(&self) -> Option<&ScrollbackLine>
pub fn peek_newest(&self) -> Option<&ScrollbackLine>
Peek at the most recent (newest) line without removing it.
Sourcepub fn get(&self, index: usize) -> Option<&ScrollbackLine>
pub fn get(&self, index: usize) -> Option<&ScrollbackLine>
Get a line by index (0 = oldest).
Sourcepub fn iter(&self) -> impl Iterator<Item = &ScrollbackLine>
pub fn iter(&self) -> impl Iterator<Item = &ScrollbackLine>
Iterate over stored lines from oldest to newest.
Sourcepub fn iter_range(
&self,
range: Range<usize>,
) -> impl Iterator<Item = &ScrollbackLine>
pub fn iter_range( &self, range: Range<usize>, ) -> impl Iterator<Item = &ScrollbackLine>
Iterate over a specific line range (0 = oldest).
The range is clamped to valid bounds. This enables viewport virtualization without scanning the full history each frame.
Sourcepub fn iter_rev(&self) -> impl Iterator<Item = &ScrollbackLine>
pub fn iter_rev(&self) -> impl Iterator<Item = &ScrollbackLine>
Iterate over stored lines from newest to oldest.
Sourcepub fn virtualized_window(
&self,
scroll_offset_from_bottom: usize,
viewport_lines: usize,
overscan_lines: usize,
) -> ScrollbackWindow
pub fn virtualized_window( &self, scroll_offset_from_bottom: usize, viewport_lines: usize, overscan_lines: usize, ) -> ScrollbackWindow
Compute a virtualized scrollback window for viewport rendering.
scroll_offset_from_bottom=0anchors viewport at the newest lines.- Larger offsets move viewport toward older lines.
overscan_linesexpands the render range around the viewport.
Trait Implementations§
Source§impl Clone for Scrollback
impl Clone for Scrollback
Source§fn clone(&self) -> Scrollback
fn clone(&self) -> Scrollback
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more