diff options
| author | Ellie Huxtable <ellie@atuin.sh> | 2026-01-27 13:51:41 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-27 13:51:41 -0800 |
| commit | 3ed6e6b8776185a57f5ce29a28b7b60174385ac1 (patch) | |
| tree | 22f6c8edb45874fd2c18ec837f3e419e1bfdce1a /crates/atuin-client/src | |
| parent | fix: do not set ATUIN_SESSION if it is already set (#3107) (diff) | |
| download | atuin-3ed6e6b8776185a57f5ce29a28b7b60174385ac1.zip | |
chore(deps): cleanup of dep versions (#3106)
Ensure we aren't using multiple versions, etc
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
## Checks
- [ ] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [ ] I have checked that there are no existing pull requests for the
same thing
Diffstat (limited to 'crates/atuin-client/src')
| -rw-r--r-- | crates/atuin-client/src/theme.rs | 201 |
1 files changed, 101 insertions, 100 deletions
diff --git a/crates/atuin-client/src/theme.rs b/crates/atuin-client/src/theme.rs index 76ddbb22..a277ac13 100644 --- a/crates/atuin-client/src/theme.rs +++ b/crates/atuin-client/src/theme.rs @@ -1,5 +1,4 @@ use config::{Config, File as ConfigFile, FileFormat}; -use lazy_static::lazy_static; use log; use palette::named; use serde::{Deserialize, Serialize}; @@ -8,6 +7,7 @@ use std::collections::HashMap; use std::error; use std::io::{Error, ErrorKind}; use std::path::PathBuf; +use std::sync::LazyLock; use strum_macros; static DEFAULT_MAX_DEPTH: u8 = 10; @@ -241,122 +241,123 @@ impl StyleFactory { // Built-in themes. Rather than having extra files added before any theming // is available, this gives a couple of basic options, demonstrating the use // of themes: autumn and marine -lazy_static! { - static ref ALERT_TYPES: HashMap<log::Level, Meaning> = { - HashMap::from([ - (log::Level::Info, Meaning::AlertInfo), - (log::Level::Warn, Meaning::AlertWarn), - (log::Level::Error, Meaning::AlertError), - ]) - }; - static ref MEANING_FALLBACKS: HashMap<Meaning, Meaning> = { +static ALERT_TYPES: LazyLock<HashMap<log::Level, Meaning>> = LazyLock::new(|| { + HashMap::from([ + (log::Level::Info, Meaning::AlertInfo), + (log::Level::Warn, Meaning::AlertWarn), + (log::Level::Error, Meaning::AlertError), + ]) +}); + +static MEANING_FALLBACKS: LazyLock<HashMap<Meaning, Meaning>> = LazyLock::new(|| { + HashMap::from([ + (Meaning::Guidance, Meaning::AlertInfo), + (Meaning::Annotation, Meaning::AlertInfo), + (Meaning::Title, Meaning::Important), + ]) +}); + +static DEFAULT_THEME: LazyLock<Theme> = LazyLock::new(|| { + Theme::new( + "default".to_string(), + None, HashMap::from([ - (Meaning::Guidance, Meaning::AlertInfo), - (Meaning::Annotation, Meaning::AlertInfo), - (Meaning::Title, Meaning::Important), - ]) - }; - static ref DEFAULT_THEME: Theme = { - Theme::new( - "default".to_string(), - None, + ( + Meaning::AlertError, + StyleFactory::from_fg_color(Color::DarkRed), + ), + ( + Meaning::AlertWarn, + StyleFactory::from_fg_color(Color::DarkYellow), + ), + ( + Meaning::AlertInfo, + StyleFactory::from_fg_color(Color::DarkGreen), + ), + ( + Meaning::Annotation, + StyleFactory::from_fg_color(Color::DarkGrey), + ), + ( + Meaning::Guidance, + StyleFactory::from_fg_color(Color::DarkBlue), + ), + ( + Meaning::Important, + StyleFactory::from_fg_color_and_attributes( + Color::White, + Attributes::from(Attribute::Bold), + ), + ), + (Meaning::Muted, StyleFactory::from_fg_color(Color::Grey)), + (Meaning::Base, ContentStyle::default()), + ]), + ) +}); + +static BUILTIN_THEMES: LazyLock<HashMap<&'static str, Theme>> = LazyLock::new(|| { + 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([ ( Meaning::AlertError, - StyleFactory::from_fg_color(Color::DarkRed), + StyleFactory::known_fg_string("saddlebrown"), ), ( Meaning::AlertWarn, - StyleFactory::from_fg_color(Color::DarkYellow), - ), - ( - Meaning::AlertInfo, - StyleFactory::from_fg_color(Color::DarkGreen), + StyleFactory::known_fg_string("darkorange"), ), + (Meaning::AlertInfo, StyleFactory::known_fg_string("gold")), ( Meaning::Annotation, StyleFactory::from_fg_color(Color::DarkGrey), ), + (Meaning::Guidance, StyleFactory::known_fg_string("brown")), + ]), + ), + ( + "marine", + HashMap::from([ ( - Meaning::Guidance, - StyleFactory::from_fg_color(Color::DarkBlue), + Meaning::AlertError, + StyleFactory::known_fg_string("yellowgreen"), ), + (Meaning::AlertWarn, StyleFactory::known_fg_string("cyan")), ( - Meaning::Important, - StyleFactory::from_fg_color_and_attributes( - Color::White, - Attributes::from(Attribute::Bold), - ), + Meaning::AlertInfo, + StyleFactory::known_fg_string("turquoise"), ), - (Meaning::Muted, StyleFactory::from_fg_color(Color::Grey)), - (Meaning::Base, ContentStyle::default()), + ( + Meaning::Annotation, + StyleFactory::known_fg_string("steelblue"), + ), + ( + Meaning::Base, + StyleFactory::known_fg_string("lightsteelblue"), + ), + (Meaning::Guidance, StyleFactory::known_fg_string("teal")), ]), - ) - }; - static ref BUILTIN_THEMES: HashMap<&'static str, Theme> = { - 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([ - ( - Meaning::AlertError, - StyleFactory::known_fg_string("saddlebrown"), - ), - ( - Meaning::AlertWarn, - StyleFactory::known_fg_string("darkorange"), - ), - (Meaning::AlertInfo, StyleFactory::known_fg_string("gold")), - ( - Meaning::Annotation, - StyleFactory::from_fg_color(Color::DarkGrey), - ), - (Meaning::Guidance, StyleFactory::known_fg_string("brown")), - ]), - ), - ( - "marine", - HashMap::from([ - ( - Meaning::AlertError, - StyleFactory::known_fg_string("yellowgreen"), - ), - (Meaning::AlertWarn, StyleFactory::known_fg_string("cyan")), - ( - Meaning::AlertInfo, - StyleFactory::known_fg_string("turquoise"), - ), - ( - Meaning::Annotation, - StyleFactory::known_fg_string("steelblue"), - ), - ( - Meaning::Base, - StyleFactory::known_fg_string("lightsteelblue"), - ), - (Meaning::Guidance, StyleFactory::known_fg_string("teal")), - ]), - ), - ]) - .iter() - .map(|(name, theme)| (*name, Theme::from_map(name.to_string(), None, theme))) - .collect() - }; -} + ), + ]) + .iter() + .map(|(name, theme)| (*name, Theme::from_map(name.to_string(), None, theme))) + .collect() +}); // To avoid themes being repeatedly loaded, we store them in a theme manager pub struct ThemeManager { |
