diff --git a/deja_vu/src/app.rs b/deja_vu/src/app.rs index 61f017f..408cac4 100644 --- a/deja_vu/src/app.rs +++ b/deja_vu/src/app.rs @@ -61,7 +61,9 @@ pub struct App { tick_rate: f64, // App clone: CloneSettings, + cur_index: usize, cur_mode: Mode, + list_size: usize, prev_mode: Mode, selections: Vec>, tasks: Tasks, @@ -93,7 +95,9 @@ impl App { tick_rate, // App clone: CloneSettings::new(disk_list_arc), + cur_index: 0, cur_mode: Mode::ScanDisks, + list_size: 0, prev_mode: Mode::ScanDisks, selections: vec![None, None], tasks, @@ -346,6 +350,25 @@ impl App { Action::Suspend => self.should_suspend = true, Action::Resume => self.should_suspend = false, Action::ClearScreen => tui.terminal.clear()?, + Action::KeyUp => { + self.cur_index = match self.cur_index { + 0 => { + if self.list_size > 0 { + self.list_size - 1 + } else { + 0 + } + } + _ => self.cur_index - 1, + }; + } + Action::KeyDown => { + self.cur_index = if self.cur_index == self.list_size - 1 { + 0 + } else { + self.cur_index + 1 + }; + } Action::Error(ref msg) => { self.action_tx .send(Action::DisplayPopup(popup::Type::Error, msg.clone()))?;