Re: [PATCH] upcoming new feature: smooth whole-window sideways scrolling
Benno Schulenberg <[email protected]> Sat, 10 Jan 2026 16:07:47 +0100
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
Op 09-01-2026 om 11:42 schreef Benno Schulenberg: > Instead of horizontally scrolling just the current line by nearly > a screen width when the cursor is about to go offscreen, now all > screen lines are scrolled horizontally together by just the amount > needed to keep the cursor comfortably in view. With above patch applied, run `src/nano +89 doc/faq.html` and press <End>. Then hold down <Ctrl+Left> for a second until the cursor is at "Pine", somewhere left-of-center on your terminal. See that two lines above are the words "free software" and two lines further the word "familiar". Now tap <Up> twice to go to the line with "free software". Huh? Where is the cursor?! ... It sits near the right edge of the terminal after "free" and before "so>". This may be logical and inherent to the patch, but it is rather unexpected and undesirable. As a small consolation, tilde, micro, and lpe behave the same way. Only joe does not suffer from this disorienting behavior, because it somehow allows the cursor to move through places where there are no characters at all. It would be great if nano could behave the same way as joe, but... how to achieve that is too hard a problem for me. What I do have is a rough patch that returns 'brink' to what it was (when possible) as long as any movement hasn't changed the 'placewewant' -- the desired column. Attached. Opinions? Benno
stabilize-cursor-column.patch
(text/x-patch, 1.8 KB)
diff --git a/src/definitions.h b/src/definitions.h
index 91861870..ab047663 100644
--- a/src/definitions.h
+++ b/src/definitions.h
@@ -565,7 +565,11 @@ typedef struct openfilestruct {
size_t current_x;
/* The file's x-coordinate position. */
size_t placewewant;
- /* The file's x position we would like. */
+ /* The column where we would like to place the cursor. */
+ size_t former_pww;
+ /* The former place we wanted (for the cursor). */
+ size_t brinkwewant;
+ /* From which column to display the file, preferably. */
ssize_t cursor_row;
/* The row in the edit window that the cursor is on. */
struct stat *statinfo;
diff --git a/src/files.c b/src/files.c
index d8b5f425..e60affe2 100644
--- a/src/files.c
+++ b/src/files.c
@@ -73,6 +73,8 @@ void make_new_buffer(void)
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
+ openfile->former_pww = 0;
+ openfile->brinkwewant = 0;
openfile->cursor_row = 0;
openfile->edittop = openfile->filetop;
diff --git a/src/winio.c b/src/winio.c
index ab305527..9cdd595e 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -3392,8 +3392,15 @@ void edit_refresh(void)
adjust_viewport((focusing || ISSET(JUMPY_SCROLLING)) ? CENTERING : FLOWING);
/* When panning, ensure the cursor will be within the viewport. */
- if (ISSET(JOINT_PANNING) && !ISSET(SOFTWRAP))
+ if (ISSET(JOINT_PANNING) && !ISSET(SOFTWRAP)) {
+ brink = openfile->brinkwewant;
+ if (openfile->placewewant != openfile->former_pww) {
+ openfile->former_pww = openfile->placewewant;
+ brink = get_page_start(openfile->placewewant);
+ openfile->brinkwewant = brink;
+ }
brink = get_page_start(xplustabs());
+ }
#ifdef ENABLE_COLOR
/* When needed and useful, initialize the colors for the current syntax. */
OpenPGP_signature.asc
(application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEEFo5vQpe/16ea/USWUUu+Lrjhlh8FAmlia0MFAwAAAAAACgkQUUu+Lrjhlh+H 3BAAtBbgs6T6YslFVd/mQ60ihS5X3KXDsmaX9vs41zTotM3j1T9viOkPFyWJhobOkyW9+ccwF0/p z+q4WbPyXpIi7kSWeMPVpdz0SoHdlt31LWqeaNpSFQJKMhXI9lNVJSlmnlEMVt71Ff5DSWH8k7FM cI+1GH+5c26OYQPoK7E5d0Ckl9ay4o0SeVCRy/zT3Z4XjgTw87L9AcTnBCsRED/Fw84OToS5JXkJ iP42An3dmtjER98AJR5HZaACp0QpZll3A7Zs1V/aj+oP3q7qD2FDc2lXDvpX+oVTi71ZKY5zVACQ T7MVcOqQ7axYgSYQHvDnj8ZD/xA0wpNGHDIW7zxm0E0BHpR+V5/R8heWuMl3FXskQuNSuceWGr8/ Qiv0yYXn9ZsNP3zA5UrUCCUorscSks2IUWohRbPN8thHz0cWgvhshVjTvRnvqJfiCldUJ75s6zOb hifjz6nuSCB8WOPYk+x9QBVBKQrF2bQBQYSruueZg3VjSiZdaCseiqQZ5iwtB2hCsNdY1ooqGEkJ yNvQgTGg2NOdFnzJE95X7DwrDHJiR1W7I7ZYugk3v+Oc/h9/4kckP1dSGbNJHG9X6fZRXluhPTuf Q9m9ZnAFQxSnRDPz9rQVY7R2wN9KA/4jUa7ZcsS1Y5lmRnTsEJA0A2s3nhWQPdizOlBu86x5eYXc HsM= =ENNV -----END PGP SIGNATURE-----