From 12514eab7f2d206e967d50d99039bf76f974ba2a Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Tue, 19 May 2020 21:30:16 +0200 Subject: Let RETURN set frequency type to current value in repeat command UI In addition, the prompt text is shortened. Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/ui-day.c | 30 +++++++++++++++++------------- src/utils.c | 2 ++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/ui-day.c b/src/ui-day.c index bd83cac..0d0e1fd 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -672,11 +672,11 @@ static int update_rept(time_t start, long dur, struct rpt **rpt, llist_t *exc, LLIST_INIT(&nrpt.bymonthday); /* Edit repetition type. */ - const char *msg_prefix = _("Repetition type:"); - const char *daily = _("(d)aily"); - const char *weekly = _("(w)eekly"); - const char *monthly = _("(m)onthly"); - const char *yearly = _("(y)early"); + const char *msg_prefix = _("Base period:"); + const char *daily = _("day"); + const char *weekly = _("week"); + const char *monthly = _("month"); + const char *yearly = _("year"); const char *dwmy = _("[dwmy]"); /* 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. */ current = ""; } - asprintf(&types, "%s %s, %s, %s, %s?", + asprintf(&types, "%s %s/%s/%s/%s?", msg_prefix, daily, weekly, monthly, yearly); if (current[0]) - asprintf(&types, "%s (now %s)", types, current); + asprintf(&types, "%s [%s]", types, current); switch (status_ask_choice(types, dwmy, 4)) { case 1: - nrpt.type = 'D'; + nrpt.type = recur_char2def('D'); break; case 2: - nrpt.type = 'W'; + nrpt.type = recur_char2def('W'); break; case 3: - nrpt.type = 'M'; + nrpt.type = recur_char2def('M'); break; case 4: - nrpt.type = 'Y'; + nrpt.type = recur_char2def('Y'); break; + case -2: /* user typed RETURN */ + if (current[0]) { + nrpt.type = (*rpt)->type; + break; + } default: goto cleanup; } - nrpt.type = recur_char2def(nrpt.type); /* Edit frequency. */ - const char *msg_freq = _("Repetition frequency:"); + const char *msg_freq = _("Frequency:"); const char *msg_inv_freq = _("Invalid frequency."); do { status_mesg(msg_freq, ""); diff --git a/src/utils.c b/src/utils.c index 8c539c3..6f849ea 100644 --- a/src/utils.c +++ b/src/utils.c @@ -235,6 +235,8 @@ int status_ask_choice(const char *message, const char choice[], return i + 1; if (ch == ESCAPE) return (-1); + if (ch == RETURN) + return (-2); if (resize) { resize = 0; wins_reset(); -- cgit v1.2.3-70-g09d2