Skip to content

Commit

Permalink
Merge pull request #3 from Andsbf/task-add-bash-default-navigation-ke…
Browse files Browse the repository at this point in the history
…ybindings

Task: Add bash keybindings for navigation as well
  • Loading branch information
jesseduffield authored Mar 1, 2021
2 parents 6337c79 + f441a45 commit c50e4a5
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 c50e4a5

Please sign in to comment.