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. Port of
__rich_measure__. The default is what upstream’s Measurement.get
returns for a renderable without one: anything from nothing to the
whole width, (0, max_width).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.Source§fn vertical(&self) -> Option<VerticalAlign>
fn vertical(&self) -> Option<VerticalAlign>
Table cell holding this renderable uses in
place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.Source§fn print_end_line(&self, _options: &ConsoleOptions) -> bool
fn print_end_line(&self, _options: &ConsoleOptions) -> bool
"\n", so a print adds the final line break. A renderable
whose upstream output stops without one (Screen, LiveRender, a
Rule whose end has no newline) returns false, and the next
output continues its last line. options are the print’s options.