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>
This commit is contained in:
Baptiste Jonglez
2012-05-13 14:09:21 +02:00
committed by Lukas Fleischer
parent 7d4ef08345
commit 13d6f8703b
6 changed files with 19 additions and 35 deletions

View File

@@ -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.
*
@@ -233,6 +226,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.
*