alacritty_terminal::grid

Struct Grid

source
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>

source

pub fn resize<D>(&mut self, reflow: bool, lines: usize, columns: usize)
where T: ResetDiscriminant<D>, D: PartialEq,

Resize the grid’s width and/or height.

source§

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

source

pub fn new(lines: usize, columns: usize, max_scroll_limit: usize) -> Grid<T>

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 scroll_down<D>(&mut self, region: &Range<Line>, positions: usize)
where T: ResetDiscriminant<D>, D: PartialEq,

source

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.

source

pub fn clear_viewport<D>(&mut self)
where T: ResetDiscriminant<D>, D: PartialEq,

source

pub fn reset<D>(&mut self)
where T: ResetDiscriminant<D>, D: PartialEq,

Completely reset the grid state.

source§

impl<T> Grid<T>

source

pub fn reset_region<D, R: RangeBounds<Line>>(&mut self, bounds: R)

Reset a visible region within the grid.

source

pub fn clear_history(&mut self)

source

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

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) -> GridIterator<'_, T>

Iterate over all cells in the grid starting at a specific point.

source

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.

source

pub fn display_offset(&self) -> usize

source

pub fn cursor_cell(&mut self) -> &mut T

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> + Default,

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<G> Dimensions for Grid<G>

source§

fn total_lines(&self) -> usize

Total number of lines in the buffer, this includes scrollback and visible lines.
source§

fn screen_lines(&self) -> usize

Height of the viewport in lines.
source§

fn columns(&self) -> usize

Width of the terminal in columns.
source§

fn last_column(&self) -> Column

Index for the last column.
source§

fn topmost_line(&self) -> Line

Line farthest up in the grid history.
source§

fn bottommost_line(&self) -> Line

Line farthest down in the grid history.
source§

fn history_size(&self) -> usize

Number of invisible lines part of the scrollback history.
source§

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

source§

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<Point> for Grid<T>

source§

type Output = T

The returned type after indexing.
source§

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

Performs the 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<Point> for Grid<T>

source§

fn index_mut(&mut self, point: Point) -> &mut T

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

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

source§

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

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

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

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> 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> 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

source§

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>,

source§

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>,

source§

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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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