aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorBaptiste Jonglez <baptiste--git@jonglez.org>2012-05-13 14:09:21 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-05-14 19:31:13 +0200
commit13d6f8703bacfb8543c9d22c01db60e083650cad (patch)
treec7c9449a0627df8b17be995cfa02fa8ccca07711 /src/utils.c
parent7d4ef08345d51e59b045c3d8415a4f15bd758d3c (diff)
downloadcalcurse-13d6f8703bacfb8543c9d22c01db60e083650cad.tar.gz
calcurse-13d6f8703bacfb8543c9d22c01db60e083650cad.zip
Factorize boolean user prompting.
Introduce a new `status_ask_bool()` function, and use it where applicable. This greatly reduces code duplication, and will allow handling special events (resize, user escape) much more uniformely. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/utils.c b/src/utils.c
index 37c1036..5359538 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -184,13 +184,6 @@ status_mesg (const char *msg1, const char *msg2)
custom_remove_attr (win[STA].p, ATTR_HIGHEST);
}
-/* Print a status message, followed by a "[y/n]" prompt. */
-void
-status_mesg_yesno (const char *msg)
-{
- status_mesg (msg, "[y/n] ");
-}
-
/*
* Prompts the user to make a choice between named alternatives.
*
@@ -234,6 +227,17 @@ status_ask_choice(const char *message, const char choice[], int nb_choice)
}
/*
+ * Prompts the user with a boolean question.
+ *
+ * Returns 1 if yes, 2 if no, and -1 otherwise
+ */
+int
+status_ask_bool (const char *msg)
+{
+ return (status_ask_choice (msg, _("[yn]"), 2));
+}
+
+/*
* Prompts the user to make a choice between a number of alternatives.
*
* Returns the option chosen by the user (starting from 1), or -1 if