Add index tracking to App
This commit is contained in:
parent
353f2d5570
commit
86b1f34330
1 changed files with 23 additions and 0 deletions
|
|
@ -61,7 +61,9 @@ pub struct App {
|
||||||
tick_rate: f64,
|
tick_rate: f64,
|
||||||
// App
|
// App
|
||||||
clone: CloneSettings,
|
clone: CloneSettings,
|
||||||
|
cur_index: usize,
|
||||||
cur_mode: Mode,
|
cur_mode: Mode,
|
||||||
|
list_size: usize,
|
||||||
prev_mode: Mode,
|
prev_mode: Mode,
|
||||||
selections: Vec<Option<usize>>,
|
selections: Vec<Option<usize>>,
|
||||||
tasks: Tasks,
|
tasks: Tasks,
|
||||||
|
|
@ -93,7 +95,9 @@ impl App {
|
||||||
tick_rate,
|
tick_rate,
|
||||||
// App
|
// App
|
||||||
clone: CloneSettings::new(disk_list_arc),
|
clone: CloneSettings::new(disk_list_arc),
|
||||||
|
cur_index: 0,
|
||||||
cur_mode: Mode::ScanDisks,
|
cur_mode: Mode::ScanDisks,
|
||||||
|
list_size: 0,
|
||||||
prev_mode: Mode::ScanDisks,
|
prev_mode: Mode::ScanDisks,
|
||||||
selections: vec![None, None],
|
selections: vec![None, None],
|
||||||
tasks,
|
tasks,
|
||||||
|
|
@ -346,6 +350,25 @@ impl App {
|
||||||
Action::Suspend => self.should_suspend = true,
|
Action::Suspend => self.should_suspend = true,
|
||||||
Action::Resume => self.should_suspend = false,
|
Action::Resume => self.should_suspend = false,
|
||||||
Action::ClearScreen => tui.terminal.clear()?,
|
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) => {
|
Action::Error(ref msg) => {
|
||||||
self.action_tx
|
self.action_tx
|
||||||
.send(Action::DisplayPopup(popup::Type::Error, msg.clone()))?;
|
.send(Action::DisplayPopup(popup::Type::Error, msg.clone()))?;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue