Skip to main content

GridRef

Struct GridRef 

Source
pub struct GridRef<'t> { /* private fields */ }
Expand description

Resolved reference to a terminal cell position.

A grid reference is a resolved reference to a specific cell position in the terminal’s internal page structure. Obtain a grid reference from Terminal::grid_ref, then extract the cell or row via GridRef::cell and GridRef::row.

A grid reference is only valid until the next update to the terminal instance. There is no guarantee that a grid reference will remain valid after ANY operation, even if a seemingly unrelated part of the grid is changed, so any information related to the grid reference should be read and cached immediately after obtaining the grid reference.

This API is not meant to be used as the core of render loop. It isn’t built to sustain the framerates needed for rendering large screens. Use the render state API for that.

Implementations§

Source§

impl GridRef<'_>

Source

pub fn row(&self) -> Result<Row>

Get the row from a grid reference.

Source

pub fn cell(&self) -> Result<Cell>

Get the cell from a grid reference.

Source

pub fn style(&self) -> Result<Style>

Get the style of the cell at the grid reference’s position.

Source

pub fn graphemes(&self, buf: &mut [char]) -> Result<usize>

Get the grapheme cluster codepoints for the cell at the grid reference’s position.

Writes the full grapheme cluster (the cell’s primary codepoint followed by any combining codepoints) into the provided buffer. If the cell has no text, Ok(0) is returned.

If the buffer is too small, the function returns Err(Error::OutOfSpace { required }) where required is the required number of codepoints. The caller can then retry with a sufficiently sized buffer.

Trait Implementations§

Source§

impl<'t> Clone for GridRef<'t>

Source§

fn clone(&self) -> GridRef<'t>

Returns a duplicate 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 for GridRef<'t>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'t> Freeze for GridRef<'t>

§

impl<'t> RefUnwindSafe for GridRef<'t>

§

impl<'t> !Send for GridRef<'t>

§

impl<'t> !Sync for GridRef<'t>

§

impl<'t> Unpin for GridRef<'t>

§

impl<'t> UnsafeUnpin for GridRef<'t>

§

impl<'t> UnwindSafe for GridRef<'t>

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.