Let RETURN set frequency type to current value in repeat command UI

In addition, the prompt text is shortened.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2020-05-19 21:30:16 +02:00 committed by Lukas Fleischer
parent 92dc069fc4
commit 12514eab7f
2 changed files with 19 additions and 13 deletions

View File

@ -672,11 +672,11 @@ static int update_rept(time_t start, long dur, struct rpt **rpt, llist_t *exc,
LLIST_INIT(&nrpt.bymonthday); LLIST_INIT(&nrpt.bymonthday);
/* Edit repetition type. */ /* Edit repetition type. */
const char *msg_prefix = _("Repetition type:"); const char *msg_prefix = _("Base period:");
const char *daily = _("(d)aily"); const char *daily = _("day");
const char *weekly = _("(w)eekly"); const char *weekly = _("week");
const char *monthly = _("(m)onthly"); const char *monthly = _("month");
const char *yearly = _("(y)early"); const char *yearly = _("year");
const char *dwmy = _("[dwmy]"); const char *dwmy = _("[dwmy]");
/* Find the current repetition type. */ /* Find the current repetition type. */
@ -698,30 +698,34 @@ static int update_rept(time_t start, long dur, struct rpt **rpt, llist_t *exc,
/* New item. */ /* New item. */
current = ""; current = "";
} }
asprintf(&types, "%s %s, %s, %s, %s?", asprintf(&types, "%s %s/%s/%s/%s?",
msg_prefix, daily, weekly, monthly, yearly); msg_prefix, daily, weekly, monthly, yearly);
if (current[0]) if (current[0])
asprintf(&types, "%s (now %s)", types, current); asprintf(&types, "%s [%s]", types, current);
switch (status_ask_choice(types, dwmy, 4)) { switch (status_ask_choice(types, dwmy, 4)) {
case 1: case 1:
nrpt.type = 'D'; nrpt.type = recur_char2def('D');
break; break;
case 2: case 2:
nrpt.type = 'W'; nrpt.type = recur_char2def('W');
break; break;
case 3: case 3:
nrpt.type = 'M'; nrpt.type = recur_char2def('M');
break; break;
case 4: case 4:
nrpt.type = 'Y'; nrpt.type = recur_char2def('Y');
break; break;
case -2: /* user typed RETURN */
if (current[0]) {
nrpt.type = (*rpt)->type;
break;
}
default: default:
goto cleanup; goto cleanup;
} }
nrpt.type = recur_char2def(nrpt.type);
/* Edit frequency. */ /* Edit frequency. */
const char *msg_freq = _("Repetition frequency:"); const char *msg_freq = _("Frequency:");
const char *msg_inv_freq = _("Invalid frequency."); const char *msg_inv_freq = _("Invalid frequency.");
do { do {
status_mesg(msg_freq, ""); status_mesg(msg_freq, "");

View File

@ -235,6 +235,8 @@ int status_ask_choice(const char *message, const char choice[],
return i + 1; return i + 1;
if (ch == ESCAPE) if (ch == ESCAPE)
return (-1); return (-1);
if (ch == RETURN)
return (-2);
if (resize) { if (resize) {
resize = 0; resize = 0;
wins_reset(); wins_reset();