Add OpsLog::select_next

This commit is contained in:
Hanno Braun 2024-11-25 22:52:51 +01:00
parent de37322aa7
commit 29527442dc
2 changed files with 7 additions and 3 deletions

View File

@ -95,9 +95,7 @@ impl ApplicationHandler for App {
match logical_key {
Key::Named(NamedKey::ArrowDown) => {
if self.ops.selected < self.ops.operations.len() {
self.ops.selected += 1;
}
self.ops.select_next();
}
Key::Named(NamedKey::ArrowUp) => {
self.ops.selected = self.ops.selected.saturating_sub(1);

View File

@ -54,6 +54,12 @@ impl OpsLog {
pub fn select_last(&mut self) {
self.selected = self.operations.len().saturating_sub(1);
}
pub fn select_next(&mut self) {
if self.selected < self.operations.len() {
self.selected += 1;
}
}
}
impl fmt::Display for OpsLog {