summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com>2018-09-24 11:07:01 +0200
committerPierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com>2018-09-24 11:07:01 +0200
commitb8fcf15e69db1622e8fc432b2bd1e2f4e199fc45 (patch)
treea01d0e0d15b7c2124fb101b081426ec0b383050e
parent5beefd99dbfc48123d53c1e66fbde49d2589a202 (diff)
parent94a039ff3959d1459db2dd80518a56a729dc2929 (diff)
Merge branch 'master' into lines_count
-rw-r--r--src/format.rs33
-rw-r--r--src/lib.rs23
2 files changed, 35 insertions, 21 deletions
diff --git a/src/format.rs b/src/format.rs
index 7cf644e..ddf6713 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -522,5 +522,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();
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 3aa6866..65f8b0c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -593,7 +593,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};
use utils::StringWriter;
#[test]
@@ -888,26 +888,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")]));