From 49816fed70c74034391b4679dbc38cf5e019bbe4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 1 Jul 2014 10:41:10 +0000 Subject: [PATCH] Now that 'currmenu' is really global, stop passing it around. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5043 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/browser.c | 4 ++-- src/files.c | 4 ++-- src/help.c | 2 +- src/nano.c | 2 +- src/prompt.c | 6 +++--- src/proto.h | 2 +- src/search.c | 2 +- src/text.c | 5 +++-- src/winio.c | 8 ++++---- 10 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6c5ee86..7e773b54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2014-07-01 Benno Schulenberg * src/browser.c (do_browser), src/help.c (do_help): Make sure to always set 'currmenu', so that we can rely on it. + * src/*.c (get_shortcut): Now that 'currmenu' is really global, + stop passing it around. 2014-06-30 Mark Majeres * src/cut.c, src/global.c, src/nano.c: Rename 'cut_till_end' to diff --git a/src/browser.c b/src/browser.c index 703a0dc1..474e0cdf 100644 --- a/src/browser.c +++ b/src/browser.c @@ -157,7 +157,7 @@ char *do_browser(char *path, DIR *dir) #endif /* !DISABLE_MOUSE */ parse_browser_input(&kbinput); - s = get_shortcut(MBROWSER, &kbinput); + s = get_shortcut(&kbinput); if (!s) continue; f = sctofunc((sc *) s); @@ -798,7 +798,7 @@ int filesearch_init(void) statusbar(_("Cancelled")); return -1; } else { - s = get_shortcut(MBROWSER, &i); + s = get_shortcut(&i); if (i == -2 || i == 0) { #ifdef HAVE_REGEX_H /* Use last_search if answer is an empty string, or diff --git a/src/files.c b/src/files.c index dfd32f08..18baacc3 100644 --- a/src/files.c +++ b/src/files.c @@ -1071,7 +1071,7 @@ void do_insertfile( ans = mallocstrcpy(ans, answer); - s = get_shortcut(currmenu, &i); + s = get_shortcut(&i); #ifndef NANO_TINY #ifndef DISABLE_MULTIBUFFER @@ -2291,7 +2291,7 @@ bool do_writeout(bool exiting) break; } else { ans = mallocstrcpy(ans, answer); - s = get_shortcut(currmenu, &i); + s = get_shortcut(&i); #ifndef DISABLE_BROWSER if (s && s->scfunc == to_files_void) { diff --git a/src/help.c b/src/help.c index 828badca..4bb2aa26 100644 --- a/src/help.c +++ b/src/help.c @@ -130,7 +130,7 @@ void do_help(void (*refresh_func)(void)) #endif parse_help_input(&kbinput); - s = get_shortcut(MHELP, &kbinput); + s = get_shortcut(&kbinput); if (!s) continue; f = sctofunc((sc *) s); diff --git a/src/nano.c b/src/nano.c index 288f83c7..5316874b 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1616,7 +1616,7 @@ int do_input(bool allow_funcs) #endif /* Check for a shortcut in the main list. */ - s = get_shortcut(MMAIN, &input); + s = get_shortcut(&input); /* If we got a shortcut from the main list, or a "universal" * edit window shortcut, set have_shortcut to TRUE. */ diff --git a/src/prompt.c b/src/prompt.c index e9ffd48c..66031a11 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -81,7 +81,7 @@ int do_statusbar_input(bool *ran_func, bool *finished, #endif /* Check for a shortcut in the current list. */ - s = get_shortcut(currmenu, &input); + s = get_shortcut(&input); /* If we got a shortcut from the current list, or a "universal" * statusbar prompt shortcut, set have_shortcut to TRUE. */ @@ -801,7 +801,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe kbinput = do_statusbar_input(&ran_func, &finished, refresh_func); assert(statusbar_x <= strlen(answer)); - s = get_shortcut(currmenu, &kbinput); + s = get_shortcut(&kbinput); if (s) if (s->scfunc == do_cancel || s->scfunc == do_enter_void) @@ -1120,7 +1120,7 @@ int do_yesno_prompt(bool all, const char *msg) currmenu = MYESNO; kbinput = get_kbinput(bottomwin); - s = get_shortcut(currmenu, &kbinput); + s = get_shortcut(&kbinput); if (s && s->scfunc == do_cancel) ok = -1; diff --git a/src/proto.h b/src/proto.h index 8f327144..dcc634fe 100644 --- a/src/proto.h +++ b/src/proto.h @@ -770,7 +770,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len); #ifndef DISABLE_MOUSE int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts); #endif -const sc *get_shortcut(int menu, int *kbinput); +const sc *get_shortcut(int *kbinput); void blank_line(WINDOW *win, int y, int x, int n); void blank_titlebar(void); void blank_topbar(void); diff --git a/src/search.c b/src/search.c index cdde40f1..f696b2f2 100644 --- a/src/search.c +++ b/src/search.c @@ -1049,7 +1049,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, return; } - s = get_shortcut(currmenu, &i); + s = get_shortcut(&i); if (s && s->scfunc == gototext_void) { /* Keep answer up on the statusbar. */ diff --git a/src/text.c b/src/text.c index 008da02c..206c7b45 100644 --- a/src/text.c +++ b/src/text.c @@ -2188,12 +2188,13 @@ void do_justify(bool full_justify) /* Display the shortcut list with UnJustify. */ uncutfunc->desc = unjust_tag; + currmenu = MMAIN; display_main_list(); /* Now get a keystroke and see if it's unjustify. If not, put back * the keystroke and return. */ kbinput = do_input(FALSE); - s = get_shortcut(MMAIN, &kbinput); + s = get_shortcut(&kbinput); if (s && s->scfunc == do_uncut_text) { /* Splice the justify buffer back into the file, but only if we @@ -3169,7 +3170,7 @@ void do_linter(void) } kbinput = get_kbinput(bottomwin); - s = get_shortcut(currmenu, &kbinput); + s = get_shortcut(&kbinput); tmplint = curlint; if (!s) diff --git a/src/winio.c b/src/winio.c index b232f3a6..04cd6d0b 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1790,7 +1790,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts) * key itself) and meta_key (whether the key is a meta sequence). The * returned shortcut will be the first in the list that corresponds to * the given sequence. */ -const sc *get_shortcut(int menu, int *kbinput) +const sc *get_shortcut(int *kbinput) { sc *s; @@ -1799,11 +1799,11 @@ const sc *get_shortcut(int menu, int *kbinput) #endif for (s = sclist; s != NULL; s = s->next) { - if ((menu & s->menu) && *kbinput == s->seq + if ((currmenu & s->menu) && *kbinput == s->seq && meta_key == (s->type == META)) { #ifdef DEBUG fprintf (stderr, "matched seq \"%s\", and btw meta was %d (menu is %x from %x)\n", - s->keystr, meta_key, menu, s->menu); + s->keystr, meta_key, currmenu, s->menu); #endif return s; } @@ -1825,7 +1825,7 @@ const subnfunc *getfuncfromkey(WINDOW *win) if (kbinput == 0) return NULL; - s = get_shortcut(currmenu, &kbinput); + s = get_shortcut(&kbinput); if (!s) return NULL;