Commit 1dd01eb4 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey Committed by Benno Schulenberg
Browse files

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.
No related merge requests found
Showing with 3 additions and 5 deletions
+3 -5
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment