summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-07-06 13:12:50 -0700
committerKevin McCarthy <kevin@8t8.us>2021-07-07 15:37:06 -0700
commitd0b9bec88a5b0c11b2a13303ceb5e8c5e5b09e05 (patch)
tree5baad9a64b3f788866aa24ab0a59b70527680884 /init.c
parentab6bbb5b15b747a72d202e150dd0621d2d9155cb (diff)
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().
Diffstat (limited to 'init.c')
-rw-r--r--init.c37
1 files changed, 36 insertions, 1 deletions
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)