refactor: Modify theme in place

This commit is contained in:
Liam 2024-08-17 11:32:53 -07:00
parent 7f15324117
commit f70195905f
No known key found for this signature in database
2 changed files with 10 additions and 10 deletions

View File

@ -196,8 +196,8 @@ impl AppState {
self.refresh_tab();
}
KeyCode::Char('/') => self.enter_search(),
KeyCode::Char('t') => self.theme = self.theme.next(),
KeyCode::Char('T') => self.theme = self.theme.prev(),
KeyCode::Char('t') => self.theme.next(),
KeyCode::Char('T') => self.theme.prev(),
_ => {}
},
Focus::List if key.kind != KeyEventKind::Release => match key.code {
@ -214,8 +214,8 @@ impl AppState {
}
KeyCode::Char('/') => self.enter_search(),
KeyCode::Tab => self.focus = Focus::TabList,
KeyCode::Char('t') => self.theme = self.theme.next(),
KeyCode::Char('T') => self.theme = self.theme.prev(),
KeyCode::Char('t') => self.theme.next(),
KeyCode::Char('T') => self.theme.prev(),
_ => {}
},
_ => {}

View File

@ -87,16 +87,16 @@ impl Theme {
impl Theme {
#[allow(unused)]
pub fn next(self) -> Self {
let position = self as usize;
pub fn next(&mut self) {
let position = *self as usize;
let types = Theme::value_variants();
types[(position + 1) % types.len()].into()
*self = types[(position + 1) % types.len()];
}
#[allow(unused)]
pub fn prev(self) -> Self {
let position = self as usize;
pub fn prev(&mut self) {
let position = *self as usize;
let types = Theme::value_variants();
types[(position + types.len() - 1) % types.len()].into()
*self = types[(position + types.len() - 1) % types.len()];
}
}