Add up/down arrows as navigation options in the help menu
use crate::{app::App, event::Key};
+use super::common_key_events;
+
+#[derive(PartialEq)]
+enum Direction {
+ UP,
+ DOWN,
+}
pub fn handler(key: Key, app: &mut App) {
match key {
+ k if common_key_events::down_event(k) => {
+ move_page(Direction::DOWN, app);
+ }
+ k if common_key_events::up_event(k) => {
+ move_page(Direction::UP, app);
+ }
Key::Ctrl('d') => {
- app.help_menu_page += 1;
- app.calculate_help_menu_offset();
+ move_page(Direction::DOWN, app);
}
Key::Ctrl('u') => {
+ move_page(Direction::UP, app);
+ }
+ _ => {}
+ };
+}
+
+fn move_page(direction: Direction, app: &mut App) {
+ if direction == Direction::UP {
if app.help_menu_page > 0 {
app.help_menu_page -= 1;
- app.calculate_help_menu_offset();
}
+ } else if direction == Direction::DOWN {
+ app.help_menu_page += 1;
}
- _ => {}
- };
+ app.calculate_help_menu_offset();
}
\ No newline at end of file
