pub struct Columns<'a> { /* private fields */ }Expand description
A renderable that arranges items in columns.
Implementations§
Source§impl<'a> Columns<'a>
impl<'a> Columns<'a>
Sourcepub fn new(items: Vec<Vec<Segment<'a>>>) -> Self
pub fn new(items: Vec<Vec<Segment<'a>>>) -> Self
Create a new Columns layout with the given items.
Sourcepub fn from_strings(items: &[&'a str]) -> Self
pub fn from_strings(items: &[&'a str]) -> Self
Create columns from strings.
Sourcepub fn column_count(self, count: usize) -> Self
pub fn column_count(self, count: usize) -> Self
Set the number of columns.
Sourcepub fn equal_width(self, equal: bool) -> Self
pub fn equal_width(self, equal: bool) -> Self
Set whether columns should have equal width.
Sourcepub fn align(self, align: AlignMethod) -> Self
pub fn align(self, align: AlignMethod) -> Self
Set alignment within columns.
Sourcepub fn gutter_style(self, style: Style) -> Self
pub fn gutter_style(self, style: Style) -> Self
Set the gutter style.
Sourcepub fn max_width(self, width: usize) -> Self
pub fn max_width(self, width: usize) -> Self
Set a maximum width for the columns layout.
When set, the columns will not expand beyond this width even if more terminal space is available. This prevents excessive whitespace on very wide terminals (e.g., 300+ columns).
§Example
ⓘ
let cols = Columns::from_strings(&["A", "B", "C"])
.max_width(120) // Never wider than 120 columns
.expand(true); // But expand up to that limitSourcepub fn render(&self, total_width: usize) -> Vec<Vec<Segment<'a>>>
pub fn render(&self, total_width: usize) -> Vec<Vec<Segment<'a>>>
Render the columns to lines of segments.
Sourcepub fn render_flat(&self, total_width: usize) -> Vec<Segment<'a>>
pub fn render_flat(&self, total_width: usize) -> Vec<Segment<'a>>
Render to a single flat list of segments with newlines.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Columns<'a>
impl<'a> RefUnwindSafe for Columns<'a>
impl<'a> Send for Columns<'a>
impl<'a> Sync for Columns<'a>
impl<'a> Unpin for Columns<'a>
impl<'a> UnsafeUnpin for Columns<'a>
impl<'a> UnwindSafe for Columns<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more