nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] scrolling: keep the cursor in the same text positio


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] scrolling: keep the cursor in the same text position for Scroll-Up/Down
Date: Sat, 10 Mar 2018 12:48:40 +0100

[Apply to current git.]

[This makes the Scroll-Up (M--) and Scroll-Down (M-=) commands behave
the way I would like them to.]

---
 src/move.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/move.c b/src/move.c
index f559fb41..3c87ecdd 100644
--- a/src/move.c
+++ b/src/move.c
@@ -501,8 +501,11 @@ void do_up(bool scroll_only)
 
        set_proper_index_and_pww(&leftedge, target_column, FALSE);
 
-       if (scroll_only)
+       if (scroll_only) {
+               if (openfile->current_y < editwinrows - 1)
+                       go_forward_chunks(1, &openfile->current, &leftedge);
                edit_scroll(BACKWARD);
+       }
 
        edit_redraw(was_current, FLOWING);
 
@@ -520,13 +523,16 @@ void do_down(bool scroll_only)
        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 (go_forward_chunks(1, &openfile->current, &leftedge) > 0 && 
!scroll_only)
                return;
 
        set_proper_index_and_pww(&leftedge, target_column, TRUE);
 
-       if (scroll_only)
+       if (scroll_only) {
+               if (openfile->current_y > 0)
+                       go_back_chunks(1, &openfile->current, &leftedge);
                edit_scroll(FORWARD);
+       }
 
        edit_redraw(was_current, FLOWING);
 
-- 
2.16.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]