aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-history/src
diff options
context:
space:
mode:
authorP T Weir <phil.weir@flaxandteal.co.uk>2024-07-15 10:18:46 +0100
committerGitHub <noreply@github.com>2024-07-15 10:18:46 +0100
commit61c6e5e46a9caa45956239082ed8b6b524686453 (patch)
treec29c8594c337a76a95f1a544f5a2ee5a2bbb693a /crates/atuin-history/src
parentchore(deps): bump @tauri-apps/api in /ui (#2265) (diff)
downloadatuin-61c6e5e46a9caa45956239082ed8b6b524686453.zip
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
Diffstat (limited to 'crates/atuin-history/src')
-rw-r--r--crates/atuin-history/src/stats.rs14
1 files changed, 7 insertions, 7 deletions
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!("▮");