mirror of
https://github.com/nushell/nushell.git
synced 2025-04-11 14:58:21 +02:00
* nu-table: Fix header style It did appeared again after my small change... Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com> * nu-table: Add a empty header style test Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
105 lines
2.6 KiB
Rust
105 lines
2.6 KiB
Rust
use tabled::style::{Line, RawStyle, Style};
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct TableTheme {
|
|
pub(crate) theme: RawStyle,
|
|
}
|
|
|
|
impl TableTheme {
|
|
pub fn basic() -> TableTheme {
|
|
Self {
|
|
theme: Style::ascii().into(),
|
|
}
|
|
}
|
|
|
|
pub fn thin() -> TableTheme {
|
|
Self {
|
|
theme: Style::modern().into(),
|
|
}
|
|
}
|
|
|
|
pub fn light() -> TableTheme {
|
|
Self {
|
|
theme: Style::blank()
|
|
.lines([(1, Line::new(Some('─'), Some('─'), None, None))])
|
|
.into(),
|
|
}
|
|
}
|
|
|
|
pub fn compact() -> TableTheme {
|
|
Self {
|
|
theme: Style::modern()
|
|
.off_left()
|
|
.off_right()
|
|
.off_horizontal()
|
|
.lines([(1, Style::modern().get_horizontal().left(None).right(None))])
|
|
.into(),
|
|
}
|
|
}
|
|
|
|
pub fn with_love() -> TableTheme {
|
|
Self {
|
|
theme: Style::empty()
|
|
.top('❤')
|
|
.bottom('❤')
|
|
.vertical('❤')
|
|
.lines([(1, Line::new(Some('❤'), Some('❤'), None, None))])
|
|
.into(),
|
|
}
|
|
}
|
|
|
|
pub fn compact_double() -> TableTheme {
|
|
Self {
|
|
theme: Style::extended()
|
|
.off_left()
|
|
.off_right()
|
|
.off_horizontal()
|
|
.lines([(1, Style::extended().get_horizontal().left(None).right(None))])
|
|
.into(),
|
|
}
|
|
}
|
|
|
|
pub fn rounded() -> TableTheme {
|
|
Self {
|
|
theme: Style::rounded().into(),
|
|
}
|
|
}
|
|
|
|
pub fn reinforced() -> TableTheme {
|
|
Self {
|
|
theme: Style::modern()
|
|
.top_left_corner('┏')
|
|
.top_right_corner('┓')
|
|
.bottom_left_corner('┗')
|
|
.bottom_right_corner('┛')
|
|
.off_horizontal()
|
|
.into(),
|
|
}
|
|
}
|
|
|
|
pub fn heavy() -> TableTheme {
|
|
Self {
|
|
theme: Style::empty()
|
|
.top('━')
|
|
.bottom('━')
|
|
.vertical('┃')
|
|
.left('┃')
|
|
.right('┃')
|
|
.top_intersection('┳')
|
|
.bottom_intersection('┻')
|
|
.top_left_corner('┏')
|
|
.top_right_corner('┓')
|
|
.bottom_left_corner('┗')
|
|
.bottom_right_corner('┛')
|
|
.lines([(1, Line::full('━', '╋', '┣', '┫'))])
|
|
.into(),
|
|
}
|
|
}
|
|
|
|
pub fn none() -> TableTheme {
|
|
Self {
|
|
theme: Style::blank().into(),
|
|
}
|
|
}
|
|
}
|