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]

[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).

[src]

Recursively clears all formatting.

[src]

Paint the table, giving each column the same width.

Trait Implementations

impl Debug for Table
[src]

[src]

Formats the value using the given formatter.

impl Eq for Table
[src]

impl PartialEq for Table
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.