Skip to main content

TerminalCellGrid

Struct TerminalCellGrid 

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

Dense cols x rows character cell surface for deterministic terminal TUI and CLI rendering.

Implementations§

Source§

impl TerminalCellGrid

Grid allocation, wide-char-safe writing, box drawing, and plain-text serialization for TerminalCellGrid.

Source

pub fn allocate(cols: u16, rows: u16) -> Self

Allocates a blank cols x rows terminal cell grid (clamped to at least 1 x 1).

§Arguments
  • u16 - Column count.
  • u16 - Row count.
§Returns
  • Self - Blank grid.
Source

pub fn reset(&mut self, cols: u16, rows: u16)

Resizes and clears the grid to cols x rows, reusing existing capacity when unchanged.

§Arguments
  • &Self - Mutable grid.
  • u16 - Target column count.
  • u16 - Target row count.
Source

pub fn total_cells(&self) -> usize

Returns total number of character cells in the grid.

§Arguments
  • &Self - Grid reference.
§Returns
  • usize - Total cell count (cols * rows).
Source

pub fn cell(&self, col: u16, row: u16) -> Option<TerminalCell>

Reads the TerminalCell stored at (col, row).

§Arguments
  • &Self - Grid reference.
  • u16 - Zero-based column coordinate.
  • u16 - Zero-based row coordinate.
§Returns
  • Option<TerminalCell> - Cell copy if within bounds.
Source

pub fn put_cell(&mut self, col: u16, row: u16, cell: TerminalCell) -> u16

Writes a single narrow or wide TerminalCell at (col, row), cleanly clearing overwritten wide neighbors and clipping cleanly at the right edge.

§Arguments
  • &Self - Mutable grid.
  • u16 - Zero-based column coordinate.
  • u16 - Zero-based row coordinate.
  • TerminalCell - Cell value to write.
§Returns
  • u16 - Number of columns consumed (0, 1, or 2).
Source

pub fn write_styled_text( &mut self, col: u16, row: u16, max_cols: u16, text: &str, style_cell: TerminalCell, ) -> u16

Writes UTF-8 text onto row starting at col within max_cols, honoring CJK double-width glyphs, zero-width combining marks, and clean edge truncation.

§Arguments
  • &Self - Mutable grid.
  • u16 - Starting zero-based column coordinate.
  • u16 - Target zero-based row coordinate.
  • u16 - Maximum display columns allowed for this write.
  • &str - UTF-8 text slice to write.
  • TerminalCell - Style template supplying foreground, background, bold, reverse, and underline flags.
§Returns
  • u16 - Total display columns written.
Source

pub fn write_text( &mut self, col: u16, row: u16, max_cols: u16, text: &str, ) -> u16

Writes UTF-8 text onto row starting at col using default terminal style within max_cols.

§Arguments
  • &Self - Mutable grid.
  • u16 - Starting zero-based column coordinate.
  • u16 - Target zero-based row coordinate.
  • u16 - Maximum display columns allowed.
  • &str - UTF-8 text slice to write.
§Returns
  • u16 - Total display columns written.
Source

pub fn draw_box( &mut self, x: u16, y: u16, w: u16, h: u16, style_cell: TerminalCell, )

Draws a Unicode box-drawing border frame covering [x, x + w) x [y, y + h).

§Arguments
  • &Self - Mutable grid.
  • u16 - Left column coordinate.
  • u16 - Top row coordinate.
  • u16 - Box width in columns.
  • u16 - Box height in rows.
  • TerminalCell - Style template supplying foreground, background, bold, and reverse flags.
Source

pub fn to_plain_text(&self) -> String

Serializes the grid into clean UTF-8 lines with zero ANSI escape sequences for piped CLI stdout.

§Arguments
  • &Self - Grid reference.
§Returns
  • String - Plain-text UTF-8 representation trimmed of trailing whitespace per line and trailing blank lines.
Source§

impl TerminalCellGrid

Source

pub fn get_cols(&self) -> u16

Source

pub fn get_mut_cols(&mut self) -> &mut u16

Source

pub fn set_cols(&mut self, val: u16) -> &mut Self

Source

pub fn get_rows(&self) -> u16

Source

pub fn get_mut_rows(&mut self) -> &mut u16

Source

pub fn set_rows(&mut self, val: u16) -> &mut Self

Source

pub fn get_cells(&self) -> &Vec<TerminalCell>

Source

pub fn get_mut_cells(&mut self) -> &mut Vec<TerminalCell>

Source

pub fn set_cells(&mut self, val: Vec<TerminalCell>) -> &mut Self

Trait Implementations§

Source§

impl Clone for TerminalCellGrid

Source§

fn clone(&self) -> Self

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 TerminalCellGrid

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for TerminalCellGrid

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for TerminalCellGrid

Source§

impl PartialEq for TerminalCellGrid

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TerminalCellGrid

Auto Trait Implementations§

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.