feat!: cache last tree structure to simplify events

Things like key up/down dont require the items anymore to be used.
Instead a cached last state from last render is used.
This commit is contained in:
EdJoPaTo
2024-05-01 01:45:54 +02:00
parent 701be9315d
commit fdd2c5436a
5 changed files with 88 additions and 88 deletions
+4 -4
View File
@@ -142,11 +142,11 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, mut app: App) -> std::io::Res
KeyCode::Char('\n' | ' ') => app.state.toggle_selected(),
KeyCode::Left => app.state.key_left(),
KeyCode::Right => app.state.key_right(),
KeyCode::Down => app.state.key_down(&app.items),
KeyCode::Up => app.state.key_up(&app.items),
KeyCode::Down => app.state.key_down(),
KeyCode::Up => app.state.key_up(),
KeyCode::Esc => app.state.select(Vec::new()),
KeyCode::Home => app.state.select_first(&app.items),
KeyCode::End => app.state.select_last(&app.items),
KeyCode::Home => app.state.select_first(),
KeyCode::End => app.state.select_last(),
KeyCode::PageDown => app.state.scroll_down(3),
KeyCode::PageUp => app.state.scroll_up(3),
_ => false,