From d0b9bec88a5b0c11b2a13303ceb5e8c5e5b09e05 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 6 Jul 2021 13:12:50 -0700 Subject: Add a help choice '?' to the yes or no prompt for quadoptions. The prompt currently just prints "See $%s for more information." where %s is the variable name. This will at least give a pointer to what variable can be adjusted to change the prompt behavior. A handful of boolean variables also control prompt display. Add a help choice for those too using the function mutt_query_boolean(). --- init.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'init.c') diff --git a/init.c b/init.c index e75e51e9..01abe50d 100644 --- a/init.c +++ b/init.c @@ -104,6 +104,27 @@ int quadoption (int opt) return (QuadOptions[n] >> b) & 0x3; } +static const char *option_type_name (int opt, int type) +{ + int i; + + for (i = 0; MuttVars[i].option; i++) + if (MuttVars[i].type == type && + MuttVars[i].data.l == opt) + return MuttVars[i].option; + return NULL; +} + +static const char *quadoption_name (int opt) +{ + return option_type_name (opt, DT_QUAD); +} + +static const char *boolean_name (int opt) +{ + return option_type_name (opt, DT_BOOL); +} + int query_quadoption (int opt, const char *prompt) { int v = quadoption (opt); @@ -115,7 +136,8 @@ int query_quadoption (int opt, const char *prompt) return (v); default: - v = mutt_yesorno (prompt, (v == MUTT_ASKYES)); + v = mutt_yesorno_with_help (prompt, (v == MUTT_ASKYES), + quadoption_name (opt)); mutt_window_clearline (MuttMessageWindow, 0); return (v); } @@ -123,6 +145,19 @@ int query_quadoption (int opt, const char *prompt) /* not reached */ } +/* This is slightly different from query_quadoption(), which only + * prompts when the quadoption is of type "ask-*". + * + * This function always prompts, but provides a help string listing + * the boolean name as a reference. It should be used when displaying + * the mutt_yesorno() prompt depends on the setting of the boolean. + */ +int mutt_query_boolean (int opt, const char *prompt, int def) +{ + return mutt_yesorno_with_help (prompt, def, + boolean_name (opt)); +} + /* given the variable ``s'', return the index into the rc_vars array which matches, or -1 if the variable is not found. */ static int mutt_option_index (char *s) -- cgit v1.2.3