pub struct Columns { /* private fields */ }Expand description
Arranges items into a grid of columns. Mirrors rich.columns.Columns.
Implementations§
Source§impl Columns
impl Columns
Sourcepub fn new(items: Vec<String>) -> Self
pub fn new(items: Vec<String>) -> Self
Columns of string items with the default padding (0, 1). Each string
is console markup, converted with the console’s defaults (markup, emoji
and highlighting), as upstream’s console.render_str(renderable) does.
Sourcepub fn from_cells(items: Vec<Cell>) -> Self
pub fn from_cells(items: Vec<Cell>) -> Self
Columns of any items: markup strings, literal Text
or renderables, as upstream’s Columns(renderables) accepts.
Sourcepub fn add_renderable(&mut self, item: impl Into<Cell>) -> &mut Self
pub fn add_renderable(&mut self, item: impl Into<Cell>) -> &mut Self
Add an item. Port of Columns.add_renderable.
Sourcepub fn padding(self, padding: (usize, usize, usize, usize)) -> Self
pub fn padding(self, padding: (usize, usize, usize, usize)) -> Self
Padding around each cell as (top, right, bottom, left) (upstream
padding, default (0, 1)); the gap between columns is the larger of
left and right.
Sourcepub fn width(self, width: usize) -> Self
pub fn width(self, width: usize) -> Self
A fixed width for every column (upstream width): as many columns as
max_width // (width + gap).
Sourcepub fn column_first(self, column_first: bool) -> Self
pub fn column_first(self, column_first: bool) -> Self
Fill columns top to bottom rather than rows left to right (upstream
column_first).
Sourcepub fn right_to_left(self, right_to_left: bool) -> Self
pub fn right_to_left(self, right_to_left: bool) -> Self
Lay each row out from the right (upstream right_to_left).
Sourcepub fn align(self, align: HorizontalAlign) -> Self
pub fn align(self, align: HorizontalAlign) -> Self
Align every item within its column (upstream align).
Trait Implementations§
Source§impl Renderable for Columns
impl Renderable for Columns
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
(minimum, maximum) cell width this renderable wants. The default
assumes the renderable fills the available width (e.g. Panel, Table);
Text overrides it with its content width so the top-level print path can
shrink to fit. Port of __rich_measure__ / Measurement.get.Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.