tweaks: avoid an unnecessary fiddling with current_y in do_mouse()
Since do_mouse() uses edit_redraw(), openfile->current_y will be immediately recalculated, so there's no point in changing it now. Use a temporary variable instead.master
parent
1dd01eb4e1
commit
d7fbc70a72
16
src/nano.c
16
src/nano.c
|
@ -1752,12 +1752,12 @@ int do_mouse(void)
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(SOFTWRAP)) {
|
if (ISSET(SOFTWRAP)) {
|
||||||
ssize_t i = 0;
|
ssize_t i = 0, current_row = 0;
|
||||||
|
|
||||||
openfile->current = openfile->edittop;
|
openfile->current = openfile->edittop;
|
||||||
|
|
||||||
while (openfile->current->next != NULL && i < mouse_y) {
|
while (openfile->current->next != NULL && i < mouse_y) {
|
||||||
openfile->current_y = i;
|
current_row = i;
|
||||||
i += strlenpt(openfile->current->data) / editwincols + 1;
|
i += strlenpt(openfile->current->data) / editwincols + 1;
|
||||||
openfile->current = openfile->current->next;
|
openfile->current = openfile->current->next;
|
||||||
}
|
}
|
||||||
|
@ -1765,18 +1765,20 @@ 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_y - openfile->current_y) * editwincols) + mouse_x);
|
((mouse_y - current_row) * 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
|
||||||
#endif /* NANO_TINY */
|
#endif /* NANO_TINY */
|
||||||
{
|
{
|
||||||
|
ssize_t current_row = openfile->current_y;
|
||||||
|
|
||||||
/* Move to where the click occurred. */
|
/* Move to where the click occurred. */
|
||||||
for (; openfile->current_y < mouse_y && openfile->current !=
|
for (; current_row < mouse_y && openfile->current !=
|
||||||
openfile->filebot; openfile->current_y++)
|
openfile->filebot; current_row++)
|
||||||
openfile->current = openfile->current->next;
|
openfile->current = openfile->current->next;
|
||||||
for (; openfile->current_y > mouse_y && openfile->current !=
|
for (; current_row > mouse_y && openfile->current !=
|
||||||
openfile->fileage; openfile->current_y--)
|
openfile->fileage; current_row--)
|
||||||
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,
|
||||||
|
|
Loading…
Reference in New Issue