aboutsummaryrefslogtreecommitdiffstats
path: root/src/todo.c
diff options
context:
space:
mode:
authorBaptiste Jonglez <baptiste--git@jonglez.org>2012-05-14 12:38:22 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-05-14 19:31:13 +0200
commit1d9c90bb18969faed7dc2e833c4b21949bd31bbb (patch)
treebfd252f618f30a95153d4335d64041e8cec36391 /src/todo.c
parent4087cd4e5ee193bb5b46472fb36bfda2017d788d (diff)
downloadcalcurse-1d9c90bb18969faed7dc2e833c4b21949bd31bbb.tar.gz
calcurse-1d9c90bb18969faed7dc2e833c4b21949bd31bbb.zip
Use status_ask_choice() where applicable
These cases make obvious candidates for factorisation. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/todo.c')
-rw-r--r--src/todo.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/todo.c b/src/todo.c
index a4c75da..87d6faf 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -246,8 +246,9 @@ todo_delete (void)
const char *erase_warning =
_("This item has a note attached to it. "
"Delete (t)odo or just its (n)ote ?");
- const char *erase_choice = _("[t/n] ");
- int answer, has_note;
+ const char *erase_choice = _("[tn]");
+ const int nb_erase_choice = 2;
+ int answer;
if (conf.confirm_delete)
{
@@ -265,20 +266,15 @@ todo_delete (void)
return;
}
- answer = -1;
- has_note = (todo_get_item (hilt)->note != NULL) ? 1 : 0;
- if (has_note == 0)
- answer = 't';
-
- while (answer != 't' && answer != 'n' && answer != KEY_GENERIC_CANCEL)
- {
- status_mesg (erase_warning, erase_choice);
- answer = wgetch (win[STA].p);
- }
+ /* This todo item doesn't have any note associated. */
+ if (todo_get_item (hilt)->note == NULL)
+ answer = 1;
+ else
+ answer = status_ask_choice (erase_warning, erase_choice, nb_erase_choice);
switch (answer)
{
- case 't':
+ case 1:
todo_delete_bynum (hilt - 1);
todos--;
if (hilt > 1)
@@ -288,7 +284,7 @@ todo_delete (void)
if (hilt - first < 0)
first--;
break;
- case 'n':
+ case 2:
todo_delete_note_bynum (hilt - 1);
break;
default: