Counting only shortcuts that are actually shown, so that clicking

on the ones after ^T (Speller/Linter) will work again correctly.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4848 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-05-09 11:44:17 +00:00
parent a152311cb5
commit 59cd3e682b
2 changed files with 21 additions and 25 deletions

View File

@ -1,3 +1,8 @@
2014-05-09 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (get_mouseinput): Count only shortcuts that are actually
shown, so that clicking on the ones after ^T (Speller/Linter) will work
again correctly. This fixes the second part of Savannah bug #42093.
2014-05-06 Benno Schulenberg <bensberg@justemail.net> 2014-05-06 Benno Schulenberg <bensberg@justemail.net>
* doc/texinfo/nano.texi: Let makeinfo figure out the node pointers. * doc/texinfo/nano.texi: Let makeinfo figure out the node pointers.
* doc/syntax/texinfo.nanorc: New file, colouring for Texinfo files. * doc/syntax/texinfo.nanorc: New file, colouring for Texinfo files.

View File

@ -1636,8 +1636,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* The width of all the shortcuts, except for the last /* The width of all the shortcuts, except for the last
* two, in the shortcut list in bottomwin. */ * two, in the shortcut list in bottomwin. */
int j; int j;
/* The y-coordinate relative to the beginning of the /* The calculated index number of the clicked item. */
* shortcut list in bottomwin. */
size_t currslen; size_t currslen;
/* The number of shortcuts in the current shortcut /* The number of shortcuts in the current shortcut
* list. */ * list. */
@ -1657,10 +1656,6 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
return 0; return 0;
} }
/* Calculate the y-coordinate relative to the beginning of
* the shortcut list in bottomwin. */
j = *mouse_y - 1;
/* Get the shortcut lists' length. */ /* Get the shortcut lists' length. */
if (currmenu == MMAIN) if (currmenu == MMAIN)
currslen = MAIN_VISIBLE; currslen = MAIN_VISIBLE;
@ -1681,38 +1676,35 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
else else
i = COLS / ((currslen / 2) + (currslen % 2)); i = COLS / ((currslen / 2) + (currslen % 2));
/* Calculate the x-coordinate relative to the beginning of /* Calculate the one-based index in the shortcut list. */
* the shortcut list in bottomwin, and add it to j. j j = (*mouse_x / i) * 2 + *mouse_y;
* should now be the index in the shortcut list of the
* shortcut we released/clicked on. */
j = (*mouse_x / i) * 2 + j;
/* Adjust j if we released on the last two shortcuts. */ /* Adjust the index if we hit the last two wider ones. */
if ((j >= currslen) && (*mouse_x % i < COLS % i)) if ((j > currslen) && (*mouse_x % i < COLS % i))
j -= 2; j -= 2;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Calculated %i as index in shortcut list, currmenu = %x.\n", j, currmenu); fprintf(stderr, "Calculated %i as index in shortcut list, currmenu = %x.\n", j, currmenu);
#endif #endif
/* Ignore releases/clicks of the first mouse button beyond /* Ignore releases/clicks of the first mouse button beyond
* the last shortcut. */ * the last shortcut. */
if (j >= currslen) if (j > currslen)
return 2; return 2;
/* Go through the list of functions to determine which /* Go through the list of functions to determine which
* shortcut in the current menu we released/clicked on. */ * shortcut in the current menu we released/clicked on. */
f = allfuncs; for (f = allfuncs; f != NULL; f = f->next) {
if ((f->menus & currmenu) == 0)
while (TRUE) { continue;
while ((f->menus & currmenu) == 0
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
|| strlen(f->help) == 0 if (!f->help || strlen(f->help) == 0)
continue;
#endif #endif
) if (first_sc_for(currmenu, f->scfunc) == NULL)
f = f->next; continue;
/* Tick off an actually shown shortcut. */
j -= 1;
if (j == 0) if (j == 0)
break; break;
f = f->next;
j -= 1;
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Stopped on func %ld present in menus %x\n", (long)f->scfunc, f->menus); fprintf(stderr, "Stopped on func %ld present in menus %x\n", (long)f->scfunc, f->menus);
@ -1721,7 +1713,6 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* And put the corresponding key into the keyboard buffer. */ /* And put the corresponding key into the keyboard buffer. */
if (f != NULL) { if (f != NULL) {
const sc *s = first_sc_for(currmenu, f->scfunc); const sc *s = first_sc_for(currmenu, f->scfunc);
if (s != NULL)
unget_kbinput(s->seq, s->type == META, FALSE); unget_kbinput(s->seq, s->type == META, FALSE);
} }
} else } else