diff options
| author | P T Weir <phil.weir@flaxandteal.co.uk> | 2024-07-23 12:03:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-23 12:03:00 +0100 |
| commit | 17ed668aacd067c645d7de19d4dc7ae652aa760a (patch) | |
| tree | 93c67921f62554b35a2b4980dceca60ddf015903 /crates/atuin-history/src | |
| parent | feat(gui): background terminals and more (#2303) (diff) | |
| download | atuin-17ed668aacd067c645d7de19d4dc7ae652aa760a.zip | |
fix(themes): Restore default theme, refactor (#2294)
* fix(theme): let the base colour remain unchanged
* fix(theme): split out default
* fix(theme): make base theme 'default' not an empty string
* wip(theme): return styles, not colors
* wip(theme): tidy up module structure a little
* wip(theme): removed unhandled references to foreground_color
* chore: fix cargo fmt
* feat(theme): allow crossterm-deserializable colors
Diffstat (limited to 'crates/atuin-history/src')
| -rw-r--r-- | crates/atuin-history/src/stats.rs | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/crates/atuin-history/src/stats.rs b/crates/atuin-history/src/stats.rs index 92e08340..6312f518 100644 --- a/crates/atuin-history/src/stats.rs +++ b/crates/atuin-history/src/stats.rs @@ -1,10 +1,10 @@ use std::collections::{HashMap, HashSet}; -use crossterm::style::{ResetColor, SetAttribute, SetForegroundColor}; +use crossterm::style::{Color, ResetColor, SetAttribute, SetForegroundColor}; use serde::{Deserialize, Serialize}; use unicode_segmentation::UnicodeSegmentation; -use atuin_client::{history::History, settings::Settings, theme::Theme}; +use atuin_client::{history::History, settings::Settings, theme::Meaning, theme::Theme}; #[derive(Debug, Serialize, Deserialize)] pub struct Stats { @@ -126,21 +126,42 @@ pub fn pretty_print(stats: Stats, ngram_size: usize, theme: &Theme) { }); for (command, count) in stats.top { - let gray = SetForegroundColor(theme.get_base()); + let gray = SetForegroundColor(match theme.as_style(Meaning::Muted).foreground_color { + Some(color) => color, + None => Color::Grey, + }); let bold = SetAttribute(crossterm::style::Attribute::Bold); let in_ten = 10 * count / max; print!("["); - print!("{}", SetForegroundColor(theme.get_error())); + print!( + "{}", + SetForegroundColor(match theme.get_error().foreground_color { + Some(color) => color, + None => Color::Red, + }) + ); for i in 0..in_ten { if i == 2 { - print!("{}", SetForegroundColor(theme.get_warning())); + print!( + "{}", + SetForegroundColor(match theme.get_warning().foreground_color { + Some(color) => color, + None => Color::Yellow, + }) + ); } if i == 5 { - print!("{}", SetForegroundColor(theme.get_info())); + print!( + "{}", + SetForegroundColor(match theme.get_info().foreground_color { + Some(color) => color, + None => Color::Green, + }) + ); } print!("▮"); |
