Struct termstyle::Table
[−]
[src]
pub struct Table { /* fields omitted */ }
A paintable Table
The type can be thought of as Rows[Cols[Cells[Text]]]
, where the items inside a Cell
will be concatenated together (alowing mixed formatting to exist within a table's cell).
Warning: do not use \t
in your text, as this currently uses tabwriter under the hood.
Examples
use termstyle::*; let rows = vec![ // header vec![ vec![Text::new("header1".into())], vec![Text::new("header2".into())], ], // row1 vec![ vec![Text::new("col1".into())], vec![Text::new("col2".into())], ], ]; let example = Table::new(rows); let expected = "\ header1 header2 col1 col2 "; let mut result = Vec::new(); example.paint(&mut result); assert_eq!(expected.as_bytes(), result.as_slice());
Methods
impl Table
[src]
fn new(table: Vec<Vec<Vec<Text>>>) -> Table
[src]
Create a new table from the given rows.
The type can be thought of as Rows[Cols[Cells[Text]]]
, where the items inside a Cell
will be concatenated together (alowing mixed formatting to exist within a table's cell).
fn set_plain(&mut self)
[src]
Recursively clears all formatting.
fn paint<W: Write>(&self, w: &mut W) -> Result<()>
[src]
Paint the table, giving each column the same width.