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.master
parent
fd0589d8bc
commit
1dd01eb4e1
|
@ -1738,7 +1738,7 @@ int do_mouse(void)
|
||||||
|
|
||||||
/* We can click on the edit window to move the cursor. */
|
/* We can click on the edit window to move the cursor. */
|
||||||
if (wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
|
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
|
/* Did they click on the line with the cursor? If they
|
||||||
* clicked on the cursor, we set the mark. */
|
* clicked on the cursor, we set the mark. */
|
||||||
filestruct *current_save = openfile->current;
|
filestruct *current_save = openfile->current;
|
||||||
|
@ -1746,15 +1746,13 @@ int do_mouse(void)
|
||||||
size_t current_x_save = openfile->current_x;
|
size_t current_x_save = openfile->current_x;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sameline = (mouse_y == openfile->current_y);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "mouse_y = %d, current_y = %ld\n", mouse_y, (long)openfile->current_y);
|
fprintf(stderr, "mouse_y = %d, current_y = %ld\n", mouse_y, (long)openfile->current_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(SOFTWRAP)) {
|
if (ISSET(SOFTWRAP)) {
|
||||||
size_t i = 0;
|
ssize_t i = 0;
|
||||||
|
|
||||||
openfile->current = openfile->edittop;
|
openfile->current = openfile->edittop;
|
||||||
|
|
||||||
|
@ -1767,7 +1765,7 @@ int do_mouse(void)
|
||||||
if (i > mouse_y) {
|
if (i > mouse_y) {
|
||||||
openfile->current = openfile->current->prev;
|
openfile->current = openfile->current->prev;
|
||||||
openfile->current_x = actual_x(openfile->current->data,
|
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
|
} else
|
||||||
openfile->current_x = actual_x(openfile->current->data, mouse_x);
|
openfile->current_x = actual_x(openfile->current->data, mouse_x);
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue