pub struct TablePresentation { /* private fields */ }Expand description
Implementations§
Source§impl TablePresentation
impl TablePresentation
Sourcepub fn new(
header_style: BlockStyle,
cell_style: BlockStyle,
border_style: TextStyle,
) -> Self
pub fn new( header_style: BlockStyle, cell_style: BlockStyle, border_style: TextStyle, ) -> Self
Creates a table presentation with a single-line border and one cell of padding.
Sourcepub const fn get_style(&self, role: TableRole) -> &BlockStyle
pub const fn get_style(&self, role: TableRole) -> &BlockStyle
Returns the block style assigned to one logical table cell role.
Sourcepub const fn get_border_style(&self) -> &TextStyle
pub const fn get_border_style(&self) -> &TextStyle
Returns the style drawn on the table’s rules.
Sourcepub fn style(self, role: TableRole, style: BlockStyle) -> Self
pub fn style(self, role: TableRole, style: BlockStyle) -> Self
Replaces the block style assigned to one logical table cell role.
Sourcepub fn header_style(self, style: BlockStyle) -> Self
pub fn header_style(self, style: BlockStyle) -> Self
Replaces the header-cell style.
Sourcepub fn cell_style(self, style: BlockStyle) -> Self
pub fn cell_style(self, style: BlockStyle) -> Self
Replaces the body-cell style.
Sourcepub fn header_styles<I>(self, styles: I) -> Self
pub fn header_styles<I>(self, styles: I) -> Self
Replaces positional complete header-cell styles.
A missing or None entry keeps the table header style. Extra entries
do not create columns.
Sourcepub fn column_styles<I>(self, styles: I) -> Self
pub fn column_styles<I>(self, styles: I) -> Self
Replaces positional complete body-column styles.
A missing or None entry keeps the table cell style. Extra entries do
not create columns.
Sourcepub fn border_style(self, style: TextStyle) -> Self
pub fn border_style(self, style: TextStyle) -> Self
Replaces the style drawn on the table’s rules.
Sourcepub const fn border(self, border: TableBorder) -> Self
pub const fn border(self, border: TableBorder) -> Self
Replaces the table’s line model and glyph repertoire.
Sourcepub const fn border_top(self, enabled: bool) -> Self
pub const fn border_top(self, enabled: bool) -> Self
Draws or omits the top edge.
Sourcepub const fn border_bottom(self, enabled: bool) -> Self
pub const fn border_bottom(self, enabled: bool) -> Self
Draws or omits the bottom edge.
Sourcepub const fn border_left(self, enabled: bool) -> Self
pub const fn border_left(self, enabled: bool) -> Self
Draws or omits the left edge.
Sourcepub const fn border_right(self, enabled: bool) -> Self
pub const fn border_right(self, enabled: bool) -> Self
Draws or omits the right edge.
Sourcepub const fn border_header(self, enabled: bool) -> Self
pub const fn border_header(self, enabled: bool) -> Self
Draws or omits the rule between the header and the first body row.
Sourcepub const fn border_column(self, enabled: bool) -> Self
pub const fn border_column(self, enabled: bool) -> Self
Draws or omits the rules between columns.
A connected table uses its LineGlyphs::vertical glyph for outer and
inner vertical rules. A straight-rule preset supplies its own vertical
marker.
Sourcepub const fn border_row(self, enabled: bool) -> Self
pub const fn border_row(self, enabled: bool) -> Self
Draws or omits the rules between body rows.
Sourcepub const fn padding(self, padding: u16) -> Self
pub const fn padding(self, padding: u16) -> Self
Sets the horizontal padding applied to both sides of every cell.
Sourcepub const fn width(self, width: u16) -> Self
pub const fn width(self, width: u16) -> Self
States the total width the table takes, in terminal cells.
A total width is a statement about the box the table sits in, so
compose puts its Canvas in a borderless block of
exactly this width. The bound table frame then gives every column an
equal share, which is why a
width much wider than the content can leave a short column wider than a
long one, and a width narrower than the content narrows every column
rather than only the widest.
Nothing is measured while composing. The bound frame decides columns and the lines between them together when the view resolves, so they cannot disagree, and a column floors at the narrowest grapheme it must show: a table given less than its floor is as wide as that floor, wrapping its content rather than dropping it.
Without a stated width the table is as wide as its content, and an area narrower than that shrinks it by the same rule. This states the width for a caller who wants one regardless of the area.
The width is a u16 for the same reason BlockStyle::width is: a
terminal dimension, not an arbitrary count.
Sourcepub fn compose<T>(&self, table: &Table<T>) -> Viewwhere
T: TableRow,
pub fn compose<T>(&self, table: &Table<T>) -> Viewwhere
T: TableRow,
Composes table data into an intrinsically sized, renderer-neutral Canvas.
Composition binds an owned snapshot without receiving an available area. During resolution, the bound item first supplies width and width-dependent height requirements, then records cell and rule commands after the final Canvas size is known.
Sourcepub fn compose_with<T>(
&self,
table: &Table<T>,
rows: &TableRowPresentation<'_, T>,
) -> View
pub fn compose_with<T>( &self, table: &Table<T>, rows: &TableRowPresentation<'_, T>, ) -> View
Composes typed table data with custom row formatting and cell styles.
Trait Implementations§
Source§impl Clone for TablePresentation
impl Clone for TablePresentation
Source§fn clone(&self) -> TablePresentation
fn clone(&self) -> TablePresentation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more