Support interactive test of recurrence rule extensions
The generic command 'next' is introduced. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
committed by
Lukas Fleischer
parent
f3779d5945
commit
f2918b1700
@@ -557,7 +557,7 @@ static inline void key_generic_cmd(void)
|
||||
int valid = 0, force = 0, ret;
|
||||
char *error_msg;
|
||||
|
||||
status_mesg(_("Command: [ h(elp) | w(rite)(!) | q(uit)(!) | wq(!) ]"), "");
|
||||
status_mesg(_("Command: [ h(elp) | w(rite)(!) | q(uit)(!) | wq(!) | n(ext) ]"), "");
|
||||
if (getstring(win[STA].p, cmd, BUFSIZ, 0, 1) != GETSTRING_VALID)
|
||||
goto cleanup;
|
||||
cmd_name = strtok(cmd, " ");
|
||||
@@ -609,6 +609,47 @@ static inline void key_generic_cmd(void)
|
||||
valid = 1;
|
||||
}
|
||||
|
||||
if (!strcmp(cmd_name, "next") || !strcmp(cmd_name, "n")) {
|
||||
struct day_item *item;
|
||||
time_t day, next;
|
||||
struct recur_apoint *rapt;
|
||||
struct recur_event *rev;
|
||||
int more = 0;
|
||||
|
||||
if (wins_slctd() != APP) {
|
||||
error_msg =
|
||||
_("Select a repeating item in the appointments panel.");
|
||||
warnbox(error_msg);
|
||||
goto cleanup;
|
||||
}
|
||||
day = date2sec(*ui_calendar_get_slctd_day(), 0, 0);
|
||||
item = ui_day_get_sel();
|
||||
if (item->type == RECUR_EVNT) {
|
||||
rev = item->item.rev;
|
||||
more = recur_next_occurrence(rev->day, -1, rev->rpt, &rev->exc,
|
||||
day, &next);
|
||||
} else if (item->type == RECUR_APPT) {
|
||||
rapt = item->item.rapt;
|
||||
more = recur_next_occurrence(rapt->start, rapt->dur, rapt->rpt,
|
||||
&rapt->exc, day, &next);
|
||||
} else {
|
||||
error_msg = _("Not a repeating item.");
|
||||
warnbox(error_msg);
|
||||
goto cleanup;
|
||||
}
|
||||
if (!more) {
|
||||
error_msg = _("Last repetition.");
|
||||
warnbox(error_msg);
|
||||
goto cleanup;
|
||||
}
|
||||
item->start = next;
|
||||
ui_calendar_set_slctd_day(sec2date(next));
|
||||
day_set_sel_data(item);
|
||||
do_storage(1);
|
||||
|
||||
valid = 1;
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
asprintf(&error_msg, _("No such command: %s"), cmd);
|
||||
status_mesg(error_msg, "");
|
||||
|
||||
Reference in New Issue
Block a user