summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Koppe <andy.koppe@gmail.com>2023-09-12 03:47:54 +0100
committerBenno Schulenberg <bensberg@telfort.nl>2024-02-23 16:06:33 +0100
commit4673e709b2b04e32db3a9c6cc561db04b0a517b1 (patch)
treebf909c617380103d14a0c50a5fc435485d41a348
parentf1a04f780afd39d7e891f90c26dfbddb0278c71e (diff)
downloadnano-4673e709.tar.gz
input: scroll on mousewheel events instead of moving the cursor
Translate mousewheel events into Alt+Up/Down key presses instead of into plain Up/Down key presses, as the latter only start scrolling once the cursor reaches the top or bottom. Scrolling rather than moving the cursor is the standard behavior for mousewheel events in GUI editors such as Gedit and Kate, as well as in the mouse mode of terminal editors such as vim, joe, and mcedit. Signed-off-by: Andy Koppe <andy.koppe@gmail.com>
-rw-r--r--src/winio.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/winio.c b/src/winio.c
index 112658a..7091f09 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1584,9 +1584,9 @@ char *get_verbatim_kbinput(WINDOW *frame, size_t *count)
* TRUE, releasing/clicking on a visible shortcut will put back the
* keystroke associated with that shortcut. If ncurses supports them,
* we also handle presses of the fourth mouse button (upward rolls of
- * the mouse wheel) by putting back keystrokes to move up, and presses
+ * the mouse wheel) by putting back keystrokes to scroll up, and presses
* of the fifth mouse button (downward rolls of the mouse wheel) by
- * putting back keystrokes to move down. We also store the coordinates
+ * putting back keystrokes to scroll down. We also store the coordinates
* of a mouse event that needs further handling in mouse_x and mouse_y.
* Return -1 on error, 0 if the mouse event needs to be handled, 1 if it's
* been handled by putting back keystrokes, or 2 if it's been ignored. */
@@ -1684,9 +1684,9 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
wmouse_trafo(footwin, mouse_y, mouse_x, FALSE);
if (in_middle || (in_footer && *mouse_y == 0)) {
- int keycode = (event.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN;
+ int keycode = (event.bstate & BUTTON4_PRESSED) ? ALT_UP : ALT_DOWN;
- /* One roll of the mouse wheel should move three lines. */
+ /* One roll of the mouse wheel should scroll three lines. */
for (int count = 3; count > 0; count--)
put_back(keycode);