From 0d84301da3b14bc07d4e72d49f09b46b589ce71f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 16 Apr 2014 08:24:32 +0000 Subject: [PATCH] Finding properly also the zeroeth item from a certain menu in the list of functions. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4781 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++++++ src/winio.c | 32 +++++++++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 965e668f..9f58a68c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-04-16 Benno Schulenberg + * 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 * 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 9d190725..b334fc83 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. */ -- 2.39.5