From 61c6e5e46a9caa45956239082ed8b6b524686453 Mon Sep 17 00:00:00 2001 From: P T Weir Date: Mon, 15 Jul 2024 10:18:46 +0100 Subject: feat(tui): Customizable Themes (#2236) * wip: add theme * feat(theme): basic theming approach * feat(theme): adds theming support * fix: split out palette without compact inspector * fix(theme): tidy up implementation * fix(theme): correct yaml to toml * fix(theme): typo in comments * chore: cheer up clippy * fix(themes): ensure tests cannot hit real loading directory * chore: rustfmt * chore: rebase * feat(themes): add rgb hexcode support * fix(theme): add tests * fix(theme): use builtin log levels and correct debug test * feat(theme): adds the ability to derive from a non-base theme * fix(theme): warn if the in-file name of a theme does not match the filename * chore: tidy for rustfmt and clippy * chore: tidy for rustfmt and clippy --- crates/atuin-history/src/stats.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/atuin-history/src') diff --git a/crates/atuin-history/src/stats.rs b/crates/atuin-history/src/stats.rs index b73a5dbb..92e08340 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::{Color, ResetColor, SetAttribute, SetForegroundColor}; +use crossterm::style::{ResetColor, SetAttribute, SetForegroundColor}; use serde::{Deserialize, Serialize}; use unicode_segmentation::UnicodeSegmentation; -use atuin_client::{history::History, settings::Settings}; +use atuin_client::{history::History, settings::Settings, theme::Theme}; #[derive(Debug, Serialize, Deserialize)] pub struct Stats { @@ -109,7 +109,7 @@ fn split_at_pipe(command: &str) -> Vec<&str> { result } -pub fn pretty_print(stats: Stats, ngram_size: usize) { +pub fn pretty_print(stats: Stats, ngram_size: usize, theme: &Theme) { let max = stats.top.iter().map(|x| x.1).max().unwrap(); let num_pad = max.ilog10() as usize + 1; @@ -126,21 +126,21 @@ pub fn pretty_print(stats: Stats, ngram_size: usize) { }); for (command, count) in stats.top { - let gray = SetForegroundColor(Color::Grey); + let gray = SetForegroundColor(theme.get_base()); let bold = SetAttribute(crossterm::style::Attribute::Bold); let in_ten = 10 * count / max; print!("["); - print!("{}", SetForegroundColor(Color::Red)); + print!("{}", SetForegroundColor(theme.get_error())); for i in 0..in_ten { if i == 2 { - print!("{}", SetForegroundColor(Color::Yellow)); + print!("{}", SetForegroundColor(theme.get_warning())); } if i == 5 { - print!("{}", SetForegroundColor(Color::Green)); + print!("{}", SetForegroundColor(theme.get_info())); } print!("▮"); -- cgit v1.3.1