mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 01:19:25 +01:00
Use Unicode box-drawing characters for tables
This commit is contained in:
parent
cd1e16d574
commit
9de0b27867
@ -1,3 +1,4 @@
|
||||
crate mod consts;
|
||||
crate mod entries;
|
||||
crate mod generic;
|
||||
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::prelude::*;
|
||||
use ansi_term::Color;
|
||||
use derive_new::new;
|
||||
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator};
|
||||
use textwrap::fill;
|
||||
|
||||
use prettytable::{color, Attr, Cell, Row, Table};
|
||||
@ -191,16 +190,7 @@ impl RenderView for TableView {
|
||||
}
|
||||
|
||||
let mut table = Table::new();
|
||||
|
||||
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());
|
||||
table.set_format(*consts::TABLE_FORMAT);
|
||||
|
||||
let header: Vec<Cell> = self
|
||||
.headers
|
||||
|
@ -1,8 +1,7 @@
|
||||
use crate::format::RenderView;
|
||||
use crate::format::{RenderView, consts};
|
||||
use crate::object::Value;
|
||||
use crate::prelude::*;
|
||||
use derive_new::new;
|
||||
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator};
|
||||
|
||||
use prettytable::{color, Attr, Cell, Row, Table};
|
||||
|
||||
@ -47,14 +46,7 @@ impl RenderView for VTableView {
|
||||
}
|
||||
|
||||
let mut table = Table::new();
|
||||
|
||||
let fb = FormatBuilder::new()
|
||||
.separator(LinePosition::Top, LineSeparator::new('-', '+', ' ', ' '))
|
||||
.separator(LinePosition::Bottom, LineSeparator::new('-', '+', ' ', ' '))
|
||||
.column_separator('|')
|
||||
.padding(1, 1);
|
||||
|
||||
table.set_format(fb.build());
|
||||
table.set_format(*consts::TABLE_FORMAT);
|
||||
|
||||
for row in &self.entries {
|
||||
table.add_row(Row::new(
|
||||
|
Loading…
Reference in New Issue
Block a user