pub struct Grid<T> {
pub cursor: Cursor<T>,
pub saved_cursor: Cursor<T>,
/* private fields */
}
Expand description
Grid based terminal content storage.
┌─────────────────────────┐ <-- max_scroll_limit + lines
│ │
│ UNINITIALIZED │
│ │
├─────────────────────────┤ <-- self.raw.inner.len()
│ │
│ RESIZE BUFFER │
│ │
├─────────────────────────┤ <-- self.history_size() + lines
│ │
│ SCROLLUP REGION │
│ │
├─────────────────────────┤v lines
│ │|
│ VISIBLE REGION │|
│ │|
├─────────────────────────┤^ <-- display_offset
│ │
│ SCROLLDOWN REGION │
│ │
└─────────────────────────┘ <-- zero
^
columns
Fields§
§cursor: Cursor<T>
Current cursor for writing data.
saved_cursor: Cursor<T>
Last saved cursor.
Implementations§
source§impl<T: GridCell + Default + PartialEq> Grid<T>
impl<T: GridCell + Default + PartialEq> Grid<T>
pub fn new(lines: usize, columns: usize, max_scroll_limit: usize) -> Grid<T>
sourcepub fn update_history(&mut self, history_size: usize)
pub fn update_history(&mut self, history_size: usize)
Update the size of the scrollback history.
pub fn scroll_display(&mut self, scroll: Scroll)
pub fn scroll_down<D>(&mut self, region: &Range<Line>, positions: usize)where
T: ResetDiscriminant<D>,
D: PartialEq,
sourcepub fn scroll_up<D>(&mut self, region: &Range<Line>, positions: usize)where
T: ResetDiscriminant<D>,
D: PartialEq,
pub fn scroll_up<D>(&mut self, region: &Range<Line>, positions: usize)where
T: ResetDiscriminant<D>,
D: PartialEq,
Move lines at the bottom toward the top.
This is the performance-sensitive part of scrolling.
pub fn clear_viewport<D>(&mut self)where
T: ResetDiscriminant<D>,
D: PartialEq,
sourcepub fn reset<D>(&mut self)where
T: ResetDiscriminant<D>,
D: PartialEq,
pub fn reset<D>(&mut self)where
T: ResetDiscriminant<D>,
D: PartialEq,
Completely reset the grid state.
source§impl<T> Grid<T>
impl<T> Grid<T>
sourcepub fn reset_region<D, R: RangeBounds<Line>>(&mut self, bounds: R)
pub fn reset_region<D, R: RangeBounds<Line>>(&mut self, bounds: R)
Reset a visible region within the grid.
pub fn clear_history(&mut self)
sourcepub fn initialize_all(&mut self)
pub fn initialize_all(&mut self)
This is used only for initializing after loading ref-tests.
sourcepub fn iter_from(&self, point: Point) -> GridIterator<'_, T> ⓘ
pub fn iter_from(&self, point: Point) -> GridIterator<'_, T> ⓘ
Iterate over all cells in the grid starting at a specific point.
sourcepub fn display_iter(&self) -> GridIterator<'_, T> ⓘ
pub fn display_iter(&self) -> GridIterator<'_, T> ⓘ
Iterate over all visible cells.
This is slightly more optimized than calling Grid::iter_from
in combination with
Iterator::take_while
.
pub fn display_offset(&self) -> usize
pub fn cursor_cell(&mut self) -> &mut T
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Grid<T>where
T: Deserialize<'de> + Default,
impl<'de, T> Deserialize<'de> for Grid<T>where
T: Deserialize<'de> + Default,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<G> Dimensions for Grid<G>
impl<G> Dimensions for Grid<G>
source§fn total_lines(&self) -> usize
fn total_lines(&self) -> usize
Total number of lines in the buffer, this includes scrollback and visible lines.
source§fn screen_lines(&self) -> usize
fn screen_lines(&self) -> usize
Height of the viewport in lines.
source§fn last_column(&self) -> Column
fn last_column(&self) -> Column
Index for the last column.
source§fn topmost_line(&self) -> Line
fn topmost_line(&self) -> Line
Line farthest up in the grid history.
source§fn bottommost_line(&self) -> Line
fn bottommost_line(&self) -> Line
Line farthest down in the grid history.
source§fn history_size(&self) -> usize
fn history_size(&self) -> usize
Number of invisible lines part of the scrollback history.
Auto Trait Implementations§
impl<T> Freeze for Grid<T>where
T: Freeze,
impl<T> RefUnwindSafe for Grid<T>where
T: RefUnwindSafe,
impl<T> Send for Grid<T>where
T: Send,
impl<T> Sync for Grid<T>where
T: Sync,
impl<T> Unpin for Grid<T>where
T: Unpin,
impl<T> UnwindSafe for Grid<T>where
T: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)