Skip to main content

Grid

Struct Grid 

Source
pub struct Grid { /* private fields */ }
Expand description

The current screen: rows × cols cells.

Implementations§

Source§

impl Grid

Source

pub fn new(cols: usize, rows: usize) -> Self

A blank grid of the given size.

Source

pub fn cols(&self) -> usize

Source

pub fn rows(&self) -> usize

Source

pub fn is_row_wrapped(&self, row: usize) -> bool

Did row soft-wrap (auto-wrap) into the next one — i.e. are the two rows one logical line?

Ask this, not the last cell’s WRAPLINE flag: soft-wrap is a property of the row and is stored there, so a cell never carries it on a live grid (#538). The flag still appears on the wire, derived onto a span’s last cell at encode time, which is a different layer — see docs/architecture.md §Cell on the two things called “cell” here.

Source

pub fn cell(&self, row: usize, col: usize) -> &Cell

Read a cell. Panics on out-of-bounds (callers clamp to the grid).

Source

pub fn cell_mut(&mut self, row: usize, col: usize) -> &mut Cell

Mutable access to a cell.

Source

pub fn row(&self, row: usize) -> &[Cell]

Read a whole row.

Source

pub fn scroll_up_region(&mut self, top: usize, bottom: usize)

Scroll the rows [top..=bottom] up by one line: the top line of the region is dropped and a blank line appears at bottom. Rows outside the region are untouched.

rotate_left moves whole-row Vec handles (24 bytes each), not cell data — cheap even at the screen’s bounded row count, so the per-newline scrollback cost lives in the eviction, not here (see scroll_up_recycle and ADR-0009).

Source

pub fn clear(&mut self)

Reset every cell to a blank default. Used when switching to the alt screen (which always starts cleared).

Source

pub fn scroll_down_region(&mut self, top: usize, bottom: usize)

Scroll the rows [top..=bottom] down by one line: a blank line appears at top and the bottom region line is dropped. Rows outside are untouched. Used by RI (reverse index) at the top margin.

Trait Implementations§

Source§

impl Clone for Grid

Source§

fn clone(&self) -> Grid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Grid

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Grid

§

impl RefUnwindSafe for Grid

§

impl Send for Grid

§

impl Sync for Grid

§

impl Unpin for Grid

§

impl UnsafeUnpin for Grid

§

impl UnwindSafe for Grid

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.