Commit 0e30177d authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

scrolling: let Scroll-Up/Down keep the cursor in the same text position

Instead of keeping the cursor in the same spot on the screen,
let the cursor move with the text (whenever possible).

This makes these functions behave the same as in Vim and Emacs.
parent 3089a981
Showing with 11 additions and 8 deletions
+11 -8
......@@ -493,17 +493,18 @@ void do_up(bool scroll_only)
openfile->firstcolumn == 0)
return;
if (scroll_only)
edit_scroll(BACKWARD);
get_edge_and_target(&leftedge, &target_column);
/* If we can't move up one line or chunk, we're at top of file. */
if (go_back_chunks(1, &openfile->current, &leftedge) > 0)
if ((!scroll_only || openfile->current_y == editwinrows - 1) &&
go_back_chunks(1, &openfile->current, &leftedge) > 0)
return;
set_proper_index_and_pww(&leftedge, target_column, FALSE);
if (scroll_only)
edit_scroll(BACKWARD);
edit_redraw(was_current, FLOWING);
/* <Up> should not change placewewant, so restore it. */
......@@ -517,17 +518,19 @@ void do_down(bool scroll_only)
filestruct *was_current = openfile->current;
size_t leftedge, target_column;
if (scroll_only && (openfile->current_y > 0 ||
openfile->current != openfile->filebot))
edit_scroll(FORWARD);
get_edge_and_target(&leftedge, &target_column);
/* If we can't move down one line or chunk, we're at bottom of file. */
if (go_forward_chunks(1, &openfile->current, &leftedge) > 0)
if ((!scroll_only || openfile->current_y == 0) &&
go_forward_chunks(1, &openfile->current, &leftedge) > 0)
return;
set_proper_index_and_pww(&leftedge, target_column, TRUE);
if (scroll_only)
edit_scroll(FORWARD);
edit_redraw(was_current, FLOWING);
/* <Down> should not change placewewant, so restore it. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment