From e9fde7d7dc9ff975d4745ce519584a456970c982 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 10 Dec 2016 19:38:03 +0100 Subject: [PATCH] mouse: use the correct screen width for calculating the cursor position When there are line numbers, the effective available screen width is smaller than COLS: editwincols. This fixes https://savannah.gnu.org/bugs/?49821. --- src/nano.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nano.c b/src/nano.c index a246675c..6bda5964 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1767,7 +1767,7 @@ int do_mouse(void) openfile->current->next && i < mouse_y; openfile->current = openfile->current->next, i++) { openfile->current_y = i; - i += strlenpt(openfile->current->data) / COLS; + i += strlenpt(openfile->current->data) / editwincols; } #ifdef DEBUG fprintf(stderr, "do_mouse(): moving to current_y = %ld, index i = %lu\n", @@ -1777,7 +1777,8 @@ int do_mouse(void) if (i > mouse_y) { openfile->current = openfile->current->prev; - openfile->current_x = actual_x(openfile->current->data, mouse_x + (mouse_y - openfile->current_y) * COLS); + openfile->current_x = actual_x(openfile->current->data, + mouse_x + (mouse_y - openfile->current_y) * editwincols); #ifdef DEBUG fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %lu\n", mouse_x, (unsigned long)openfile->current_x);