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
impl Grid
Sourcepub fn new(rows: usize, cols: usize) -> Self
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).
Sourcepub fn write(&mut self, x: i32, y: i32, text: &str)
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.
Sourcepub fn write_styled(
&mut self,
x: i32,
y: i32,
text: &str,
transformers: &[Transformer<'_>],
)
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).
Sourcepub fn get(&self) -> (String, usize)
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).