Added Vi support for scrolling in the textview command.

This commit is contained in:
Jonathan Rothberg 2019-10-02 18:45:23 -07:00
parent 97695b74dd
commit 7d2747ea9a

View File

@ -150,7 +150,7 @@ fn scroll_view_lines_if_needed(draw_commands: Vec<DrawCommand>, use_color_buffer
KeyEvent::Esc => { KeyEvent::Esc => {
break; break;
} }
KeyEvent::Up => { KeyEvent::Up | KeyEvent::Char('k') => {
if starting_row > 0 { if starting_row > 0 {
starting_row -= 1; starting_row -= 1;
max_bottom_line = paint_textview( max_bottom_line = paint_textview(
@ -160,19 +160,19 @@ fn scroll_view_lines_if_needed(draw_commands: Vec<DrawCommand>, use_color_buffer
); );
} }
} }
KeyEvent::Down => { KeyEvent::Down | KeyEvent::Char('j') => {
if starting_row < (max_bottom_line - height) { if starting_row < (max_bottom_line - height) {
starting_row += 1; starting_row += 1;
} }
max_bottom_line = max_bottom_line =
paint_textview(&draw_commands, starting_row, use_color_buffer); paint_textview(&draw_commands, starting_row, use_color_buffer);
} }
KeyEvent::PageUp => { KeyEvent::PageUp | KeyEvent::Ctrl('b') => {
starting_row -= std::cmp::min(height, starting_row); starting_row -= std::cmp::min(height, starting_row);
max_bottom_line = max_bottom_line =
paint_textview(&draw_commands, starting_row, use_color_buffer); paint_textview(&draw_commands, starting_row, use_color_buffer);
} }
KeyEvent::PageDown | KeyEvent::Char(' ') => { KeyEvent::PageDown | KeyEvent::Ctrl('f') | KeyEvent::Char(' ') => {
if starting_row < (max_bottom_line - height) { if starting_row < (max_bottom_line - height) {
starting_row += height; starting_row += height;