Treat recurrence item parameters as a unit
An edit session, and in particular, a cancelled edit session should encompass all parameters. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
f374737171
commit
cc86516f64
@ -1022,7 +1022,7 @@ void pcal_export_data(FILE *);
|
|||||||
/* recur.c */
|
/* recur.c */
|
||||||
extern llist_ts_t recur_alist_p;
|
extern llist_ts_t recur_alist_p;
|
||||||
extern llist_t recur_elist;
|
extern llist_t recur_elist;
|
||||||
void recur_update_exc(llist_t *, char *);
|
int recur_update_exc(llist_t *, char *);
|
||||||
char *recur_exc2str(llist_t *);
|
char *recur_exc2str(llist_t *);
|
||||||
struct recur_event *recur_event_dup(struct recur_event *);
|
struct recur_event *recur_event_dup(struct recur_event *);
|
||||||
struct recur_apoint *recur_apoint_dup(struct recur_apoint *);
|
struct recur_apoint *recur_apoint_dup(struct recur_apoint *);
|
||||||
|
@ -106,8 +106,9 @@ char *recur_exc2str(llist_t *exc)
|
|||||||
* Update the list of exceptions from a string of days. Any positive number of
|
* Update the list of exceptions from a string of days. Any positive number of
|
||||||
* spaces are allowed before, between and after the days.
|
* spaces are allowed before, between and after the days.
|
||||||
*/
|
*/
|
||||||
void recur_update_exc(llist_t *exc, char *days)
|
int recur_update_exc(llist_t *exc, char *days)
|
||||||
{
|
{
|
||||||
|
int updated = 0;
|
||||||
char *d;
|
char *d;
|
||||||
time_t t = get_today();
|
time_t t = get_today();
|
||||||
llist_t nexc;
|
llist_t nexc;
|
||||||
@ -131,8 +132,10 @@ void recur_update_exc(llist_t *exc, char *days)
|
|||||||
}
|
}
|
||||||
free_exc_list(exc);
|
free_exc_list(exc);
|
||||||
exc_dup(exc, &nexc);
|
exc_dup(exc, &nexc);
|
||||||
|
updated = 1;
|
||||||
cleanup:
|
cleanup:
|
||||||
free_exc_list(&nexc);
|
free_exc_list(&nexc);
|
||||||
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct recur_event *recur_event_dup(struct recur_event *in)
|
struct recur_event *recur_event_dup(struct recur_event *in)
|
||||||
|
59
src/ui-day.c
59
src/ui-day.c
@ -272,7 +272,38 @@ static void update_desc(char **desc)
|
|||||||
updatestring(win[STA].p, desc, 0, 1);
|
updatestring(win[STA].p, desc, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_rept(struct rpt **rpt, const long start)
|
/* Edit the list of exception days for a recurrent item. */
|
||||||
|
static int update_exc(llist_t *exc)
|
||||||
|
{
|
||||||
|
int updated = 0;
|
||||||
|
|
||||||
|
if (!exc->head)
|
||||||
|
return updated;
|
||||||
|
char *days;
|
||||||
|
enum getstr ret;
|
||||||
|
|
||||||
|
status_mesg(_("Exception days:"), "");
|
||||||
|
days = recur_exc2str(exc);
|
||||||
|
while (1) {
|
||||||
|
ret = updatestring(win[STA].p, &days, 0, 1);
|
||||||
|
if (ret == GETSTRING_VALID || ret == GETSTRING_RET) {
|
||||||
|
if (recur_update_exc(exc, days)) {
|
||||||
|
updated = 1;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
status_mesg(_("Invalid date format - try again:."), "");
|
||||||
|
mem_free(days);
|
||||||
|
days = recur_exc2str(exc);
|
||||||
|
}
|
||||||
|
} else if (ret == GETSTRING_ESC)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mem_free(days);
|
||||||
|
|
||||||
|
return updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_rept(struct rpt **rpt, const time_t start, llist_t *exc)
|
||||||
{
|
{
|
||||||
/* Pointers to dynamically allocated memory. */
|
/* Pointers to dynamically allocated memory. */
|
||||||
char *msg_rpt_current = NULL;
|
char *msg_rpt_current = NULL;
|
||||||
@ -412,6 +443,10 @@ static void update_rept(struct rpt **rpt, const long start)
|
|||||||
keys_wgetch(win[KEY].p);
|
keys_wgetch(win[KEY].p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update exception list. */
|
||||||
|
if (!update_exc(exc))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
(*rpt)->type = recur_char2def(newtype);
|
(*rpt)->type = recur_char2def(newtype);
|
||||||
(*rpt)->freq = newfreq;
|
(*rpt)->freq = newfreq;
|
||||||
(*rpt)->until = newuntil;
|
(*rpt)->until = newuntil;
|
||||||
@ -424,22 +459,6 @@ cleanup:
|
|||||||
mem_free(outstr);
|
mem_free(outstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Edit the list of exception days for a recurrent item. */
|
|
||||||
static void update_exc(llist_t *exc)
|
|
||||||
{
|
|
||||||
if (!exc->head)
|
|
||||||
return;
|
|
||||||
char *days;
|
|
||||||
enum getstr ret;
|
|
||||||
|
|
||||||
status_mesg(_("Exception days:"), "");
|
|
||||||
days = recur_exc2str(exc);
|
|
||||||
ret = updatestring(win[STA].p, &days, 0, 1);
|
|
||||||
if (ret == GETSTRING_VALID || ret == GETSTRING_RET)
|
|
||||||
recur_update_exc(exc, days);
|
|
||||||
mem_free(days);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Edit an already existing item. */
|
/* Edit an already existing item. */
|
||||||
void ui_day_item_edit(void)
|
void ui_day_item_edit(void)
|
||||||
{
|
{
|
||||||
@ -468,8 +487,7 @@ void ui_day_item_edit(void)
|
|||||||
io_set_modified();
|
io_set_modified();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
update_rept(&re->rpt, re->day);
|
update_rept(&re->rpt, re->day, &re->exc);
|
||||||
update_exc(&re->exc);
|
|
||||||
io_set_modified();
|
io_set_modified();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -510,8 +528,7 @@ void ui_day_item_edit(void)
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
need_check_notify = 1;
|
need_check_notify = 1;
|
||||||
update_rept(&ra->rpt, ra->start);
|
update_rept(&ra->rpt, ra->start, &ra->exc);
|
||||||
update_exc(&ra->exc);
|
|
||||||
io_set_modified();
|
io_set_modified();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user