[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH v2] scrolling: let Scroll-Up/Down keep the cursor in
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH v2] scrolling: let Scroll-Up/Down keep the cursor in the same text position |
Date: |
Sat, 10 Mar 2018 17:16:05 +0100 |
This makes these functions behave the same as in Vim and Emacs.
---
src/move.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/move.c b/src/move.c
index f559fb41..63af1a2b 100644
--- a/src/move.c
+++ b/src/move.c
@@ -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. */
--
2.16.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nano-devel] [PATCH v2] scrolling: let Scroll-Up/Down keep the cursor in the same text position,
Benno Schulenberg <=