From 2ffff959fcd54bb0465433f0b1fdf6c8a05590b5 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:34:36 -0500 Subject: [PATCH] add 6 more table themes (#10279) # Description After looking at a users terminal that didn't support UTF-8, I wanted to add some themes that may help them. Here's what they look like. ## psql ![image](https://github.com/nushell/nushell/assets/343840/67ac003a-72f1-4e2b-8bb0-244b70385d59) ## markdown ![image](https://github.com/nushell/nushell/assets/343840/a8f4a439-013b-48ee-b9e0-284ec47d1eef) ## dots please excuse the different theme ![image](https://github.com/nushell/nushell/assets/343840/fb931650-cc64-4f0a-bf3d-ec736e0374ad) ## restructured ![image](https://github.com/nushell/nushell/assets/343840/80595a8e-f2b3-49dc-ad02-81e94bde5253) ## ascii_rounded ![image](https://github.com/nushell/nushell/assets/343840/42f0b8b2-1fd2-4ae5-b28c-477e83ded354) ## basic_compact ![image](https://github.com/nushell/nushell/assets/343840/5888b6b2-b9b8-48bc-963e-5a76ef246adc) # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/viewers/table.rs | 6 ++++ crates/nu-table/src/common.rs | 6 ++++ crates/nu-table/src/table_theme.rs | 50 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index 1bd81690be..bb2523a068 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -330,6 +330,12 @@ fn supported_table_modes() -> Vec { Value::test_string("rounded"), Value::test_string("thin"), Value::test_string("with_love"), + Value::test_string("psql"), + Value::test_string("markdown"), + Value::test_string("dots"), + Value::test_string("restructured"), + Value::test_string("ascii_rounded"), + Value::test_string("basic_compact"), ] } diff --git a/crates/nu-table/src/common.rs b/crates/nu-table/src/common.rs index 257c66749c..eac5dab57b 100644 --- a/crates/nu-table/src/common.rs +++ b/crates/nu-table/src/common.rs @@ -157,6 +157,12 @@ pub fn load_theme_from_config(config: &Config) -> TableTheme { "reinforced" => TableTheme::reinforced(), "heavy" => TableTheme::heavy(), "none" => TableTheme::none(), + "psql" => TableTheme::psql(), + "markdown" => TableTheme::markdown(), + "dots" => TableTheme::dots(), + "restructured" => TableTheme::resturctured(), + "ascii_rounded" => TableTheme::ascii_rounded(), + "basic_compact" => TableTheme::basic_compact(), _ => TableTheme::rounded(), } } diff --git a/crates/nu-table/src/table_theme.rs b/crates/nu-table/src/table_theme.rs index befbe1c46e..efe4aa0253 100644 --- a/crates/nu-table/src/table_theme.rs +++ b/crates/nu-table/src/table_theme.rs @@ -38,6 +38,56 @@ impl TableTheme { } } + pub fn psql() -> TableTheme { + Self { + theme: Style::psql().into(), + full_theme: Style::psql().into(), + has_inner: true, + } + } + + pub fn markdown() -> TableTheme { + Self { + theme: Style::markdown().into(), + full_theme: Style::markdown().into(), + has_inner: true, + } + } + + pub fn dots() -> TableTheme { + let theme = Style::dots().remove_horizontal().into(); + Self { + theme, + full_theme: Style::dots().into(), + has_inner: true, + } + } + + pub fn resturctured() -> TableTheme { + Self { + theme: Style::re_structured_text().into(), + full_theme: Style::re_structured_text().into(), + has_inner: true, + } + } + + pub fn ascii_rounded() -> TableTheme { + Self { + theme: Style::ascii_rounded().into(), + full_theme: Style::ascii_rounded().into(), + has_inner: true, + } + } + + pub fn basic_compact() -> TableTheme { + let theme = Style::ascii().remove_horizontal().into(); + Self { + theme, + full_theme: Style::ascii().into(), + has_inner: true, + } + } + pub fn compact() -> TableTheme { let theme = Style::modern() .remove_left()