mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2025-04-18 17:53:45 +01:00
refactor: Modify theme in place
This commit is contained in:
parent
7f15324117
commit
f70195905f
@ -196,8 +196,8 @@ impl AppState {
|
|||||||
self.refresh_tab();
|
self.refresh_tab();
|
||||||
}
|
}
|
||||||
KeyCode::Char('/') => self.enter_search(),
|
KeyCode::Char('/') => self.enter_search(),
|
||||||
KeyCode::Char('t') => self.theme = self.theme.next(),
|
KeyCode::Char('t') => self.theme.next(),
|
||||||
KeyCode::Char('T') => self.theme = self.theme.prev(),
|
KeyCode::Char('T') => self.theme.prev(),
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Focus::List if key.kind != KeyEventKind::Release => match key.code {
|
Focus::List if key.kind != KeyEventKind::Release => match key.code {
|
||||||
@ -214,8 +214,8 @@ impl AppState {
|
|||||||
}
|
}
|
||||||
KeyCode::Char('/') => self.enter_search(),
|
KeyCode::Char('/') => self.enter_search(),
|
||||||
KeyCode::Tab => self.focus = Focus::TabList,
|
KeyCode::Tab => self.focus = Focus::TabList,
|
||||||
KeyCode::Char('t') => self.theme = self.theme.next(),
|
KeyCode::Char('t') => self.theme.next(),
|
||||||
KeyCode::Char('T') => self.theme = self.theme.prev(),
|
KeyCode::Char('T') => self.theme.prev(),
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
12
src/theme.rs
12
src/theme.rs
@ -87,16 +87,16 @@ impl Theme {
|
|||||||
|
|
||||||
impl Theme {
|
impl Theme {
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn next(self) -> Self {
|
pub fn next(&mut self) {
|
||||||
let position = self as usize;
|
let position = *self as usize;
|
||||||
let types = Theme::value_variants();
|
let types = Theme::value_variants();
|
||||||
types[(position + 1) % types.len()].into()
|
*self = types[(position + 1) % types.len()];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn prev(self) -> Self {
|
pub fn prev(&mut self) {
|
||||||
let position = self as usize;
|
let position = *self as usize;
|
||||||
let types = Theme::value_variants();
|
let types = Theme::value_variants();
|
||||||
types[(position + types.len() - 1) % types.len()].into()
|
*self = types[(position + types.len() - 1) % types.len()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user