commit 1dd01eb4e1cd984f58fe4b8962595df529af8cfe
parent fd0589d8bca2154c9f2d33e68b6fe044d6a3dff7
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 2 Jan 2017 13:31:42 -0600
tweaks: move a setting, fix a type, and rearrange a line in do_mouse()
The value of sameline doesn't change, so it can be initialized to that.
Since i holds openfile->current_y, it should be ssize_t, not size_t.
And it's better to do the most significant part of a calculation first.
Diffstat:
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -1738,7 +1738,7 @@ int do_mouse(void)
/* We can click on the edit window to move the cursor. */
if (wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
- bool sameline;
+ bool sameline = (mouse_y == openfile->current_y);
/* Did they click on the line with the cursor? If they
* clicked on the cursor, we set the mark. */
filestruct *current_save = openfile->current;
@@ -1746,15 +1746,13 @@ int do_mouse(void)
size_t current_x_save = openfile->current_x;
#endif
- sameline = (mouse_y == openfile->current_y);
-
#ifdef DEBUG
fprintf(stderr, "mouse_y = %d, current_y = %ld\n", mouse_y, (long)openfile->current_y);
#endif
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
- size_t i = 0;
+ ssize_t i = 0;
openfile->current = openfile->edittop;
@@ -1767,7 +1765,7 @@ 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) * editwincols);
+ ((mouse_y - openfile->current_y) * editwincols) + mouse_x);
} else
openfile->current_x = actual_x(openfile->current->data, mouse_x);
} else