Allow to omit end date in repetitions

Addresses GitHub issue #213.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2019-06-03 18:43:23 -04:00
parent e6099b2d59
commit 987fa9d3e5

View File

@ -366,9 +366,11 @@ static void update_rept(struct rpt **rpt, const long start)
mem_free(timstr); mem_free(timstr);
timstr = date_sec2date_str((*rpt)->until, DATEFMT(conf.input_datefmt)); timstr = date_sec2date_str((*rpt)->until, DATEFMT(conf.input_datefmt));
status_mesg(msg_until_1, ""); status_mesg(msg_until_1, "");
if (updatestring(win[STA].p, &timstr, 0, 1) != if (updatestring(win[STA].p, &timstr, 0, 1) == GETSTRING_ESC)
GETSTRING_VALID) {
goto cleanup; goto cleanup;
if (strcmp(timstr, "") == 0 || strcmp(timstr, "0") == 0) {
newuntil = 0;
break;
} }
if (*(timstr + strlen(timstr) - 1) == '?') { if (*(timstr + strlen(timstr) - 1) == '?') {
mem_free(outstr); mem_free(outstr);
@ -377,10 +379,6 @@ static void update_rept(struct rpt **rpt, const long start)
keys_wgetch(win[KEY].p); keys_wgetch(win[KEY].p);
continue; continue;
} }
if (strcmp(timstr, "0") == 0) {
newuntil = 0;
break;
}
if (*timstr == '+') { if (*timstr == '+') {
unsigned days; unsigned days;
if (!parse_date_duration(timstr + 1, &days, start)) { if (!parse_date_duration(timstr + 1, &days, start)) {
@ -905,9 +903,12 @@ void ui_day_item_repeat(void)
char *outstr, *datestr; char *outstr, *datestr;
for (;;) { for (;;) {
status_mesg(mesg_until_1, ""); status_mesg(mesg_until_1, "");
if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) != if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_ESC)
GETSTRING_VALID)
goto cleanup; goto cleanup;
if (strcmp(user_input, "") == 0 || strcmp(user_input, "0") == 0) {
until = 0;
break;
}
if (*user_input == '?') { if (*user_input == '?') {
user_input[0] = '\0'; user_input[0] = '\0';
asprintf(&outstr, mesg_help_1, DATEFMT_DESC(conf.input_datefmt)); asprintf(&outstr, mesg_help_1, DATEFMT_DESC(conf.input_datefmt));
@ -916,10 +917,6 @@ void ui_day_item_repeat(void)
wgetch(win[KEY].p); wgetch(win[KEY].p);
continue; continue;
} }
if (strcmp(user_input, "0") == 0) {
until = 0;
break;
}
if (*user_input == '+') { if (*user_input == '+') {
if (!parse_date_duration(user_input + 1, &days, p->start)) { if (!parse_date_duration(user_input + 1, &days, p->start)) {
status_mesg(mesg_wrong_1, mesg_wrong_2); status_mesg(mesg_wrong_1, mesg_wrong_2);