nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 265bdd94f16338982886b919bb8c1d76dda1cdf9
parent d1c412d20009341cb1fedf42828ae72adc8a195a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 22 Dec 2020 12:20:42 +0100

mouse: do not offset the shortcuts by 'margin' when using --linenumbers

The bottom window (the prompt bar and the shortcuts) does not shift
its position when line numbers are active, so mouse clicks in this
window should be not be compensated for the line-numbers margin.

This fixes https://savannah.gnu.org/bugs/?59749.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Bug existed since version 2.7.0, since line numbers were introduced.

Diffstat:
Msrc/winio.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -1488,14 +1488,16 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count) int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) { MEVENT mevent; - bool in_bottomwin; + bool in_editwin, in_bottomwin; /* First, get the actual mouse event. */ if (getmouse(&mevent) == ERR) return -1; + in_editwin = wenclose(edit, mevent.y, mevent.x); + /* Save the screen coordinates where the mouse event took place. */ - *mouse_x = mevent.x - margin; + *mouse_x = mevent.x - (in_editwin ? margin : 0); *mouse_y = mevent.y; in_bottomwin = wenclose(bottomwin, *mouse_y, *mouse_x); @@ -1521,7 +1523,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) /* Clicks on the status bar are handled elsewhere, so * restore the untranslated mouse-event coordinates. */ if (*mouse_y == 0) { - *mouse_x = mevent.x - margin; + *mouse_x = mevent.x; *mouse_y = mevent.y; return 0; }