forked from extern/nushell
Merge pull request #349 from Porges/box-drawing
Use Unicode box-drawing characters for tables
This commit is contained in:
commit
8ff418dc00
@ -1,3 +1,4 @@
|
|||||||
|
crate mod consts;
|
||||||
crate mod entries;
|
crate mod entries;
|
||||||
crate mod generic;
|
crate mod generic;
|
||||||
crate mod list;
|
crate mod list;
|
||||||
|
14
src/format/consts.rs
Normal file
14
src/format/consts.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
|
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator, TableFormat};
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub(crate) static ref TABLE_FORMAT: TableFormat =
|
||||||
|
FormatBuilder::new()
|
||||||
|
.column_separator('│')
|
||||||
|
.separator(LinePosition::Top, LineSeparator::new('━', '┯', ' ', ' '))
|
||||||
|
.separator(LinePosition::Title, LineSeparator::new('─', '┼', ' ', ' '))
|
||||||
|
.separator(LinePosition::Bottom, LineSeparator::new('━', '┷', ' ', ' '))
|
||||||
|
.padding(1, 1)
|
||||||
|
.build();
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
use crate::format::RenderView;
|
use crate::format::{RenderView, consts};
|
||||||
use crate::object::Value;
|
use crate::object::Value;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use ansi_term::Color;
|
use ansi_term::Color;
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator};
|
|
||||||
use textwrap::fill;
|
use textwrap::fill;
|
||||||
|
|
||||||
use prettytable::{color, Attr, Cell, Row, Table};
|
use prettytable::{color, Attr, Cell, Row, Table};
|
||||||
@ -191,16 +190,7 @@ impl RenderView for TableView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
|
table.set_format(*consts::TABLE_FORMAT);
|
||||||
let fb = FormatBuilder::new()
|
|
||||||
.separator(LinePosition::Top, LineSeparator::new('-', '+', ' ', ' '))
|
|
||||||
.separator(LinePosition::Bottom, LineSeparator::new('-', '+', ' ', ' '))
|
|
||||||
.separator(LinePosition::Title, LineSeparator::new('-', '+', '|', '|'))
|
|
||||||
.column_separator('|')
|
|
||||||
.padding(1, 1);
|
|
||||||
|
|
||||||
//table.set_format(*prettytable::format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
|
|
||||||
table.set_format(fb.build());
|
|
||||||
|
|
||||||
let header: Vec<Cell> = self
|
let header: Vec<Cell> = self
|
||||||
.headers
|
.headers
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use crate::format::RenderView;
|
use crate::format::{RenderView, consts};
|
||||||
use crate::object::Value;
|
use crate::object::Value;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator};
|
|
||||||
|
|
||||||
use prettytable::{color, Attr, Cell, Row, Table};
|
use prettytable::{color, Attr, Cell, Row, Table};
|
||||||
|
|
||||||
@ -47,14 +46,7 @@ impl RenderView for VTableView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
|
table.set_format(*consts::TABLE_FORMAT);
|
||||||
let fb = FormatBuilder::new()
|
|
||||||
.separator(LinePosition::Top, LineSeparator::new('-', '+', ' ', ' '))
|
|
||||||
.separator(LinePosition::Bottom, LineSeparator::new('-', '+', ' ', ' '))
|
|
||||||
.column_separator('|')
|
|
||||||
.padding(1, 1);
|
|
||||||
|
|
||||||
table.set_format(fb.build());
|
|
||||||
|
|
||||||
for row in &self.entries {
|
for row in &self.entries {
|
||||||
table.add_row(Row::new(
|
table.add_row(Row::new(
|
||||||
|
Loading…
Reference in New Issue
Block a user