mirror of
https://github.com/nushell/nushell.git
synced 2024-12-22 23:23:12 +01:00
commit
628da27122
@ -1,4 +1,3 @@
|
||||
crate mod consts;
|
||||
crate mod entries;
|
||||
crate mod generic;
|
||||
crate mod list;
|
||||
|
@ -1,14 +0,0 @@
|
||||
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,10 @@
|
||||
use crate::format::{RenderView, consts};
|
||||
use crate::format::RenderView;
|
||||
use crate::object::Value;
|
||||
use crate::prelude::*;
|
||||
use derive_new::new;
|
||||
use textwrap::fill;
|
||||
|
||||
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator};
|
||||
use prettytable::{color, Attr, Cell, Row, Table};
|
||||
|
||||
#[derive(Debug, new)]
|
||||
@ -49,9 +50,12 @@ impl TableView {
|
||||
} => headers
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, d)| {
|
||||
.map(|(i, d)| {
|
||||
let data = value.get_data(d);
|
||||
return (data.borrow().format_leaf(Some(&headers[i])), data.borrow().style_leaf());
|
||||
return (
|
||||
data.borrow().format_leaf(Some(&headers[i])),
|
||||
data.borrow().style_leaf(),
|
||||
);
|
||||
})
|
||||
.collect(),
|
||||
x => vec![(x.format_leaf(None), x.style_leaf())],
|
||||
@ -191,7 +195,15 @@ impl RenderView for TableView {
|
||||
}
|
||||
|
||||
let mut table = Table::new();
|
||||
table.set_format(*consts::TABLE_FORMAT);
|
||||
table.set_format(
|
||||
FormatBuilder::new()
|
||||
.column_separator('│')
|
||||
.separator(LinePosition::Top, LineSeparator::new('━', '┯', ' ', ' '))
|
||||
.separator(LinePosition::Title, LineSeparator::new('─', '┼', ' ', ' '))
|
||||
.separator(LinePosition::Bottom, LineSeparator::new('━', '┷', ' ', ' '))
|
||||
.padding(1, 1)
|
||||
.build(),
|
||||
);
|
||||
|
||||
let header: Vec<Cell> = self
|
||||
.headers
|
||||
@ -206,7 +218,11 @@ impl RenderView for TableView {
|
||||
table.set_titles(Row::new(header));
|
||||
|
||||
for row in &self.entries {
|
||||
table.add_row(Row::new(row.iter().map(|(v, s)| Cell::new(v).style_spec(s)).collect()));
|
||||
table.add_row(Row::new(
|
||||
row.iter()
|
||||
.map(|(v, s)| Cell::new(v).style_spec(s))
|
||||
.collect(),
|
||||
));
|
||||
}
|
||||
|
||||
table.print_term(&mut *host.out_terminal()).unwrap();
|
||||
|
@ -1,8 +1,9 @@
|
||||
use crate::format::{RenderView, consts};
|
||||
use crate::format::RenderView;
|
||||
use crate::object::Value;
|
||||
use crate::prelude::*;
|
||||
use derive_new::new;
|
||||
|
||||
use prettytable::format::{FormatBuilder, LinePosition, LineSeparator};
|
||||
use prettytable::{color, Attr, Cell, Row, Table};
|
||||
|
||||
#[derive(new)]
|
||||
@ -46,7 +47,15 @@ impl RenderView for VTableView {
|
||||
}
|
||||
|
||||
let mut table = Table::new();
|
||||
table.set_format(*consts::TABLE_FORMAT);
|
||||
table.set_format(
|
||||
FormatBuilder::new()
|
||||
.column_separator('│')
|
||||
.separator(LinePosition::Top, LineSeparator::new('━', '┯', ' ', ' '))
|
||||
.separator(LinePosition::Title, LineSeparator::new('─', '┼', ' ', ' '))
|
||||
.separator(LinePosition::Bottom, LineSeparator::new('━', '┷', ' ', ' '))
|
||||
.padding(1, 1)
|
||||
.build(),
|
||||
);
|
||||
|
||||
for row in &self.entries {
|
||||
table.add_row(Row::new(
|
||||
|
Loading…
Reference in New Issue
Block a user