diff options
author | Pierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com> | 2018-09-23 10:24:04 +0200 |
---|---|---|
committer | Pierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com> | 2018-09-23 10:24:04 +0200 |
commit | 61766c924b49bddce2266e9ede5cde42e9c7491e (patch) | |
tree | f87e90e1080bebaea60fc52d9d2a1a63cb8fd76b | |
parent | 029141636d41f850e0ecf9e63992cf97e64d86ed (diff) |
Added FORMAT_BOX_CHARS
-rw-r--r-- | src/format.rs | 33 | ||||
-rw-r--r-- | src/lib.rs | 23 |
2 files changed, 35 insertions, 21 deletions
diff --git a/src/format.rs b/src/format.rs index 45405ca..4dec4fa 100644 --- a/src/format.rs +++ b/src/format.rs @@ -530,5 +530,38 @@ pub mod consts { .separator(LinePosition::Title, *MINUS_PLUS_SEP) .column_separator('|') .build(); + + /// A table with borders and delimiters made with box characters + /// + /// # Example + /// ```text + /// ┌────┬────┬────┐ + /// │ t1 │ t2 │ t3 │ + /// ├────┼────┼────┤ + /// │ 1 │ 1 │ 1 │ + /// ├────┼────┼────┤ + /// │ 2 │ 2 │ 2 │ + /// └────┴────┴────┘ + /// ``` + pub static ref FORMAT_BOX_CHARS: TableFormat = FormatBuilder::new() + .column_separator('│') + .borders('│') + .separators(&[LinePosition::Top], + LineSeparator::new('─', + '┬', + '┌', + '┐')) + .separators(&[LinePosition::Intern], + LineSeparator::new('─', + '┼', + '├', + '┤')) + .separators(&[LinePosition::Bottom], + LineSeparator::new('─', + '┴', + '└', + '┘')) + .padding(1, 1) + .build(); } } @@ -578,7 +578,7 @@ mod tests { use Row; use Cell; use format; - use format::consts::{FORMAT_DEFAULT, FORMAT_NO_LINESEP, FORMAT_NO_COLSEP, FORMAT_CLEAN}; + use format::consts::{FORMAT_DEFAULT, FORMAT_NO_LINESEP, FORMAT_NO_COLSEP, FORMAT_CLEAN, FORMAT_BOX_CHARS}; #[test] fn table() { @@ -862,26 +862,7 @@ mod tests { #[test] fn test_unicode_separators() { let mut table = Table::new(); - table.set_format(format::FormatBuilder::new() - .column_separator('│') - .borders('│') - .separators(&[format::LinePosition::Top], - format::LineSeparator::new('─', - '┬', - '┌', - '┐')) - .separators(&[format::LinePosition::Intern], - format::LineSeparator::new('─', - '┼', - '├', - '┤')) - .separators(&[format::LinePosition::Bottom], - format::LineSeparator::new('─', - '┴', - '└', - '┘')) - .padding(1, 1) - .build()); + table.set_format(*FORMAT_BOX_CHARS); table.add_row(Row::new(vec![Cell::new("1"), Cell::new("1"), Cell::new("1")])); table.add_row(Row::new(vec![Cell::new("2"), Cell::new("2"), Cell::new("2")])); table.set_titles(Row::new(vec![Cell::new("t1"), Cell::new("t2"), Cell::new("t3")])); |