From 987fa9d3e5db8549612db7a8f1c05f7e7a19d224 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 3 Jun 2019 18:43:23 -0400 Subject: Allow to omit end date in repetitions Addresses GitHub issue #213. Signed-off-by: Lukas Fleischer --- src/ui-day.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ui-day.c b/src/ui-day.c index 5907490..c90edc1 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -366,9 +366,11 @@ static void update_rept(struct rpt **rpt, const long start) mem_free(timstr); timstr = date_sec2date_str((*rpt)->until, DATEFMT(conf.input_datefmt)); status_mesg(msg_until_1, ""); - if (updatestring(win[STA].p, &timstr, 0, 1) != - GETSTRING_VALID) { + if (updatestring(win[STA].p, &timstr, 0, 1) == GETSTRING_ESC) goto cleanup; + if (strcmp(timstr, "") == 0 || strcmp(timstr, "0") == 0) { + newuntil = 0; + break; } if (*(timstr + strlen(timstr) - 1) == '?') { mem_free(outstr); @@ -377,10 +379,6 @@ static void update_rept(struct rpt **rpt, const long start) keys_wgetch(win[KEY].p); continue; } - if (strcmp(timstr, "0") == 0) { - newuntil = 0; - break; - } if (*timstr == '+') { unsigned days; if (!parse_date_duration(timstr + 1, &days, start)) { @@ -905,9 +903,12 @@ void ui_day_item_repeat(void) char *outstr, *datestr; for (;;) { status_mesg(mesg_until_1, ""); - if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) != - GETSTRING_VALID) + if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_ESC) goto cleanup; + if (strcmp(user_input, "") == 0 || strcmp(user_input, "0") == 0) { + until = 0; + break; + } if (*user_input == '?') { user_input[0] = '\0'; asprintf(&outstr, mesg_help_1, DATEFMT_DESC(conf.input_datefmt)); @@ -916,10 +917,6 @@ void ui_day_item_repeat(void) wgetch(win[KEY].p); continue; } - if (strcmp(user_input, "0") == 0) { - until = 0; - break; - } if (*user_input == '+') { if (!parse_date_duration(user_input + 1, &days, p->start)) { status_mesg(mesg_wrong_1, mesg_wrong_2); -- cgit v1.2.3-70-g09d2