Skip to content

Commit

Permalink
Task: Add bash keybindings for navigation as well
Browse files Browse the repository at this point in the history
this commit adds the bash default nagivation keybings as another navigation option.
  • Loading branch information
Anderson Saunders committed Mar 1, 2021
1 parent 6337c79 commit f441a45
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ fn handle_event(
lines_to_skip: usize,
loading_tx: &Sender<bool>,
) -> Result<bool, Box<dyn Error>> {
fn navigate_down(app: &mut App) {
app.table.next();
app.on_select();
}
fn navigate_up(app: &mut App) {
app.table.previous();
app.on_select();
}
match event {
Event::Input(event) => {
if event.code == KeyCode::Char('c') && event.modifiers == KeyModifiers::CONTROL {
Expand All @@ -186,12 +194,16 @@ fn handle_event(
app.reset_filter_text();
}
KeyCode::Down | KeyCode::Char('j') => {
app.table.next();
app.on_select();
navigate_down(app)
}
KeyCode::Char('n') if event.modifiers == KeyModifiers::CONTROL => {
navigate_down(app)
}
KeyCode::Up | KeyCode::Char('k') => {
app.table.previous();
app.on_select();
navigate_up(app)
}
KeyCode::Char('p') if event.modifiers == KeyModifiers::CONTROL => {
navigate_up(app)
}
KeyCode::Char('/') => {
app.focused_panel = FocusedPanel::Search;
Expand Down

0 comments on commit f441a45

Please sign in to comment.