summaryrefslogtreecommitdiffstats
path: root/vendor/prettydiff/src/format_table.rs
blob: 7293faefde9550767081d63a276ad289fef052f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Setup unicode-formatted table for prettytable
//!
//! TODO: Move to separate crate

use prettytable::format;
use prettytable::Table;

fn format_table(table: &mut Table) {
    table.set_format(
        format::FormatBuilder::new()
            .column_separator('│')
            .borders('│')
            .separators(
                &[format::LinePosition::Top],
                format::LineSeparator::new('─', '┬', '┌', '┐'),
            )
            .separators(
                &[format::LinePosition::Title],
                format::LineSeparator::new('─', '┼', '├', '┤'),
            )
            .separators(
                &[format::LinePosition::Intern],
                format::LineSeparator::new('─', '┼', '├', '┤'),
            )
            .separators(
                &[format::LinePosition::Bottom],
                format::LineSeparator::new('─', '┴', '└', '┘'),
            )
            .padding(1, 1)
            .build(),
    );
}
/// Returns Table with unicode formatter
pub fn new() -> Table {
    let mut table = Table::new();
    format_table(&mut table);
    table
}