Skip to main content

Columns

Struct Columns 

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

Arranges items into a grid of columns. Mirrors rich.columns.Columns.

Implementations§

Source§

impl Columns

Source

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.

Source

pub fn from_cells(items: Vec<Cell>) -> Self

Columns of any items: markup strings, literal Text or renderables, as upstream’s Columns(renderables) accepts.

Source

pub fn add_renderable(&mut self, item: impl Into<Cell>) -> &mut Self

Add an item. Port of Columns.add_renderable.

Source

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.

Source

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

A fixed width for every column (upstream width): as many columns as max_width // (width + gap).

Source

pub fn column_first(self, column_first: bool) -> Self

Fill columns top to bottom rather than rows left to right (upstream column_first).

Source

pub fn right_to_left(self, right_to_left: bool) -> Self

Lay each row out from the right (upstream right_to_left).

Source

pub fn align(self, align: HorizontalAlign) -> Self

Align every item within its column (upstream align).

Source

pub fn title(self, title: impl Into<String>) -> Self

A title (console markup) above the columns (upstream title).

Source

pub fn expand(self, expand: bool) -> Self

Expand columns to the full width (upstream expand).

Source

pub fn equal(self, equal: bool) -> Self

Arrange into equal sized columns (upstream equal).

Trait Implementations§

Source§

impl Renderable for Columns

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement

The (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

Whether a top-level 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>

The vertical alignment a Table cell holding this renderable uses in place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.

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> 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, 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.