Merge pull request #775 from JonnyWalker81/vi-textview-scroll

Added Vi support for scrolling in the textview command.
This commit is contained in:
Jonathan Turner 2019-10-03 15:19:11 +13:00 committed by GitHub
commit 124a814f4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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