Skip to content

Commit 9466db7

Browse files
committed
add some vim keybinds for navigation
1 parent 91c1f09 commit 9466db7

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/main.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,25 +502,37 @@ fn print_paged(graph_lines: &[String], text_lines: &[String]) -> Result<(), Erro
502502
let input = crossterm::event::read()?;
503503
if let Event::Key(evt) = input {
504504
match evt.code {
505-
KeyCode::Down => {
505+
KeyCode::Down | KeyCode::Char('j') => {
506506
start_idx += 1;
507507
should_update = true;
508508
}
509-
KeyCode::Up => {
509+
KeyCode::Up | KeyCode::Char('k') => {
510510
if start_idx > 0 {
511511
start_idx -= 1;
512512
should_update = true;
513513
}
514514
}
515-
KeyCode::Enter | KeyCode::PageDown => {
515+
KeyCode::Enter | KeyCode::PageDown | KeyCode::Char('f') => {
516516
start_idx += height as usize - 2;
517517
should_update = true;
518518
}
519-
KeyCode::End => {
519+
KeyCode::End | KeyCode::Char('G') => {
520520
start_idx = graph_lines.len() - height as usize - 2;
521521
should_update = true;
522522
// TODO: maybe make this better
523523
}
524+
KeyCode::PageUp | KeyCode::Char('b') => {
525+
if start_idx >= height as usize - 2 {
526+
start_idx -= height as usize - 2;
527+
} else {
528+
start_idx = 0;
529+
}
530+
should_update = true;
531+
}
532+
KeyCode::Home | KeyCode::Char('g') => {
533+
start_idx = 0;
534+
should_update = true;
535+
}
524536
KeyCode::Char(c) => match c {
525537
'q' => {
526538
break;

0 commit comments

Comments
 (0)