aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apoint.c3
-rw-r--r--src/calcurse.c6
-rw-r--r--src/calcurse.h2
-rw-r--r--src/io.c12
-rw-r--r--src/todo.c13
-rw-r--r--src/utils.c18
6 files changed, 19 insertions, 35 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 60a7c19..9bcde1b 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -276,8 +276,7 @@ apoint_delete (unsigned *nb_events, unsigned *nb_apoints)
if (conf.confirm_delete)
{
- status_mesg_yesno (del_app_str);
- if (wgetch (win[STA].p) != 'y')
+ if (status_ask_bool (del_app_str) != 1)
{
wins_erase_status_bar ();
return;
diff --git a/src/calcurse.c b/src/calcurse.c
index 6c473c3..ee85ea7 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -546,10 +546,8 @@ main (int argc, char **argv)
if (conf.confirm_quit)
{
- status_mesg_yesno (_("Do you really want to quit ?"));
- key = wgetch (win[STA].p);
- if (key == 'y')
- exit_calcurse (EXIT_SUCCESS);
+ if (status_ask_bool (_("Do you really want to quit ?")) == 1)
+ exit_calcurse (EXIT_SUCCESS);
else
{
wins_erase_status_bar ();
diff --git a/src/calcurse.h b/src/calcurse.h
index e26976a..5165f25 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -895,8 +895,8 @@ void free_user_data (void);
void fatalbox (const char *);
void warnbox (const char *);
void status_mesg (const char *, const char *);
-void status_mesg_yesno (const char *);
int status_ask_choice (const char *, const char[], int);
+int status_ask_bool (const char *);
int status_ask_simplechoice (const char *, const char *[], int);
void erase_window_part (WINDOW *, int, int, int, int);
WINDOW *popup (int, int, int, int, const char *, const char *, int);
diff --git a/src/io.c b/src/io.c
index 737a198..b382e07 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1253,16 +1253,8 @@ io_log_display (struct io_file *log, const char *msg, const char *pager)
}
else
{
- status_mesg_yesno (msg);
- do
- {
- ans = wgetch (win[STA].p);
- if (ans == 'y')
- {
- wins_launch_external (log->name, pager);
- }
- }
- while (ans != 'y' && ans != 'n');
+ if (status_ask_bool (msg) == 1)
+ wins_launch_external (log->name, pager);
wins_erase_status_bar ();
}
}
diff --git a/src/todo.c b/src/todo.c
index 87d6faf..24bcec6 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -250,17 +250,8 @@ todo_delete (void)
const int nb_erase_choice = 2;
int answer;
- if (conf.confirm_delete)
- {
- status_mesg_yesno (del_todo_str);
- answer = wgetch (win[STA].p);
- if ((answer != 'y') || (todos <= 0))
- {
- wins_erase_status_bar ();
- return;
- }
- }
- else if (todos <= 0)
+ if ((todos <= 0) ||
+ (conf.confirm_delete && (status_ask_bool (del_todo_str) != 1)))
{
wins_erase_status_bar ();
return;
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