Struct term_model::grid::Grid

source ·
pub struct Grid<T> {
    pub selection: Option<Selection>,
    /* private fields */
}
Expand description

Represents the terminal display contents

┌─────────────────────────┐  <-- 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
                          ^
                         cols

Fields§

§selection: Option<Selection>

Selected region.

Implementations§

source§

impl<T: GridCell + PartialEq + Copy> Grid<T>

source

pub fn new(lines: Line, cols: Column, scrollback: usize, template: T) -> Grid<T>

source

pub fn buffer_to_visible( &self, point: impl Into<Point<usize>> ) -> Option<Point<usize>>

source

pub fn visible_to_buffer(&self, point: Point) -> Point<usize>

source

pub fn update_history(&mut self, history_size: usize)

Update the size of the scrollback history

source

pub fn scroll_display(&mut self, scroll: Scroll)

source

pub fn resize( &mut self, reflow: bool, lines: Line, cols: Column, cursor_pos: &mut Point, template: &T )

source

pub fn line_to_offset(&self, line: Line) -> usize

Convert a Line index (active region) to a buffer offset

§Panics

This method will panic if Line is larger than the grid dimensions

source

pub fn scroll_down( &mut self, region: &Range<Line>, positions: Line, template: &T )

source

pub fn scroll_up(&mut self, region: &Range<Line>, positions: Line, template: &T)

scroll_up moves lines at the bottom towards the top

This is the performance-sensitive part of scrolling.

source

pub fn clear_viewport(&mut self, template: &T)

source

pub fn reset(&mut self, template: &T)

source§

impl<T> Grid<T>

source

pub fn num_lines(&self) -> Line

source

pub fn display_iter(&self) -> DisplayIter<'_, T>

source

pub fn num_cols(&self) -> Column

source

pub fn clear_history(&mut self)

source

pub fn len(&self) -> usize

Total number of lines in the buffer, this includes scrollback + visible lines

source

pub fn history_size(&self) -> usize

source

pub fn initialize_all(&mut self, template: &T)
where T: Copy + GridCell,

This is used only for initializing after loading ref-tests

source

pub fn truncate(&mut self)

This is used only for truncating before saving ref-tests

source

pub fn iter_from(&self, point: Point<usize>) -> GridIterator<'_, T>

source

pub fn contains(&self, point: &Point) -> bool

source

pub fn display_offset(&self) -> usize

Trait Implementations§

source§

impl<T: Clone> Clone for Grid<T>

source§

fn clone(&self) -> Grid<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Grid<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, T> Deserialize<'de> for Grid<T>
where T: Deserialize<'de>,

source§

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<'point, T> Index<&'point Point> for Grid<T>

§

type Output = T

The returned type after indexing.
source§

fn index<'a>(&'a self, point: &Point) -> &'a T

Performs the indexing (container[index]) operation. Read more
source§

impl<T> Index<Line> for Grid<T>

Index active region by line

§

type Output = Row<T>

The returned type after indexing.
source§

fn index(&self, index: Line) -> &Row<T>

Performs the indexing (container[index]) operation. Read more
source§

impl<T> Index<usize> for Grid<T>

Index with buffer offset

§

type Output = Row<T>

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Row<T>

Performs the indexing (container[index]) operation. Read more
source§

impl<'point, T> IndexMut<&'point Point> for Grid<T>

source§

fn index_mut<'a, 'b>(&'a mut self, point: &'b Point) -> &'a mut T

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<T> IndexMut<Line> for Grid<T>

source§

fn index_mut(&mut self, index: Line) -> &mut Row<T>

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<T> IndexMut<usize> for Grid<T>

source§

fn index_mut(&mut self, index: usize) -> &mut Row<T>

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<T> IndexRegion<Range<Line>, T> for Grid<T>

source§

fn region(&self, index: Range<Line>) -> Region<'_, T>

Get an immutable region of Self
source§

fn region_mut(&mut self, index: Range<Line>) -> RegionMut<'_, T>

Get a mutable region of Self
source§

impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T>

source§

fn region(&self, index: RangeFrom<Line>) -> Region<'_, T>

Get an immutable region of Self
source§

fn region_mut(&mut self, index: RangeFrom<Line>) -> RegionMut<'_, T>

Get a mutable region of Self
source§

impl<T> IndexRegion<RangeFull, T> for Grid<T>

source§

fn region(&self, _: RangeFull) -> Region<'_, T>

Get an immutable region of Self
source§

fn region_mut(&mut self, _: RangeFull) -> RegionMut<'_, T>

Get a mutable region of Self
source§

impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T>

source§

fn region(&self, index: RangeTo<Line>) -> Region<'_, T>

Get an immutable region of Self
source§

fn region_mut(&mut self, index: RangeTo<Line>) -> RegionMut<'_, T>

Get a mutable region of Self
source§

impl<T: PartialEq> PartialEq for Grid<T>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for Grid<T>
where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,