diff options
Diffstat (limited to 'crates/atuin-client/src')
| -rw-r--r-- | crates/atuin-client/src/theme.rs | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/crates/atuin-client/src/theme.rs b/crates/atuin-client/src/theme.rs index fc15bfd8..76ddbb22 100644 --- a/crates/atuin-client/src/theme.rs +++ b/crates/atuin-client/src/theme.rs @@ -51,7 +51,7 @@ pub struct ThemeDefinitionConfigBlock { pub parent: Option<String>, } -use crossterm::style::{Color, ContentStyle}; +use crossterm::style::{Attribute, Attributes, Color, ContentStyle}; // For now, a theme is loaded as a mapping of meanings to colors, but it may be desirable to // expand that in the future to general styles, so we populate a Meaning->ContentStyle hashmap. @@ -228,6 +228,14 @@ impl StyleFactory { ..ContentStyle::default() } } + + fn from_fg_color_and_attributes(color: Color, attributes: Attributes) -> ContentStyle { + ContentStyle { + foreground_color: Some(color), + attributes, + ..ContentStyle::default() + } + } } // Built-in themes. Rather than having extra files added before any theming @@ -275,7 +283,10 @@ lazy_static! { ), ( Meaning::Important, - StyleFactory::from_fg_color(Color::White), + StyleFactory::from_fg_color_and_attributes( + Color::White, + Attributes::from(Attribute::Bold), + ), ), (Meaning::Muted, StyleFactory::from_fg_color(Color::Grey)), (Meaning::Base, ContentStyle::default()), @@ -286,6 +297,19 @@ lazy_static! { HashMap::from([ ("default", HashMap::new()), ( + "(none)", + HashMap::from([ + (Meaning::AlertError, ContentStyle::default()), + (Meaning::AlertWarn, ContentStyle::default()), + (Meaning::AlertInfo, ContentStyle::default()), + (Meaning::Annotation, ContentStyle::default()), + (Meaning::Guidance, ContentStyle::default()), + (Meaning::Important, ContentStyle::default()), + (Meaning::Muted, ContentStyle::default()), + (Meaning::Base, ContentStyle::default()), + ]), + ), + ( "autumn", HashMap::from([ ( @@ -430,7 +454,7 @@ impl ThemeManager { } Some(self.load_theme(parent_name.as_str(), Some(max_depth - 1))) } - None => None, + None => Some(self.load_theme("default", Some(max_depth - 1))), }; if debug && name != theme_config.theme.name { @@ -461,7 +485,7 @@ impl ThemeManager { Ok(theme) => theme, Err(err) => { log::warn!("Could not load theme {name}: {err}"); - built_ins.get("default").unwrap() + built_ins.get("(none)").unwrap() } }, } @@ -669,7 +693,8 @@ mod theme_tests { testing_logger::validate(|captured_logs| assert_eq!(captured_logs.len(), 0)); - // If the parent is not found, we end up with the base theme colors + // If the parent is not found, we end up with the no theme colors or styling + // as this is considered a (soft) error state. let nunsolarized = Config::builder() .add_source(ConfigFile::from_str( " @@ -692,7 +717,7 @@ mod theme_tests { nunsolarized_theme .as_style(Meaning::Guidance) .foreground_color, - Some(Color::DarkBlue) + None ); testing_logger::validate(|captured_logs| { |
