2022-10-03 18:40:16 +02:00
|
|
|
use tabled::{
|
|
|
|
style::RawStyle,
|
|
|
|
style::{HorizontalLine, Line, Style},
|
|
|
|
};
|
2022-07-06 21:57:40 +02:00
|
|
|
|
2022-05-16 17:35:57 +02:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct TableTheme {
|
2022-07-17 20:56:31 +02:00
|
|
|
pub(crate) theme: RawStyle,
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TableTheme {
|
|
|
|
pub fn basic() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
|
|
|
theme: Style::ascii().into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn thin() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
|
|
|
theme: Style::modern().into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn light() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
2022-07-18 18:45:21 +02:00
|
|
|
theme: Style::blank()
|
2022-10-03 18:40:16 +02:00
|
|
|
.horizontals([HorizontalLine::new(
|
|
|
|
1,
|
|
|
|
Line::new(Some('─'), Some('─'), None, None),
|
|
|
|
)])
|
2022-07-18 18:45:21 +02:00
|
|
|
.into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn compact() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
|
|
|
theme: Style::modern()
|
2022-07-17 20:56:31 +02:00
|
|
|
.off_left()
|
|
|
|
.off_right()
|
|
|
|
.off_horizontal()
|
2022-10-03 18:40:16 +02:00
|
|
|
.horizontals([HorizontalLine::new(1, Style::modern().get_horizontal())
|
|
|
|
.left(None)
|
|
|
|
.right(None)])
|
2022-07-06 21:57:40 +02:00
|
|
|
.into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn with_love() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
2022-07-17 20:56:31 +02:00
|
|
|
theme: Style::empty()
|
2022-07-06 21:57:40 +02:00
|
|
|
.top('❤')
|
|
|
|
.bottom('❤')
|
|
|
|
.vertical('❤')
|
2022-10-03 18:40:16 +02:00
|
|
|
.horizontals([HorizontalLine::new(
|
|
|
|
1,
|
|
|
|
Line::new(Some('❤'), Some('❤'), None, None),
|
|
|
|
)])
|
2022-07-06 21:57:40 +02:00
|
|
|
.into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn compact_double() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
2022-07-17 20:56:31 +02:00
|
|
|
theme: Style::extended()
|
|
|
|
.off_left()
|
|
|
|
.off_right()
|
|
|
|
.off_horizontal()
|
2022-10-03 18:40:16 +02:00
|
|
|
.horizontals([HorizontalLine::new(1, Style::extended().get_horizontal())
|
|
|
|
.left(None)
|
|
|
|
.right(None)])
|
2022-07-06 21:57:40 +02:00
|
|
|
.into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn rounded() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
|
|
|
theme: Style::rounded().into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn reinforced() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
|
|
|
theme: Style::modern()
|
|
|
|
.top_left_corner('┏')
|
|
|
|
.top_right_corner('┓')
|
|
|
|
.bottom_left_corner('┗')
|
|
|
|
.bottom_right_corner('┛')
|
2022-07-17 20:56:31 +02:00
|
|
|
.off_horizontal()
|
2022-07-06 21:57:40 +02:00
|
|
|
.into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn heavy() -> TableTheme {
|
2022-07-06 21:57:40 +02:00
|
|
|
Self {
|
2022-07-17 20:56:31 +02:00
|
|
|
theme: Style::empty()
|
2022-07-06 21:57:40 +02:00
|
|
|
.top('━')
|
|
|
|
.bottom('━')
|
|
|
|
.vertical('┃')
|
|
|
|
.left('┃')
|
|
|
|
.right('┃')
|
|
|
|
.top_intersection('┳')
|
2022-07-17 20:56:31 +02:00
|
|
|
.bottom_intersection('┻')
|
2022-07-06 21:57:40 +02:00
|
|
|
.top_left_corner('┏')
|
|
|
|
.top_right_corner('┓')
|
|
|
|
.bottom_left_corner('┗')
|
|
|
|
.bottom_right_corner('┛')
|
2022-10-03 18:40:16 +02:00
|
|
|
.horizontals([HorizontalLine::new(1, Line::full('━', '╋', '┣', '┫'))])
|
2022-07-06 21:57:40 +02:00
|
|
|
.into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-06 21:57:40 +02:00
|
|
|
pub fn none() -> TableTheme {
|
|
|
|
Self {
|
|
|
|
theme: Style::blank().into(),
|
2022-05-16 17:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|