aboutsummaryrefslogtreecommitdiffstats
path: root/src/recur.c
diff options
context:
space:
mode:
authorBaptiste Jonglez <baptiste--git@jonglez.org>2012-05-13 14:09:20 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-05-14 19:31:13 +0200
commit7d4ef08345d51e59b045c3d8415a4f15bd758d3c (patch)
treea21f887648a81521c8803feab8a859b1d2dc6731 /src/recur.c
parent1d9c90bb18969faed7dc2e833c4b21949bd31bbb (diff)
downloadcalcurse-7d4ef08345d51e59b045c3d8415a4f15bd758d3c.tar.gz
calcurse-7d4ef08345d51e59b045c3d8415a4f15bd758d3c.zip
Use status_ask_choice() on more difficult cases
These cases are also candidates for the factorisation process, but they are somewhat more tricky to get right. Since we use a completely different approach, the result (from a user perspective) looks different. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/recur.c')
-rw-r--r--src/recur.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/recur.c b/src/recur.c
index bf18d55..d1a5516 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -868,15 +868,17 @@ recur_repeat_item (void)
{
struct tm *lt;
time_t t;
- int ch = 0;
int date_entered = 0;
int year = 0, month = 0, day = 0;
struct date until_date;
char outstr[BUFSIZ];
char user_input[BUFSIZ] = "";
- const char *mesg_type_1 =
- _("Enter the repetition type: (D)aily, (W)eekly, (M)onthly, (Y)early");
- const char *mesg_type_2 = _("[D/W/M/Y] ");
+ const char *msg_rpt_prefix = _("Enter the repetition type:");
+ const char *msg_rpt_daily = _("(d)aily");
+ const char *msg_rpt_weekly = _("(w)eekly");
+ const char *msg_rpt_monthly = _("(m)onthly");
+ const char *msg_rpt_yearly = _("(y)early");
+ const char *msg_type_choice = _("[dwmy]");
const char *mesg_freq_1 = _("Enter the repetition frequence:");
const char *mesg_wrong_freq = _("The frequence you entered is not valid.");
const char *mesg_until_1 =
@@ -888,6 +890,15 @@ recur_repeat_item (void)
const char *wrong_type_2 = _("Press [ENTER] to continue.");
const char *mesg_older =
_("Sorry, the date you entered is older than the item start time.");
+
+ char msg_asktype[BUFSIZ];
+ snprintf (msg_asktype, BUFSIZ, "%s %s, %s, %s, %s",
+ msg_rpt_prefix,
+ msg_rpt_daily,
+ msg_rpt_weekly,
+ msg_rpt_monthly,
+ msg_rpt_yearly);
+
int type = 0, freq = 0;
int item_nb;
struct day_item *p;
@@ -903,21 +914,23 @@ recur_repeat_item (void)
return;
}
- while ((ch != 'D') && (ch != 'W') && (ch != 'M')
- && (ch != 'Y') && (ch != ESCAPE))
- {
- status_mesg (mesg_type_1, mesg_type_2);
- ch = wgetch (win[STA].p);
- ch = toupper (ch);
- }
- if (ch == ESCAPE)
+ switch (status_ask_choice (msg_asktype, msg_type_choice, 4))
{
+ case 1:
+ type = RECUR_DAILY;
+ break;
+ case 2:
+ type = RECUR_WEEKLY;
+ break;
+ case 3:
+ type = RECUR_MONTHLY;
+ break;
+ case 4:
+ type = RECUR_YEARLY;
+ break;
+ default:
return;
}
- else
- {
- type = recur_char2def (ch);
- }
while (freq == 0)
{