Skip to main content

Grid

Struct Grid 

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

Plain-frame character grid.

Initialized to spaces (output.ts:141-156: each cell = {value:' ', fullWidth:false}). Rows are indexed from top (row 0 = topmost visible line).

cols is the initial row width (ink’s Output.width). Individual rows may grow past cols when a write lands at a column beyond the initial width — mirroring JS sparse-array growth in Output.get(). Skipped indices become holes ([Cell::hole]) and are dropped at assembly.

Implementations§

Source§

impl Grid

Source

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

Create a rows × cols grid filled with spaces.

Mirrors Output constructor (output.ts:98-103) + the get() pre-fill loop (output.ts:141-156).

Source

pub fn push_clip(&mut self, clip: Clip)

Push a clip rectangle (output.ts:126-131).

Source

pub fn pop_clip(&mut self)

Pop the most recent clip rectangle (output.ts:133-137).

Source

pub fn write(&mut self, x: i32, y: i32, text: &str)

Write text at grid position (x, y), applying the current clip.

Plain (no-transformer) entry point — equivalent to write_styled(x, y, text, &[]). Used by render_border and any caller that has no SGR transform to thread.

Source

pub fn write_styled( &mut self, x: i32, y: i32, text: &str, transformers: &[Transformer<'_>], )

Write text at grid position (x, y), applying the current clip then the transformers chain (innermost-first), then blitting styled chars.

text may contain \n to write multiple lines; each line is placed at (x, y + line_index).

Mirrors Output.write (output.ts:105-124) + the per-operation handler inside get() (output.ts:169-302). In the plain slice, write is synchronous (no operation queue).

Source

pub fn get(&self) -> (String, usize)

Serialize the grid to a string.

Each row is right-trimmed (output.ts:309-310: styledCharsToString(lineWithoutEmptyItems).trimEnd()), then rows are joined with \n.

Returns (output_string, height) mirroring ink’s {output, height}. Height is always self.rows (the pre-initialized row count — output.ts:315-316).

Auto Trait Implementations§

§

impl !Send for Grid

§

impl !Sync for Grid

§

impl Freeze for Grid

§

impl RefUnwindSafe 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> 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, 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.