diff --git a/ChangeLog b/ChangeLog index 965e668f909e56d7890b371bd04197a73f02c3fe..9f58a68c1c9d69be30685b04e5bc365e1ff05085 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-04-16 Benno Schulenberg <bensberg@justemail.net> + * src/winio.c (get_mouseinput): Properly find also the zeroeth + item from a certain menu in the list of functions. Until now + this accidentally worked, because "Get Help" was the very first + item in almost all menus. Partly fixes Savannah bug #42093. + 2014-04-15 Benno Schulenberg <bensberg@justemail.net> * src/nano.c (precalc_multicolorinfo): Actually set the intended non-blocking mode for keyboard input. diff --git a/src/winio.c b/src/winio.c index 9d19072504bd4b925a46f1886750ad4ad74fa1fa..b334fc83d3dc2b0ca556362b98fa4e6008f4ce2c 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1690,29 +1690,35 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts) /* Adjust j if we released on the last two shortcuts. */ if ((j >= currslen) && (*mouse_x % i < COLS % i)) j -= 2; - +#ifdef DEBUG + fprintf(stderr, "Calculated %i as index in shortcut list, currmenu = %x.\n", j, currmenu); +#endif /* Ignore releases/clicks of the first mouse button beyond * the last shortcut. */ if (j >= currslen) return 2; - /* Go through the shortcut list to determine which shortcut - * we released/clicked on. */ + /* Go through the list of functions to determine which + * shortcut in the current menu we released/clicked on. */ f = allfuncs; - for (; j > 0; j--) { - if (f->next != NULL) - f = f->next; - - while (f->next != NULL && ((f->menus & currmenu) == 0 + while (TRUE) { + while ((f->menus & currmenu) == 0 #ifndef DISABLE_HELP - || strlen(f->help) == 0 + || strlen(f->help) == 0 #endif - )) - f = f->next; + ) + f = f->next; + if (j == 0) + break; + f = f->next; + j -= 1; } +#ifdef DEBUG + fprintf(stderr, "Stopped on func %ld present in menus %x\n", f->scfunc, f->menus); +#endif - /* And put back the equivalent key. */ + /* And put the corresponding key into the keyboard buffer. */ if (f != NULL) { const sc *s = first_sc_for(currmenu, f->scfunc); if (s != NULL) @@ -1769,7 +1775,7 @@ const sc *get_shortcut(int menu, int *kbinput, bool *meta_key) sc *s; #ifdef DEBUG - fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %s", *kbinput, *meta_key ? "TRUE" : "FALSE"); + fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %s -- ", *kbinput, *meta_key ? "TRUE" : "FALSE"); #endif /* Check for shortcuts. */