Skip to content

Commit cb94b42

Browse files
committed
wip(theme): removed unhandled references to foreground_color
1 parent 61aa872 commit cb94b42

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

crates/atuin-client/src/theme.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ impl Theme {
108108
// General access - if you have a meaning, this will give you a (crossterm) style
109109
pub fn as_style(&self, meaning: Meaning) -> ContentStyle {
110110
self.styles[self.closest_meaning(&meaning)]
111-
// ContentStyle {
112-
// foreground_color: self.styles[self.closest_meaning(&meaning)],
113-
// ..ContentStyle::default()
114-
// }
115111
}
116112

117113
// Turns a map of meanings to colornames into a theme

crates/atuin-history/src/stats.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::{HashMap, HashSet};
22

3-
use crossterm::style::{ResetColor, SetAttribute, SetForegroundColor};
3+
use crossterm::style::{ResetColor, SetAttribute, SetForegroundColor, Color};
44
use serde::{Deserialize, Serialize};
55
use unicode_segmentation::UnicodeSegmentation;
66

@@ -126,21 +126,33 @@ pub fn pretty_print(stats: Stats, ngram_size: usize, theme: &Theme) {
126126
});
127127

128128
for (command, count) in stats.top {
129-
let gray = SetForegroundColor(theme.as_style(Meaning::Muted).foreground_color.unwrap());
129+
let gray = SetForegroundColor(match theme.as_style(Meaning::Muted).foreground_color {
130+
Some(color) => color,
131+
None => Color::Grey
132+
});
130133
let bold = SetAttribute(crossterm::style::Attribute::Bold);
131134

132135
let in_ten = 10 * count / max;
133136

134137
print!("[");
135-
print!("{}", SetForegroundColor(theme.get_error().foreground_color.unwrap()));
138+
print!("{}", SetForegroundColor(match theme.get_error().foreground_color {
139+
Some(color) => color,
140+
None => Color::Red
141+
}));
136142

137143
for i in 0..in_ten {
138144
if i == 2 {
139-
print!("{}", SetForegroundColor(theme.get_warning().foreground_color.unwrap()));
145+
print!("{}", SetForegroundColor(match theme.get_warning().foreground_color {
146+
Some(color) => color,
147+
None => Color::Yellow
148+
}));
140149
}
141150

142151
if i == 5 {
143-
print!("{}", SetForegroundColor(theme.get_info().foreground_color.unwrap()));
152+
print!("{}", SetForegroundColor(match theme.get_info().foreground_color {
153+
Some(color) => color,
154+
None => Color::Green
155+
}));
144156
}
145157

146158
print!("▮");

crates/atuin/src/command/client/search/interactive.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,10 @@ impl State {
766766

767767
fn build_title(&mut self, theme: &Theme) -> Paragraph {
768768
let title = if self.update_needed.is_some() {
769+
let error_style: Style = theme.get_error().into();
769770
Paragraph::new(Text::from(Span::styled(
770771
format!("Atuin v{VERSION} - UPGRADE"),
771-
Style::default()
772-
.add_modifier(Modifier::BOLD)
773-
.fg(theme.get_error().foreground_color.unwrap().into()),
772+
error_style.add_modifier(Modifier::BOLD),
774773
)))
775774
} else {
776775
let style: Style = theme.as_style(Meaning::Base).into();

0 commit comments

Comments
 (0)