grid

Grid molecule — multi-row table that normalizes column widths across all rows.

struct Component

source

pub struct Component

A multi-row table that computes column widths across all rows before rendering.

Grid pre-scans all rows to normalize natural column widths — for each column position, it computes the max display_width across all rows and promotes each natural column to fixed(max_width) before delegating to Row for rendering.

Field Type Description
max_width Option<usize> Width limit passed to every rendered row; None lets each row use the terminal width.
rows Vec<Row> Rows in display order, before natural columns are widened to match.
spacing usize Spaces between adjacent columns in every row.

Implements Display.

Component::new

source

pub fn new() -> Self

Create an empty grid with default spacing of 2 columns.

Parameter Type Description
returns Self A grid that displays as nothing until rows are pushed.

Component::spacing

source

pub fn spacing(self, spacing: usize) -> Self

Set the number of space characters between columns (default 2).

Parameter Type Description
spacing usize the number of spaces between columns
returns Self The grid with the new spacing.

Component::push

source

pub fn push(&mut self, row: Row)

Add a row to the grid.

Parameter Type Description
row Row the row to append; its own spacing and width limit are replaced by the grid’s