mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 01:17:47 +02:00
nu-table/ table --collapse style fix (#8041)
close #8033 So as I said they suppose to be there; I've basically added a change of style if --collapse is used. PS: I guess it's worth to add tests so hold on if you'll plan to merge it. --------- Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
This commit is contained in:
@ -201,7 +201,7 @@ fn load_theme<R>(table: &mut tabled::Table<R>, style_computer: &StyleComputer, t
|
||||
where
|
||||
R: Records,
|
||||
{
|
||||
let mut theme = theme.theme.clone();
|
||||
let mut theme = theme.into_full().unwrap_or_else(|| theme.theme.clone());
|
||||
theme.set_horizontals(HashMap::default());
|
||||
|
||||
table.with(theme);
|
||||
|
@ -7,12 +7,14 @@ use tabled::{
|
||||
pub struct TableTheme {
|
||||
pub(crate) theme: RawStyle,
|
||||
has_inner: bool,
|
||||
full_theme: Option<RawStyle>,
|
||||
}
|
||||
|
||||
impl TableTheme {
|
||||
pub fn basic() -> TableTheme {
|
||||
Self {
|
||||
theme: Style::ascii().into(),
|
||||
full_theme: None,
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -20,6 +22,7 @@ impl TableTheme {
|
||||
pub fn thin() -> TableTheme {
|
||||
Self {
|
||||
theme: Style::modern().into(),
|
||||
full_theme: None,
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -32,7 +35,7 @@ impl TableTheme {
|
||||
Line::new(Some('─'), Some('─'), None, None),
|
||||
)])
|
||||
.into(),
|
||||
|
||||
full_theme: Some(Style::modern().into()),
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -47,6 +50,7 @@ impl TableTheme {
|
||||
.left(None)
|
||||
.right(None)])
|
||||
.into(),
|
||||
full_theme: Some(Style::modern().into()),
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -62,6 +66,25 @@ impl TableTheme {
|
||||
Line::new(Some('❤'), Some('❤'), None, None),
|
||||
)])
|
||||
.into(),
|
||||
full_theme: Some(
|
||||
Style::empty()
|
||||
.top('❤')
|
||||
.bottom('❤')
|
||||
.vertical('❤')
|
||||
.horizontal('❤')
|
||||
.left('❤')
|
||||
.right('❤')
|
||||
.top_intersection('❤')
|
||||
.top_left_corner('❤')
|
||||
.top_right_corner('❤')
|
||||
.bottom_intersection('❤')
|
||||
.bottom_left_corner('❤')
|
||||
.bottom_right_corner('❤')
|
||||
.right_intersection('❤')
|
||||
.left_intersection('❤')
|
||||
.inner_intersection('❤')
|
||||
.into(),
|
||||
),
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -76,6 +99,7 @@ impl TableTheme {
|
||||
.left(None)
|
||||
.right(None)])
|
||||
.into(),
|
||||
full_theme: Some(Style::extended().into()),
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -83,6 +107,14 @@ impl TableTheme {
|
||||
pub fn rounded() -> TableTheme {
|
||||
Self {
|
||||
theme: Style::rounded().into(),
|
||||
full_theme: Some(
|
||||
Style::modern()
|
||||
.top_left_corner('╭')
|
||||
.top_right_corner('╮')
|
||||
.bottom_left_corner('╰')
|
||||
.bottom_right_corner('╯')
|
||||
.into(),
|
||||
),
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -96,6 +128,14 @@ impl TableTheme {
|
||||
.bottom_right_corner('┛')
|
||||
.off_horizontal()
|
||||
.into(),
|
||||
full_theme: Some(
|
||||
Style::modern()
|
||||
.top_left_corner('┏')
|
||||
.top_right_corner('┓')
|
||||
.bottom_left_corner('┗')
|
||||
.bottom_right_corner('┛')
|
||||
.into(),
|
||||
),
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -116,6 +156,25 @@ impl TableTheme {
|
||||
.bottom_right_corner('┛')
|
||||
.horizontals([HorizontalLine::new(1, Line::full('━', '╋', '┣', '┫'))])
|
||||
.into(),
|
||||
full_theme: Some(
|
||||
Style::modern()
|
||||
.top('━')
|
||||
.bottom('━')
|
||||
.vertical('┃')
|
||||
.left('┃')
|
||||
.right('┃')
|
||||
.top_intersection('┳')
|
||||
.bottom_intersection('┻')
|
||||
.top_left_corner('┏')
|
||||
.top_right_corner('┓')
|
||||
.bottom_left_corner('┗')
|
||||
.bottom_right_corner('┛')
|
||||
.horizontal('━')
|
||||
.left_intersection('┣')
|
||||
.right_intersection('┫')
|
||||
.inner_intersection('╋')
|
||||
.into(),
|
||||
),
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -123,6 +182,7 @@ impl TableTheme {
|
||||
pub fn none() -> TableTheme {
|
||||
Self {
|
||||
theme: Style::blank().into(),
|
||||
full_theme: None,
|
||||
has_inner: true,
|
||||
}
|
||||
}
|
||||
@ -151,4 +211,8 @@ impl TableTheme {
|
||||
pub fn has_inner(&self) -> bool {
|
||||
self.has_inner
|
||||
}
|
||||
|
||||
pub fn into_full(&self) -> Option<RawStyle> {
|
||||
self.full_theme.clone()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user