Skip to content

Commit b49c02b

Browse files
committed
Vim Scrolling Keybinds
1 parent b6dd72e commit b49c02b

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/app.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,6 @@ impl App {
573573
let ctrl_pressed = key.modifiers.contains(KeyModifiers::CONTROL);
574574
let shift_pressed = key.modifiers.contains(KeyModifiers::SHIFT);
575575

576-
// TODO vim-style hjkl menu scroll behaviors
577-
578576
// let at_port_selection = matches!(self.menu, Menu::PortSelection);
579577
// TODO soon, redo this variable's name + use
580578
let mut at_port_selection = false;
@@ -625,6 +623,12 @@ impl App {
625623
// might replace with PartialEq, Eq on Menu later, not sure
626624
Menu::PortSelection(_) => at_port_selection = true,
627625
}
626+
let vim_scrollable_menu: bool = match (self.menu, &self.popup, &self.macros.ui_state) {
627+
(_, Some(PopupMenu::Macros), MacrosPrompt::Keybind) => false,
628+
(_, Some(PopupMenu::Macros), MacrosPrompt::AddEdit(_)) => false,
629+
(Menu::Terminal(TerminalPrompt::None), None, _) => false,
630+
_ => true,
631+
};
628632
// TODO split this up into more functions based on menu
629633
match key_combo {
630634
// Start of hardcoded keybinds.
@@ -736,6 +740,10 @@ impl App {
736740
// KeyCode::End => self
737741
// .event_carousel
738742
// .add_event(Event::TickSecond, Duration::from_secs(3)),
743+
key!(h) if vim_scrollable_menu => self.left_pressed(),
744+
key!(j) if vim_scrollable_menu => self.down_pressed(),
745+
key!(k) if vim_scrollable_menu => self.up_pressed(),
746+
key!(l) if vim_scrollable_menu => self.right_pressed(),
739747
key!(up) => self.up_pressed(),
740748
key!(down) => self.down_pressed(),
741749
key!(left) => self.left_pressed(),

0 commit comments

Comments
 (0)