Skip to main content

Grid

Struct Grid 

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

Implementations§

Source§

impl Grid

Source

pub fn new(width: u16, height: u16) -> Self

Source

pub fn width(&self) -> u16

Source

pub fn height(&self) -> u16

Source

pub fn resize(&mut self, width: u16, height: u16)

Source

pub fn cell(&self, x: u16, y: u16) -> &Cell

Source

pub fn cell_mut(&mut self, x: u16, y: u16) -> Option<&mut Cell>

Mutable cell access; returns None when out of bounds.

Escape hatch that bypasses the wide-char continuation invariant upheld by set / put_char / fill. Callers must own the entire region they write into and re-establish the invariant themselves (e.g. snapshot.rs stamps \0 continuations explicitly). For any normal painting, prefer set / put_str / put_char / fill.

Source

pub fn set(&mut self, x: u16, y: u16, symbol: char, style: Style)

Source

pub fn put_str(&mut self, x: u16, y: u16, text: &str, style: Style) -> u16

Source

pub fn put_char(&mut self, x: u16, y: u16, symbol: char, fg: Color)

Overwrites symbol and style.fg; preserves the existing cell’s bg and text attributes. Use for fg-only painting over a filled background.

Source

pub fn put_str_fg(&mut self, x: u16, y: u16, text: &str, fg: Color) -> u16

String form of Grid::put_char: overwrites symbol + fg, preserves bg and attrs.

Source

pub fn put_line(&mut self, x: u16, y: u16, line: &Line<'_>) -> u16

Paint a [Line] of styled spans at (x, y), clipping at the right edge.

Source

pub fn fill(&mut self, area: Rect, symbol: char, style: Style)

Source

pub fn clear(&mut self, area: Rect)

Source

pub fn clear_all(&mut self)

Source

pub fn slice_mut(&mut self, area: Rect) -> GridSlice<'_>

Source

pub fn diff<'a>( &'a self, prev: &'a Grid, ) -> impl Iterator<Item = CellUpdate<'a>>

Source

pub fn swap_with(&mut self, other: &mut Grid)

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

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