Ability to attach notes to appointments and events added
This commit is contained in:
parent
b7115fbcf2
commit
738a3a4170
@ -1,3 +1,6 @@
|
|||||||
|
13 Jan 2008:
|
||||||
|
Ability to attach notes to appointments and events added
|
||||||
|
|
||||||
31 Dec 2007:
|
31 Dec 2007:
|
||||||
Notes attached to todos can now be suppressed
|
Notes attached to todos can now be suppressed
|
||||||
|
|
||||||
|
61
src/apoint.c
61
src/apoint.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: apoint.c,v 1.19 2007/12/30 16:27:58 culot Exp $ */
|
/* $calcurse: apoint.c,v 1.20 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -43,7 +43,8 @@
|
|||||||
apoint_llist_t *alist_p;
|
apoint_llist_t *alist_p;
|
||||||
static int hilt = 0;
|
static int hilt = 0;
|
||||||
|
|
||||||
int apoint_llist_init(void)
|
int
|
||||||
|
apoint_llist_init(void)
|
||||||
{
|
{
|
||||||
alist_p = (apoint_llist_t *) malloc(sizeof(apoint_llist_t));
|
alist_p = (apoint_llist_t *) malloc(sizeof(apoint_llist_t));
|
||||||
alist_p->root = NULL;
|
alist_p->root = NULL;
|
||||||
@ -79,13 +80,14 @@ apoint_hilt(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
apoint_llist_node_t *
|
apoint_llist_node_t *
|
||||||
apoint_new(char *mesg, long start, long dur, char state)
|
apoint_new(char *mesg, char *note, long start, long dur, char state)
|
||||||
{
|
{
|
||||||
apoint_llist_node_t *o, **i;
|
apoint_llist_node_t *o, **i;
|
||||||
|
|
||||||
o = (apoint_llist_node_t *) malloc(sizeof(apoint_llist_node_t));
|
o = (apoint_llist_node_t *) malloc(sizeof(apoint_llist_node_t));
|
||||||
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
||||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||||
|
o->note = note;
|
||||||
o->state = state;
|
o->state = state;
|
||||||
o->start = start;
|
o->start = start;
|
||||||
o->dur = dur;
|
o->dur = dur;
|
||||||
@ -192,12 +194,12 @@ apoint_add(void)
|
|||||||
apoint_start =
|
apoint_start =
|
||||||
date2sec(*calendar_get_slctd_day(), heures,
|
date2sec(*calendar_get_slctd_day(), heures,
|
||||||
minutes);
|
minutes);
|
||||||
apoint_pointeur = apoint_new(item_mesg, apoint_start,
|
apoint_pointeur = apoint_new(item_mesg, 0L, apoint_start,
|
||||||
min2sec(apoint_duration), 0L);
|
min2sec(apoint_duration), 0L);
|
||||||
if (notify_bar())
|
if (notify_bar())
|
||||||
notify_check_added(item_mesg, apoint_start, 0L);
|
notify_check_added(item_mesg, apoint_start, 0L);
|
||||||
} else
|
} else
|
||||||
event_pointeur = event_new(item_mesg,
|
event_pointeur = event_new(item_mesg, 0L,
|
||||||
date2sec(*calendar_get_slctd_day(), 12, 0), Id);
|
date2sec(*calendar_get_slctd_day(), 12, 0), Id);
|
||||||
|
|
||||||
if (hilt == 0)
|
if (hilt == 0)
|
||||||
@ -317,6 +319,9 @@ apoint_write(apoint_llist_node_t *o, FILE * f)
|
|||||||
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year,
|
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year,
|
||||||
lt->tm_hour, lt->tm_min);
|
lt->tm_hour, lt->tm_min);
|
||||||
|
|
||||||
|
if (o->note != NULL)
|
||||||
|
fprintf(f, ">%s ", o->note);
|
||||||
|
|
||||||
if (o->state & APOINT_NOTIFY)
|
if (o->state & APOINT_NOTIFY)
|
||||||
fprintf(f, "!");
|
fprintf(f, "!");
|
||||||
else
|
else
|
||||||
@ -326,7 +331,7 @@ apoint_write(apoint_llist_node_t *o, FILE * f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
apoint_llist_node_t *
|
apoint_llist_node_t *
|
||||||
apoint_scan(FILE * f, struct tm start, struct tm end, char state)
|
apoint_scan(FILE * f, struct tm start, struct tm end, char state, char *note)
|
||||||
{
|
{
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
char buf[MESG_MAXSIZE], *nl;
|
char buf[MESG_MAXSIZE], *nl;
|
||||||
@ -355,29 +360,37 @@ apoint_scan(FILE * f, struct tm start, struct tm end, char state)
|
|||||||
fputs(_("FATAL ERROR in apoint_scan: date error in the appointment\n"), stderr);
|
fputs(_("FATAL ERROR in apoint_scan: date error in the appointment\n"), stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return apoint_new(buf, tstart, tend - tstart, state);
|
return (apoint_new(buf, note, tstart, tend - tstart, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
void apoint_delete_bynum(long start, unsigned num)
|
void
|
||||||
|
apoint_delete_bynum(long start, unsigned num, int only_note)
|
||||||
{
|
{
|
||||||
unsigned n;
|
unsigned n;
|
||||||
int need_check_notify = 0;
|
int need_check_notify = 0;
|
||||||
apoint_llist_node_t *i, **iptr;
|
apoint_llist_node_t *i, **iptr;
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&(alist_p->mutex));
|
pthread_mutex_lock(&(alist_p->mutex));
|
||||||
iptr = &alist_p->root;
|
iptr = &alist_p->root;
|
||||||
for (i = alist_p->root; i != 0; i = i->next) {
|
for (i = alist_p->root; i != 0; i = i->next) {
|
||||||
if (apoint_inday(i, start)) {
|
if (apoint_inday(i, start)) {
|
||||||
if (n == num) {
|
if (n == num) {
|
||||||
|
if (only_note)
|
||||||
|
erase_note(&i->note);
|
||||||
|
else {
|
||||||
if (notify_bar())
|
if (notify_bar())
|
||||||
need_check_notify = notify_same_item(i->start);
|
need_check_notify =
|
||||||
|
notify_same_item(i->start);
|
||||||
*iptr = i->next;
|
*iptr = i->next;
|
||||||
free(i->mesg);
|
free(i->mesg);
|
||||||
|
if (i->note != NULL)
|
||||||
|
erase_note(&i->note);
|
||||||
free(i);
|
free(i);
|
||||||
pthread_mutex_unlock(&(alist_p->mutex));
|
pthread_mutex_unlock(&(alist_p->mutex));
|
||||||
if (need_check_notify) notify_check_next_app();
|
if (need_check_notify)
|
||||||
|
notify_check_next_app();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
@ -414,7 +427,8 @@ get_item_line(int item_nb, int nb_events_inday)
|
|||||||
* Update (if necessary) the first displayed pad line to make the
|
* Update (if necessary) the first displayed pad line to make the
|
||||||
* appointment panel scroll down next time pnoutrefresh is called.
|
* appointment panel scroll down next time pnoutrefresh is called.
|
||||||
*/
|
*/
|
||||||
void apoint_scroll_pad_down(int nb_events_inday, int win_length)
|
void
|
||||||
|
apoint_scroll_pad_down(int nb_events_inday, int win_length)
|
||||||
{
|
{
|
||||||
int pad_last_line = 0;
|
int pad_last_line = 0;
|
||||||
int item_first_line = 0, item_last_line = 0;
|
int item_first_line = 0, item_last_line = 0;
|
||||||
@ -435,7 +449,8 @@ void apoint_scroll_pad_down(int nb_events_inday, int win_length)
|
|||||||
* Update (if necessary) the first displayed pad line to make the
|
* Update (if necessary) the first displayed pad line to make the
|
||||||
* appointment panel scroll up next time pnoutrefresh is called.
|
* appointment panel scroll up next time pnoutrefresh is called.
|
||||||
*/
|
*/
|
||||||
void apoint_scroll_pad_up(int nb_events_inday)
|
void
|
||||||
|
apoint_scroll_pad_up(int nb_events_inday)
|
||||||
{
|
{
|
||||||
int item_first_line = 0;
|
int item_first_line = 0;
|
||||||
|
|
||||||
@ -476,8 +491,8 @@ apoint_check_next(struct notify_app_s *app, long start)
|
|||||||
* Returns a structure of type apoint_llist_t given a structure of type
|
* Returns a structure of type apoint_llist_t given a structure of type
|
||||||
* recur_apoint_s
|
* recur_apoint_s
|
||||||
*/
|
*/
|
||||||
apoint_llist_node_t *apoint_recur_s2apoint_s(
|
apoint_llist_node_t *
|
||||||
recur_apoint_llist_node_t *p)
|
apoint_recur_s2apoint_s(recur_apoint_llist_node_t *p)
|
||||||
{
|
{
|
||||||
apoint_llist_node_t *a;
|
apoint_llist_node_t *a;
|
||||||
|
|
||||||
@ -589,17 +604,3 @@ apoint_update_panel(window_t *winapp, int which_pan)
|
|||||||
winapp->y + title_lines + 1, winapp->x + bordr,
|
winapp->y + title_lines + 1, winapp->x + bordr,
|
||||||
winapp->y + winapp->h - 2*bordr, winapp->x + winapp->w - 3*bordr);
|
winapp->y + winapp->h - 2*bordr, winapp->x + winapp->w - 3*bordr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attach a note to an appointment or event */
|
|
||||||
void
|
|
||||||
apoint_edit_note(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* View a note previously attached to an appointment or event */
|
|
||||||
void
|
|
||||||
apoint_view_note(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
12
src/apoint.h
12
src/apoint.h
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: apoint.h,v 1.10 2007/12/30 16:27:58 culot Exp $ */
|
/* $calcurse: apoint.h,v 1.11 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -59,22 +59,20 @@ void apoint_hilt_set(int);
|
|||||||
void apoint_hilt_decrease(void);
|
void apoint_hilt_decrease(void);
|
||||||
void apoint_hilt_increase(void);
|
void apoint_hilt_increase(void);
|
||||||
int apoint_hilt(void);
|
int apoint_hilt(void);
|
||||||
apoint_llist_node_t *apoint_new(char *, long, long, char);
|
apoint_llist_node_t *apoint_new(char *, char *, long, long, char);
|
||||||
void apoint_add(void);
|
void apoint_add(void);
|
||||||
void apoint_delete(conf_t *, unsigned *, unsigned *);
|
void apoint_delete(conf_t *, unsigned *, unsigned *);
|
||||||
unsigned apoint_inday(apoint_llist_node_t *, long);
|
unsigned apoint_inday(apoint_llist_node_t *, long);
|
||||||
void apoint_sec2str(apoint_llist_node_t *, int, long,
|
void apoint_sec2str(apoint_llist_node_t *, int, long,
|
||||||
char *, char *);
|
char *, char *);
|
||||||
void apoint_write(apoint_llist_node_t *, FILE *);
|
void apoint_write(apoint_llist_node_t *, FILE *);
|
||||||
apoint_llist_node_t *apoint_scan(FILE *, struct tm, struct tm, char);
|
apoint_llist_node_t *apoint_scan(FILE *, struct tm, struct tm, char, char *);
|
||||||
void apoint_delete_bynum(long, unsigned);
|
void apoint_delete_bynum(long, unsigned, int);
|
||||||
void apoint_scroll_pad_down(int, int);
|
void apoint_scroll_pad_down(int, int);
|
||||||
void apoint_scroll_pad_up(int);
|
void apoint_scroll_pad_up(int);
|
||||||
struct notify_app_s *apoint_check_next(struct notify_app_s *, long);
|
struct notify_app_s *apoint_check_next(struct notify_app_s *, long);
|
||||||
apoint_llist_node_t *apoint_recur_s2apoint_s(recur_apoint_llist_node_t *);
|
apoint_llist_node_t *apoint_recur_s2apoint_s(recur_apoint_llist_node_t *);
|
||||||
void apoint_switch_notify(void);
|
void apoint_switch_notify(void);
|
||||||
void apoint_update_panel(window_t *, int);
|
void apoint_update_panel(window_t *, int);
|
||||||
void apoint_edit_note(void);
|
|
||||||
void apoint_view_note(void);
|
|
||||||
|
|
||||||
#endif /* CALCURSE_APOINT_H */
|
#endif /* CALCURSE_APOINT_H */
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: calcurse.c,v 1.59 2007/12/30 16:27:58 culot Exp $ */
|
/* $calcurse: calcurse.c,v 1.60 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -350,7 +350,7 @@ main(int argc, char **argv)
|
|||||||
case 'n':
|
case 'n':
|
||||||
/* Attach a note to an item, create it if necessary */
|
/* Attach a note to an item, create it if necessary */
|
||||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||||
apoint_edit_note();
|
day_edit_note(conf.editor);
|
||||||
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
||||||
todo_edit_note(conf.editor);
|
todo_edit_note(conf.editor);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
@ -359,7 +359,7 @@ main(int argc, char **argv)
|
|||||||
case '>':
|
case '>':
|
||||||
/* View a note previously attached to an item */
|
/* View a note previously attached to an item */
|
||||||
if (wins_slctd() == APP && apoint_hilt() != 0)
|
if (wins_slctd() == APP && apoint_hilt() != 0)
|
||||||
apoint_view_note();
|
day_view_note(conf.pager);
|
||||||
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
else if (wins_slctd() == TOD && todo_hilt() != 0)
|
||||||
todo_view_note(conf.pager);
|
todo_view_note(conf.pager);
|
||||||
break;
|
break;
|
||||||
|
203
src/day.c
203
src/day.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: day.c,v 1.31 2007/12/30 16:27:59 culot Exp $ */
|
/* $calcurse: day.c,v 1.32 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -56,12 +56,13 @@ day_free_list(void)
|
|||||||
|
|
||||||
/* Add an event in the current day list */
|
/* Add an event in the current day list */
|
||||||
static struct day_item_s *
|
static struct day_item_s *
|
||||||
day_add_event(int type, char *mesg, long day, int id)
|
day_add_event(int type, char *mesg, char *note, long day, int id)
|
||||||
{
|
{
|
||||||
struct day_item_s *o, **i;
|
struct day_item_s *o, **i;
|
||||||
o = (struct day_item_s *) malloc(sizeof(struct day_item_s));
|
o = (struct day_item_s *) malloc(sizeof(struct day_item_s));
|
||||||
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
||||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||||
|
o->note = note;
|
||||||
o->type = type;
|
o->type = type;
|
||||||
o->appt_dur = 0;
|
o->appt_dur = 0;
|
||||||
o->appt_pos = 0;
|
o->appt_pos = 0;
|
||||||
@ -81,8 +82,8 @@ day_add_event(int type, char *mesg, long day, int id)
|
|||||||
|
|
||||||
/* Add an appointment in the current day list. */
|
/* Add an appointment in the current day list. */
|
||||||
static struct day_item_s *
|
static struct day_item_s *
|
||||||
day_add_apoint(int type, char *mesg, long start, long dur, char state,
|
day_add_apoint(int type, char *mesg, char *note, long start, long dur,
|
||||||
int real_pos)
|
char state, int real_pos)
|
||||||
{
|
{
|
||||||
struct day_item_s *o, **i;
|
struct day_item_s *o, **i;
|
||||||
int insert_item = 0;
|
int insert_item = 0;
|
||||||
@ -90,6 +91,7 @@ day_add_apoint(int type, char *mesg, long start, long dur, char state,
|
|||||||
o = (struct day_item_s *) malloc(sizeof(struct day_item_s));
|
o = (struct day_item_s *) malloc(sizeof(struct day_item_s));
|
||||||
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
||||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||||
|
o->note = note;
|
||||||
o->start = start;
|
o->start = start;
|
||||||
o->appt_dur = dur;
|
o->appt_dur = dur;
|
||||||
o->appt_pos = real_pos;
|
o->appt_pos = real_pos;
|
||||||
@ -131,7 +133,8 @@ day_store_events(long date)
|
|||||||
for (j = eventlist; j != 0; j = j->next) {
|
for (j = eventlist; j != 0; j = j->next) {
|
||||||
if (event_inday(j, date)) {
|
if (event_inday(j, date)) {
|
||||||
e_nb++;
|
e_nb++;
|
||||||
ptr = day_add_event(EVNT, j->mesg, j->day, j->id);
|
ptr = day_add_event(EVNT, j->mesg, j->note, j->day,
|
||||||
|
j->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +159,8 @@ day_store_recur_events(long date)
|
|||||||
if (recur_item_inday(j->day, j->exc, j->rpt->type, j->rpt->freq,
|
if (recur_item_inday(j->day, j->exc, j->rpt->type, j->rpt->freq,
|
||||||
j->rpt->until, date)) {
|
j->rpt->until, date)) {
|
||||||
e_nb++;
|
e_nb++;
|
||||||
ptr = day_add_event(RECUR_EVNT, j->mesg, j->day, j->id);
|
ptr = day_add_event(RECUR_EVNT, j->mesg, j->note,
|
||||||
|
j->day, j->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +185,8 @@ day_store_apoints(long date)
|
|||||||
for (j = alist_p->root; j != 0; j = j->next) {
|
for (j = alist_p->root; j != 0; j = j->next) {
|
||||||
if (apoint_inday(j, date)) {
|
if (apoint_inday(j, date)) {
|
||||||
a_nb++;
|
a_nb++;
|
||||||
ptr = day_add_apoint(APPT, j->mesg, j->start, j->dur,
|
ptr = day_add_apoint(APPT, j->mesg, j->note, j->start,
|
||||||
j->state, 0);
|
j->dur, j->state, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&(alist_p->mutex));
|
pthread_mutex_unlock(&(alist_p->mutex));
|
||||||
@ -210,9 +214,8 @@ day_store_recur_apoints(long date)
|
|||||||
if ((real_start = recur_item_inday(j->start, j->exc,
|
if ((real_start = recur_item_inday(j->start, j->exc,
|
||||||
j->rpt->type, j->rpt->freq, j->rpt->until, date)) ){
|
j->rpt->type, j->rpt->freq, j->rpt->until, date)) ){
|
||||||
a_nb++;
|
a_nb++;
|
||||||
ptr = day_add_apoint(
|
ptr = day_add_apoint(RECUR_APPT, j->mesg, j->note,
|
||||||
RECUR_APPT, j->mesg, real_start, j->dur,
|
real_start, j->dur, j->state, n);
|
||||||
j->state, n);
|
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,8 +400,8 @@ day_write_pad(long date, int width, int length, int incolor)
|
|||||||
day_saved_item->type = p->type;
|
day_saved_item->type = p->type;
|
||||||
day_saved_item->mesg = p->mesg;
|
day_saved_item->mesg = p->mesg;
|
||||||
}
|
}
|
||||||
display_item(item_number - incolor, p->mesg, recur, 0,
|
display_item(item_number - incolor, p->mesg, recur,
|
||||||
width - 7, line, x_pos);
|
(p->note != NULL) ? 1 : 0, width - 7, line, x_pos);
|
||||||
line++;
|
line++;
|
||||||
draw_line = true;
|
draw_line = true;
|
||||||
} else {
|
} else {
|
||||||
@ -420,9 +423,10 @@ day_write_pad(long date, int width, int length, int incolor)
|
|||||||
}
|
}
|
||||||
display_item_date(item_number - incolor, &a, p->type,
|
display_item_date(item_number - incolor, &a, p->type,
|
||||||
date, line + 1, x_pos);
|
date, line + 1, x_pos);
|
||||||
display_item(item_number - incolor, p->mesg, 0, 0,
|
display_item(item_number - incolor, p->mesg, 0,
|
||||||
width - 7, line + 2, x_pos);
|
(p->note != NULL) ? 1 : 0, width - 7, line + 2,
|
||||||
line = line + 3;
|
x_pos);
|
||||||
|
line += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,9 +489,41 @@ void day_popup_item(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update an existing item. */
|
||||||
|
static void update_item(long date, int item_num, struct day_item_s *p,
|
||||||
|
struct rpt_s *rpt)
|
||||||
|
{
|
||||||
|
recur_apoint_llist_node_t *ra_new;
|
||||||
|
|
||||||
|
day_erase_item(date, item_num, 1);
|
||||||
|
|
||||||
|
switch (p->type) {
|
||||||
|
case RECUR_EVNT:
|
||||||
|
recur_event_new(p->mesg, p->note, p->start, p->evnt_id,
|
||||||
|
rpt->type, rpt->freq, rpt->until, NULL);
|
||||||
|
break;
|
||||||
|
case EVNT:
|
||||||
|
event_new(p->mesg, p->note, p->start, p->evnt_id);
|
||||||
|
break;
|
||||||
|
case RECUR_APPT:
|
||||||
|
ra_new = recur_apoint_new(p->mesg, p->note, p->start,
|
||||||
|
p->appt_dur, p->state, rpt->type, rpt->freq, rpt->until,
|
||||||
|
NULL);
|
||||||
|
if (notify_bar())
|
||||||
|
notify_check_repeated(ra_new);
|
||||||
|
break;
|
||||||
|
case APPT:
|
||||||
|
apoint_new(p->mesg, p->note, p->start, p->appt_dur, p->state);
|
||||||
|
if (notify_bar())
|
||||||
|
notify_check_added(p->mesg, p->start, p->state);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Request the user to enter a new time. */
|
/* Request the user to enter a new time. */
|
||||||
static char *
|
static char *
|
||||||
day_edit_time(long time) {
|
day_edit_time(long time)
|
||||||
|
{
|
||||||
char *timestr;
|
char *timestr;
|
||||||
char *msg_time = _("Enter the new time ([hh:mm] or [h:mm]) : ");
|
char *msg_time = _("Enter the new time ([hh:mm] or [h:mm]) : ");
|
||||||
char *enter_str = _("Press [Enter] to continue");
|
char *enter_str = _("Press [Enter] to continue");
|
||||||
@ -521,7 +557,7 @@ day_edit_item(void)
|
|||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
time_t t;
|
time_t t;
|
||||||
date_t new_date;
|
date_t new_date;
|
||||||
recur_apoint_llist_node_t *ra, *ra_new;
|
recur_apoint_llist_node_t *ra;
|
||||||
long date, newtime = 0;
|
long date, newtime = 0;
|
||||||
int cancel, ch = 0, valid_date = 0, newfreq = 0, date_entered = 0;
|
int cancel, ch = 0, valid_date = 0, newfreq = 0, date_entered = 0;
|
||||||
int newmonth, newday, newyear;
|
int newmonth, newday, newyear;
|
||||||
@ -697,28 +733,7 @@ day_edit_item(void)
|
|||||||
rpt->type = recur_char2def(ch);
|
rpt->type = recur_char2def(ch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
day_erase_item(date, item_num, 1);
|
update_item(date, item_num, p, rpt);
|
||||||
|
|
||||||
switch (p->type) {
|
|
||||||
case RECUR_EVNT:
|
|
||||||
recur_event_new(p->mesg, p->start, p->evnt_id,
|
|
||||||
rpt->type, rpt->freq, rpt->until, NULL);
|
|
||||||
break;
|
|
||||||
case EVNT:
|
|
||||||
event_new(p->mesg, p->start, p->evnt_id);
|
|
||||||
break;
|
|
||||||
case RECUR_APPT:
|
|
||||||
ra_new = recur_apoint_new(p->mesg, p->start, p->appt_dur,
|
|
||||||
p->state, rpt->type, rpt->freq, rpt->until, NULL);
|
|
||||||
if (notify_bar())
|
|
||||||
notify_check_repeated(ra_new);
|
|
||||||
break;
|
|
||||||
case APPT:
|
|
||||||
apoint_new(p->mesg, p->start, p->appt_dur, p->state);
|
|
||||||
if (notify_bar())
|
|
||||||
notify_check_added(p->mesg, p->start, p->state);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -727,26 +742,48 @@ day_edit_item(void)
|
|||||||
* recurrent appointments and appointments) and then to test the
|
* recurrent appointments and appointments) and then to test the
|
||||||
* type of the item to be deleted.
|
* type of the item to be deleted.
|
||||||
*/
|
*/
|
||||||
int day_erase_item(long date, int item_number, int force_erase) {
|
int
|
||||||
int ch = 0;
|
day_erase_item(long date, int item_number, int force_erase)
|
||||||
unsigned delete_whole;
|
{
|
||||||
struct day_item_s *p;
|
struct day_item_s *p;
|
||||||
char *erase_warning =
|
char *erase_warning =
|
||||||
_("This item is recurrent. "
|
_("This item is recurrent. "
|
||||||
"Delete (a)ll occurences or just this (o)ne ?");
|
"Delete (a)ll occurences or just this (o)ne ?");
|
||||||
char *erase_choice =
|
char *note_warning =
|
||||||
_("[a/o] ");
|
_("This item has a note attached to it. "
|
||||||
|
"Delete (i)tem or just its (n)ote ?");
|
||||||
if (force_erase)
|
char *note_choice = _("[i/n] ");
|
||||||
ch = 'a';
|
char *erase_choice = _("[a/o] ");
|
||||||
|
int ch = 0, only_note, has_note, ans = 0;
|
||||||
|
unsigned delete_whole;
|
||||||
|
|
||||||
p = day_get_item(item_number);
|
p = day_get_item(item_number);
|
||||||
|
if (force_erase) {
|
||||||
|
ch = 'a';
|
||||||
|
only_note = 0;
|
||||||
|
} else {
|
||||||
|
has_note = (p->note != NULL ) ? 1 : 0;
|
||||||
|
if (has_note == 0)
|
||||||
|
ans = 'i';
|
||||||
|
while (ans != 'i' && ans != 'n') {
|
||||||
|
status_mesg(note_warning, note_choice);
|
||||||
|
ans = wgetch(win[STA].p);
|
||||||
|
}
|
||||||
|
if (ans == 'i')
|
||||||
|
only_note = 0;
|
||||||
|
else
|
||||||
|
only_note = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (p->type == EVNT) {
|
if (p->type == EVNT) {
|
||||||
event_delete_bynum(date, day_item_nb(date, item_number, EVNT));
|
event_delete_bynum(date, day_item_nb(date, item_number, EVNT),
|
||||||
|
only_note);
|
||||||
} else if (p->type == APPT) {
|
} else if (p->type == APPT) {
|
||||||
apoint_delete_bynum(date, day_item_nb(date, item_number, APPT));
|
apoint_delete_bynum(date, day_item_nb(date, item_number, APPT),
|
||||||
|
only_note);
|
||||||
} else {
|
} else {
|
||||||
|
if (only_note)
|
||||||
|
ch = 'a';
|
||||||
while ( (ch != 'a') && (ch != 'o') && (ch != ESCAPE)) {
|
while ( (ch != 'a') && (ch != 'o') && (ch != ESCAPE)) {
|
||||||
status_mesg(erase_warning, erase_choice);
|
status_mesg(erase_warning, erase_choice);
|
||||||
ch = wgetch(win[STA].p);
|
ch = wgetch(win[STA].p);
|
||||||
@ -761,12 +798,13 @@ int day_erase_item(long date, int item_number, int force_erase) {
|
|||||||
if (p->type == RECUR_EVNT) {
|
if (p->type == RECUR_EVNT) {
|
||||||
recur_event_erase(date,
|
recur_event_erase(date,
|
||||||
day_item_nb(date, item_number, RECUR_EVNT),
|
day_item_nb(date, item_number, RECUR_EVNT),
|
||||||
delete_whole);
|
delete_whole, only_note);
|
||||||
} else {
|
} else {
|
||||||
recur_apoint_erase(date, p->appt_pos, delete_whole);
|
recur_apoint_erase(date, p->appt_pos, delete_whole,
|
||||||
|
only_note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p->type;
|
return (p->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a structure containing the selected item. */
|
/* Returns a structure containing the selected item. */
|
||||||
@ -801,3 +839,60 @@ day_item_nb(long date, int day_num, int type)
|
|||||||
|
|
||||||
return (nb_item[type - 1]);
|
return (nb_item[type - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attach a note to an appointment or event. */
|
||||||
|
void
|
||||||
|
day_edit_note(char *editor)
|
||||||
|
{
|
||||||
|
struct day_item_s *p;
|
||||||
|
recur_apoint_llist_node_t *ra;
|
||||||
|
struct recur_event_s *re;
|
||||||
|
struct rpt_s *rpt;
|
||||||
|
char fullname[BUFSIZ];
|
||||||
|
char *filename;
|
||||||
|
long date;
|
||||||
|
int item_num;
|
||||||
|
|
||||||
|
item_num = apoint_hilt();
|
||||||
|
p = day_get_item(item_num);
|
||||||
|
if (p->note == NULL) {
|
||||||
|
if ((filename = new_tempfile(path_notes, NOTESIZ))
|
||||||
|
!= NULL)
|
||||||
|
p->note = filename;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
snprintf(fullname, BUFSIZ, "%s%s", path_notes, p->note);
|
||||||
|
wins_launch_external(fullname, editor);
|
||||||
|
|
||||||
|
date = calendar_get_slctd_day_sec();
|
||||||
|
switch (p->type) {
|
||||||
|
case RECUR_EVNT:
|
||||||
|
re = recur_get_event(date,
|
||||||
|
day_item_nb(date, item_num, RECUR_EVNT));
|
||||||
|
rpt = re->rpt;
|
||||||
|
break;
|
||||||
|
case RECUR_APPT:
|
||||||
|
ra = recur_get_apoint(date,
|
||||||
|
day_item_nb(date, item_num, RECUR_APPT));
|
||||||
|
rpt = ra->rpt;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rpt = NULL;
|
||||||
|
}
|
||||||
|
update_item(date, item_num, p, rpt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* View a note previously attached to an appointment or event */
|
||||||
|
void
|
||||||
|
day_view_note(char *pager)
|
||||||
|
{
|
||||||
|
struct day_item_s *p;
|
||||||
|
char fullname[BUFSIZ];
|
||||||
|
|
||||||
|
p = day_get_item(apoint_hilt());
|
||||||
|
if (p->note == NULL)
|
||||||
|
return;
|
||||||
|
snprintf(fullname, BUFSIZ, "%s%s", path_notes, p->note);
|
||||||
|
wins_launch_external(fullname, pager);
|
||||||
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: day.h,v 1.15 2007/08/15 15:37:10 culot Exp $ */
|
/* $calcurse: day.h,v 1.16 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -50,6 +50,7 @@ struct day_item_s {
|
|||||||
int appt_pos; /* real position in recurrent list */
|
int appt_pos; /* real position in recurrent list */
|
||||||
char state; /* appointment state */
|
char state; /* appointment state */
|
||||||
char *mesg; /* item description */
|
char *mesg; /* item description */
|
||||||
|
char *note; /* note attached to item */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct day_saved_item_s {
|
struct day_saved_item_s {
|
||||||
@ -68,5 +69,7 @@ void day_edit_item(void);
|
|||||||
int day_erase_item(long, int, int);
|
int day_erase_item(long, int, int);
|
||||||
struct day_item_s *day_get_item(int);
|
struct day_item_s *day_get_item(int);
|
||||||
int day_item_nb(long, int, int);
|
int day_item_nb(long, int, int);
|
||||||
|
void day_edit_note(char *);
|
||||||
|
void day_view_note(char *);
|
||||||
|
|
||||||
#endif /* CALCURSE_DAY_H */
|
#endif /* CALCURSE_DAY_H */
|
||||||
|
27
src/event.c
27
src/event.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: event.c,v 1.4 2007/07/28 13:11:42 culot Exp $ */
|
/* $calcurse: event.c,v 1.5 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,13 +31,14 @@
|
|||||||
|
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
|
||||||
struct event_s *eventlist;
|
struct event_s *eventlist;
|
||||||
|
|
||||||
/* Create a new event */
|
/* Create a new event */
|
||||||
struct event_s *
|
struct event_s *
|
||||||
event_new(char *mesg, long day, int id)
|
event_new(char *mesg, char *note, long day, int id)
|
||||||
{
|
{
|
||||||
struct event_s *o, **i;
|
struct event_s *o, **i;
|
||||||
o = (struct event_s *) malloc(sizeof(struct event_s));
|
o = (struct event_s *) malloc(sizeof(struct event_s));
|
||||||
@ -45,6 +46,7 @@ event_new(char *mesg, long day, int id)
|
|||||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||||
o->day = day;
|
o->day = day;
|
||||||
o->id = id;
|
o->id = id;
|
||||||
|
o->note = note;
|
||||||
i = &eventlist;
|
i = &eventlist;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (*i == 0 || (*i)->day > day) {
|
if (*i == 0 || (*i)->day > day) {
|
||||||
@ -76,13 +78,16 @@ event_write(struct event_s *o, FILE * f)
|
|||||||
|
|
||||||
t = o->day;
|
t = o->day;
|
||||||
lt = localtime(&t);
|
lt = localtime(&t);
|
||||||
fprintf(f, "%02u/%02u/%04u [%d] %s\n",
|
fprintf(f, "%02u/%02u/%04u [%d] ",
|
||||||
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year, o->id, o->mesg);
|
lt->tm_mon + 1, lt->tm_mday, 1900 + lt->tm_year, o->id);
|
||||||
|
if (o->note != NULL)
|
||||||
|
fprintf(f, ">%s ", o->note);
|
||||||
|
fprintf(f, "%s\n", o->mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load the events from file */
|
/* Load the events from file */
|
||||||
struct event_s *
|
struct event_s *
|
||||||
event_scan(FILE * f, struct tm start, int id)
|
event_scan(FILE * f, struct tm start, int id, char *note)
|
||||||
{
|
{
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
char buf[MESG_MAXSIZE], *nl;
|
char buf[MESG_MAXSIZE], *nl;
|
||||||
@ -109,12 +114,12 @@ event_scan(FILE * f, struct tm start, int id)
|
|||||||
fputs(_("FATAL ERROR in event_scan: date error in the event\n"), stderr);
|
fputs(_("FATAL ERROR in event_scan: date error in the event\n"), stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return event_new(buf, tstart, id);
|
return (event_new(buf, note, tstart, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete an event from the list */
|
/* Delete an event from the list */
|
||||||
void
|
void
|
||||||
event_delete_bynum(long start, unsigned num)
|
event_delete_bynum(long start, unsigned num, int only_note)
|
||||||
{
|
{
|
||||||
unsigned n;
|
unsigned n;
|
||||||
struct event_s *i, **iptr;
|
struct event_s *i, **iptr;
|
||||||
@ -124,9 +129,15 @@ event_delete_bynum(long start, unsigned num)
|
|||||||
for (i = eventlist; i != 0; i = i->next) {
|
for (i = eventlist; i != 0; i = i->next) {
|
||||||
if (event_inday(i, start)) {
|
if (event_inday(i, start)) {
|
||||||
if (n == num) {
|
if (n == num) {
|
||||||
|
if (only_note)
|
||||||
|
erase_note(&i->note);
|
||||||
|
else {
|
||||||
*iptr = i->next;
|
*iptr = i->next;
|
||||||
free(i->mesg);
|
free(i->mesg);
|
||||||
|
if (i->note != NULL)
|
||||||
|
erase_note(&i->note);
|
||||||
free(i);
|
free(i);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
|
10
src/event.h
10
src/event.h
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: event.h,v 1.3 2007/12/30 16:27:59 culot Exp $ */
|
/* $calcurse: event.h,v 1.4 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2006 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -40,10 +40,10 @@ struct event_s {
|
|||||||
|
|
||||||
extern struct event_s *eventlist;
|
extern struct event_s *eventlist;
|
||||||
|
|
||||||
struct event_s *event_new(char *, long, int);
|
struct event_s *event_new(char *, char *, long, int);
|
||||||
unsigned event_inday(struct event_s *, long);
|
unsigned event_inday(struct event_s *, long);
|
||||||
void event_write(struct event_s *, FILE *);
|
void event_write(struct event_s *, FILE *);
|
||||||
struct event_s *event_scan(FILE *, struct tm, int);
|
struct event_s *event_scan(FILE *, struct tm, int, char *);
|
||||||
void event_delete_bynum(long, unsigned);
|
void event_delete_bynum(long, unsigned, int);
|
||||||
|
|
||||||
#endif /* CALCURSE_EVENT_H */
|
#endif /* CALCURSE_EVENT_H */
|
||||||
|
31
src/io.c
31
src/io.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: io.c,v 1.24 2007/12/30 16:27:59 culot Exp $ */
|
/* $calcurse: io.c,v 1.25 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -508,7 +508,8 @@ io_save_cal(conf_t *conf)
|
|||||||
* appointments first, and then the events.
|
* appointments first, and then the events.
|
||||||
* Recursive items are written first.
|
* Recursive items are written first.
|
||||||
*/
|
*/
|
||||||
if (show_bar) progress_bar(PROGRESS_BAR_SAVE, 2);
|
if (show_bar)
|
||||||
|
progress_bar(PROGRESS_BAR_SAVE, 2);
|
||||||
data_file = fopen(path_apts, "w");
|
data_file = fopen(path_apts, "w");
|
||||||
if (data_file == (FILE *) 0)
|
if (data_file == (FILE *) 0)
|
||||||
status_mesg(access_pb, "");
|
status_mesg(access_pb, "");
|
||||||
@ -549,6 +550,7 @@ io_load_app(void)
|
|||||||
int id = 0;
|
int id = 0;
|
||||||
int freq;
|
int freq;
|
||||||
char type, state = 0L;
|
char type, state = 0L;
|
||||||
|
char note[NOTESIZ + 1], *notep;
|
||||||
char *error =
|
char *error =
|
||||||
_("FATAL ERROR in io_load_app: wrong format in the appointment or event\n");
|
_("FATAL ERROR in io_load_app: wrong format in the appointment or event\n");
|
||||||
|
|
||||||
@ -642,6 +644,18 @@ io_load_app(void)
|
|||||||
} else
|
} else
|
||||||
ungetc(c, data_file);
|
ungetc(c, data_file);
|
||||||
|
|
||||||
|
/* Check if a note is attached to the item. */
|
||||||
|
c = getc(data_file);
|
||||||
|
if (c == '>') {
|
||||||
|
fgets(note, NOTESIZ + 1, data_file);
|
||||||
|
note[NOTESIZ] = '\0';
|
||||||
|
notep = strdup(note);
|
||||||
|
getc(data_file);
|
||||||
|
} else {
|
||||||
|
notep = NULL;
|
||||||
|
ungetc(c, data_file);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Last: read the item description and load it into its
|
* Last: read the item description and load it into its
|
||||||
* corresponding linked list, depending on the item type.
|
* corresponding linked list, depending on the item type.
|
||||||
@ -659,16 +673,16 @@ io_load_app(void)
|
|||||||
}
|
}
|
||||||
if (is_recursive) {
|
if (is_recursive) {
|
||||||
recur_apoint_scan(data_file, start, end,
|
recur_apoint_scan(data_file, start, end,
|
||||||
type, freq, until, exc, state);
|
type, freq, until, notep, exc, state);
|
||||||
} else {
|
} else {
|
||||||
apoint_scan(data_file, start, end, state);
|
apoint_scan(data_file, start, end, state, notep);
|
||||||
}
|
}
|
||||||
} else if (is_event) {
|
} else if (is_event) {
|
||||||
if (is_recursive) {
|
if (is_recursive) {
|
||||||
recur_event_scan(data_file, start, id,
|
recur_event_scan(data_file, start, id, type,
|
||||||
type, freq, until, exc);
|
freq, until, notep, exc);
|
||||||
} else {
|
} else {
|
||||||
event_scan(data_file, start, id);
|
event_scan(data_file, start, id, notep);
|
||||||
}
|
}
|
||||||
} else { /* NOT REACHED */
|
} else { /* NOT REACHED */
|
||||||
fputs(error, stderr);
|
fputs(error, stderr);
|
||||||
@ -710,7 +724,6 @@ io_load_todo(void)
|
|||||||
if (c == '>') {
|
if (c == '>') {
|
||||||
fgets(note, NOTESIZ + 1, data_file);
|
fgets(note, NOTESIZ + 1, data_file);
|
||||||
note[NOTESIZ] = '\0';
|
note[NOTESIZ] = '\0';
|
||||||
fprintf(stderr, "note: [%s]\n", note);
|
|
||||||
getc(data_file);
|
getc(data_file);
|
||||||
} else
|
} else
|
||||||
note[0] = '\0';
|
note[0] = '\0';
|
||||||
|
102
src/recur.c
102
src/recur.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: recur.c,v 1.31 2007/12/10 19:03:23 culot Exp $ */
|
/* $calcurse: recur.c,v 1.32 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -39,7 +39,8 @@
|
|||||||
recur_apoint_llist_t *recur_alist_p;
|
recur_apoint_llist_t *recur_alist_p;
|
||||||
struct recur_event_s *recur_elist;
|
struct recur_event_s *recur_elist;
|
||||||
|
|
||||||
int recur_apoint_llist_init(void)
|
int
|
||||||
|
recur_apoint_llist_init(void)
|
||||||
{
|
{
|
||||||
recur_alist_p = (recur_apoint_llist_t *)
|
recur_alist_p = (recur_apoint_llist_t *)
|
||||||
malloc(sizeof(recur_apoint_llist_t));
|
malloc(sizeof(recur_apoint_llist_t));
|
||||||
@ -51,8 +52,8 @@ int recur_apoint_llist_init(void)
|
|||||||
|
|
||||||
/* Insert a new recursive appointment in the general linked list */
|
/* Insert a new recursive appointment in the general linked list */
|
||||||
recur_apoint_llist_node_t *
|
recur_apoint_llist_node_t *
|
||||||
recur_apoint_new(char *mesg, long start, long dur, char state, int type,
|
recur_apoint_new(char *mesg, char *note, long start, long dur, char state,
|
||||||
int freq, long until, struct days_s *except)
|
int type, int freq, long until, struct days_s *except)
|
||||||
{
|
{
|
||||||
recur_apoint_llist_node_t *o, **i;
|
recur_apoint_llist_node_t *o, **i;
|
||||||
o = (recur_apoint_llist_node_t *)
|
o = (recur_apoint_llist_node_t *)
|
||||||
@ -61,6 +62,7 @@ recur_apoint_new(char *mesg, long start, long dur, char state, int type,
|
|||||||
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
||||||
o->exc = (struct days_s *) malloc(sizeof(struct days_s));
|
o->exc = (struct days_s *) malloc(sizeof(struct days_s));
|
||||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||||
|
o->note = note;
|
||||||
o->start = start;
|
o->start = start;
|
||||||
o->state = state;
|
o->state = state;
|
||||||
o->dur = dur;
|
o->dur = dur;
|
||||||
@ -85,13 +87,15 @@ recur_apoint_new(char *mesg, long start, long dur, char state, int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Insert a new recursive event in the general linked list */
|
/* Insert a new recursive event in the general linked list */
|
||||||
struct recur_event_s *recur_event_new(char *mesg, long day, int id,
|
struct recur_event_s *
|
||||||
int type, int freq, long until, struct days_s *except)
|
recur_event_new(char *mesg, char *note, long day, int id, int type, int freq,
|
||||||
|
long until, struct days_s *except)
|
||||||
{
|
{
|
||||||
struct recur_event_s *o, **i;
|
struct recur_event_s *o, **i;
|
||||||
o = (struct recur_event_s *) malloc(sizeof(struct recur_event_s));
|
o = (struct recur_event_s *) malloc(sizeof(struct recur_event_s));
|
||||||
o->rpt = (struct rpt_s *) malloc(sizeof(struct rpt_s));
|
o->rpt = (struct rpt_s *) malloc(sizeof(struct rpt_s));
|
||||||
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
o->mesg = (char *) malloc(strlen(mesg) + 1);
|
||||||
|
o->note = note;
|
||||||
o->exc = (struct days_s *) malloc(sizeof(struct days_s));
|
o->exc = (struct days_s *) malloc(sizeof(struct days_s));
|
||||||
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
strncpy(o->mesg, mesg, strlen(mesg) + 1);
|
||||||
o->day = day;
|
o->day = day;
|
||||||
@ -147,7 +151,9 @@ recur_def2char(recur_types_t define)
|
|||||||
* Correspondance between the letters written in file and the defines
|
* Correspondance between the letters written in file and the defines
|
||||||
* concerning the recursive type.
|
* concerning the recursive type.
|
||||||
*/
|
*/
|
||||||
int recur_char2def(char type){
|
int
|
||||||
|
recur_char2def(char type)
|
||||||
|
{
|
||||||
int recur_def;
|
int recur_def;
|
||||||
char *error = _("FATAL ERROR in recur_char2def: unknown char\n");
|
char *error = _("FATAL ERROR in recur_char2def: unknown char\n");
|
||||||
|
|
||||||
@ -192,7 +198,7 @@ recur_write_exc(struct days_s *exc, FILE *f) {
|
|||||||
/* Load the recursive appointment description */
|
/* Load the recursive appointment description */
|
||||||
recur_apoint_llist_node_t *
|
recur_apoint_llist_node_t *
|
||||||
recur_apoint_scan(FILE * f, struct tm start, struct tm end, char type,
|
recur_apoint_scan(FILE * f, struct tm start, struct tm end, char type,
|
||||||
int freq, struct tm until, struct days_s *exc, char state)
|
int freq, struct tm until, char *note, struct days_s *exc, char state)
|
||||||
{
|
{
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
char buf[MESG_MAXSIZE], *nl;
|
char buf[MESG_MAXSIZE], *nl;
|
||||||
@ -234,13 +240,14 @@ recur_apoint_scan(FILE * f, struct tm start, struct tm end, char type,
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return recur_apoint_new(buf, tstart, tend - tstart,
|
return (recur_apoint_new(buf, note, tstart, tend - tstart, state,
|
||||||
state, recur_char2def(type), freq, tuntil, exc);
|
recur_char2def(type), freq, tuntil, exc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load the recursive events from file */
|
/* Load the recursive events from file */
|
||||||
struct recur_event_s *recur_event_scan(FILE * f, struct tm start, int id,
|
struct recur_event_s *
|
||||||
char type, int freq, struct tm until, struct days_s *exc)
|
recur_event_scan(FILE * f, struct tm start, int id, char type, int freq,
|
||||||
|
struct tm until, char *note, struct days_s *exc)
|
||||||
{
|
{
|
||||||
struct tm *lt;
|
struct tm *lt;
|
||||||
char buf[MESG_MAXSIZE], *nl;
|
char buf[MESG_MAXSIZE], *nl;
|
||||||
@ -275,7 +282,7 @@ struct recur_event_s *recur_event_scan(FILE * f, struct tm start, int id,
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return recur_event_new(buf, tstart, id, recur_char2def(type),
|
return recur_event_new(buf, note, tstart, id, recur_char2def(type),
|
||||||
freq, tuntil, exc);
|
freq, tuntil, exc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,10 +317,13 @@ recur_apoint_write(recur_apoint_llist_node_t *o, FILE *f)
|
|||||||
}
|
}
|
||||||
if (o->exc != 0)
|
if (o->exc != 0)
|
||||||
recur_write_exc(o->exc, f);
|
recur_write_exc(o->exc, f);
|
||||||
|
fprintf(f, "} ");
|
||||||
|
if (o->note != NULL)
|
||||||
|
fprintf(f, ">%s ", o->note);
|
||||||
if (o->state & APOINT_NOTIFY)
|
if (o->state & APOINT_NOTIFY)
|
||||||
fprintf(f, "} !");
|
fprintf(f, "!");
|
||||||
else
|
else
|
||||||
fprintf(f, "} |");
|
fprintf(f, "|");
|
||||||
fprintf(f, "%s\n", o->mesg);
|
fprintf(f, "%s\n", o->mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,8 +346,6 @@ recur_event_write(struct recur_event_s *o, FILE *f)
|
|||||||
fprintf(f, "%02u/%02u/%04u [%d] {%d%c",
|
fprintf(f, "%02u/%02u/%04u [%d] {%d%c",
|
||||||
st_mon, st_day, st_year, o->id, o->rpt->freq,
|
st_mon, st_day, st_year, o->id, o->rpt->freq,
|
||||||
recur_def2char(o->rpt->type));
|
recur_def2char(o->rpt->type));
|
||||||
if (o->exc != 0) recur_write_exc(o->exc, f);
|
|
||||||
fprintf(f,"} %s\n", o->mesg);
|
|
||||||
} else {
|
} else {
|
||||||
lt = localtime(&t);
|
lt = localtime(&t);
|
||||||
end_mon = lt->tm_mon + 1;
|
end_mon = lt->tm_mon + 1;
|
||||||
@ -347,13 +355,18 @@ recur_event_write(struct recur_event_s *o, FILE *f)
|
|||||||
st_mon, st_day, st_year, o->id,
|
st_mon, st_day, st_year, o->id,
|
||||||
o->rpt->freq, recur_def2char(o->rpt->type),
|
o->rpt->freq, recur_def2char(o->rpt->type),
|
||||||
end_mon, end_day, end_year);
|
end_mon, end_day, end_year);
|
||||||
if (o->exc != 0) recur_write_exc(o->exc, f);
|
|
||||||
fprintf(f, "} %s\n", o->mesg);
|
|
||||||
}
|
}
|
||||||
|
if (o->exc != 0)
|
||||||
|
recur_write_exc(o->exc, f);
|
||||||
|
fprintf(f, "} ");
|
||||||
|
if (o->note != NULL)
|
||||||
|
fprintf(f, ">%s ", o->note);
|
||||||
|
fprintf(f, "%s\n", o->mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write recursive items to file. */
|
/* Write recursive items to file. */
|
||||||
void recur_save_data(FILE *f)
|
void
|
||||||
|
recur_save_data(FILE *f)
|
||||||
{
|
{
|
||||||
struct recur_event_s *re;
|
struct recur_event_s *re;
|
||||||
recur_apoint_llist_node_t *ra;
|
recur_apoint_llist_node_t *ra;
|
||||||
@ -373,8 +386,8 @@ void recur_save_data(FILE *f)
|
|||||||
* This function was improved thanks to Tony's patch.
|
* This function was improved thanks to Tony's patch.
|
||||||
*/
|
*/
|
||||||
unsigned
|
unsigned
|
||||||
recur_item_inday(long item_start, struct days_s *item_exc,
|
recur_item_inday(long item_start, struct days_s *item_exc, int rpt_type,
|
||||||
int rpt_type, int rpt_freq, long rpt_until, long day_start)
|
int rpt_freq, long rpt_until, long day_start)
|
||||||
{
|
{
|
||||||
date_t start_date;
|
date_t start_date;
|
||||||
long day_end, diff;
|
long day_end, diff;
|
||||||
@ -459,7 +472,8 @@ recur_item_inday(long item_start, struct days_s *item_exc,
|
|||||||
* Delete a recurrent event from the list (if delete_whole is not null),
|
* Delete a recurrent event from the list (if delete_whole is not null),
|
||||||
* or delete only one occurence of the recurrent event.
|
* or delete only one occurence of the recurrent event.
|
||||||
*/
|
*/
|
||||||
void recur_event_erase(long start, unsigned num, unsigned delete_whole)
|
void
|
||||||
|
recur_event_erase(long start, unsigned num, unsigned delete_whole, int only_note)
|
||||||
{
|
{
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
struct recur_event_s *i, **iptr;
|
struct recur_event_s *i, **iptr;
|
||||||
@ -471,11 +485,17 @@ void recur_event_erase(long start, unsigned num, unsigned delete_whole)
|
|||||||
i->rpt->freq, i->rpt->until, start)) {
|
i->rpt->freq, i->rpt->until, start)) {
|
||||||
if (n == num) {
|
if (n == num) {
|
||||||
if (delete_whole) {
|
if (delete_whole) {
|
||||||
|
if (only_note)
|
||||||
|
erase_note(&i->note);
|
||||||
|
else {
|
||||||
*iptr = i->next;
|
*iptr = i->next;
|
||||||
free(i->mesg);
|
free(i->mesg);
|
||||||
free(i->rpt);
|
free(i->rpt);
|
||||||
free(i->exc);
|
free(i->exc);
|
||||||
|
if (i->note != NULL)
|
||||||
|
erase_note(&i->note);
|
||||||
free(i);
|
free(i);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
o = (struct days_s *)
|
o = (struct days_s *)
|
||||||
@ -507,7 +527,9 @@ void recur_event_erase(long start, unsigned num, unsigned delete_whole)
|
|||||||
* Delete a recurrent appointment from the list (if delete_whole is not null),
|
* Delete a recurrent appointment from the list (if delete_whole is not null),
|
||||||
* or delete only one occurence of the recurrent appointment.
|
* or delete only one occurence of the recurrent appointment.
|
||||||
*/
|
*/
|
||||||
void recur_apoint_erase(long start, unsigned num, unsigned delete_whole)
|
void
|
||||||
|
recur_apoint_erase(long start, unsigned num, unsigned delete_whole,
|
||||||
|
int only_note)
|
||||||
{
|
{
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
recur_apoint_llist_node_t *i, **iptr;
|
recur_apoint_llist_node_t *i, **iptr;
|
||||||
@ -520,18 +542,25 @@ void recur_apoint_erase(long start, unsigned num, unsigned delete_whole)
|
|||||||
if (recur_item_inday(i->start, i->exc, i->rpt->type,
|
if (recur_item_inday(i->start, i->exc, i->rpt->type,
|
||||||
i->rpt->freq, i->rpt->until, start)) {
|
i->rpt->freq, i->rpt->until, start)) {
|
||||||
if (n == num) {
|
if (n == num) {
|
||||||
if (notify_bar())
|
if (notify_bar() && only_note != 0)
|
||||||
need_check_notify = notify_same_recur_item(i);
|
need_check_notify =
|
||||||
|
notify_same_recur_item(i);
|
||||||
if (delete_whole) {
|
if (delete_whole) {
|
||||||
|
if (only_note)
|
||||||
|
erase_note(&i->note);
|
||||||
|
else {
|
||||||
*iptr = i->next;
|
*iptr = i->next;
|
||||||
free(i->mesg);
|
free(i->mesg);
|
||||||
free(i->rpt);
|
free(i->rpt);
|
||||||
free(i->exc);
|
free(i->exc);
|
||||||
|
if (i->note != NULL)
|
||||||
|
erase_note(&i->note);
|
||||||
free(i);
|
free(i);
|
||||||
pthread_mutex_unlock(
|
pthread_mutex_unlock(
|
||||||
&(recur_alist_p->mutex));
|
&(recur_alist_p->mutex));
|
||||||
if (need_check_notify)
|
if (need_check_notify)
|
||||||
notify_check_next_app();
|
notify_check_next_app();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
o = (struct days_s *)
|
o = (struct days_s *)
|
||||||
@ -677,12 +706,13 @@ recur_repeat_item(void)
|
|||||||
date = calendar_get_slctd_day_sec();
|
date = calendar_get_slctd_day_sec();
|
||||||
day_erase_item(date, item_nb, 0);
|
day_erase_item(date, item_nb, 0);
|
||||||
if (p->type == EVNT) {
|
if (p->type == EVNT) {
|
||||||
re = recur_event_new(p->mesg, p->start, p->evnt_id,
|
re = recur_event_new(p->mesg, p->note, p->start, p->evnt_id,
|
||||||
type, freq, until, NULL);
|
type, freq, until, NULL);
|
||||||
} else if (p->type == APPT) {
|
} else if (p->type == APPT) {
|
||||||
ra = recur_apoint_new(p->mesg, p->start, p->appt_dur, p->state,
|
ra = recur_apoint_new(p->mesg, p->note, p->start, p->appt_dur,
|
||||||
type, freq, until, NULL);
|
p->state, type, freq, until, NULL);
|
||||||
if (notify_bar()) notify_check_repeated(ra);
|
if (notify_bar())
|
||||||
|
notify_check_repeated(ra);
|
||||||
} else { /* NOTREACHED */
|
} else { /* NOTREACHED */
|
||||||
fputs(_("FATAL ERROR in recur_repeat_item: wrong item type\n"),
|
fputs(_("FATAL ERROR in recur_repeat_item: wrong item type\n"),
|
||||||
stderr);
|
stderr);
|
||||||
@ -694,7 +724,8 @@ recur_repeat_item(void)
|
|||||||
* Read days for which recurrent items must not be repeated
|
* Read days for which recurrent items must not be repeated
|
||||||
* (such days are called exceptions).
|
* (such days are called exceptions).
|
||||||
*/
|
*/
|
||||||
struct days_s *recur_exc_scan(FILE *data_file)
|
struct days_s *
|
||||||
|
recur_exc_scan(FILE *data_file)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
struct tm *lt, day;
|
struct tm *lt, day;
|
||||||
@ -758,7 +789,8 @@ recur_apoint_check_next(struct notify_app_s *app, long start, long day)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a structure containing the selected recurrent appointment. */
|
/* Returns a structure containing the selected recurrent appointment. */
|
||||||
recur_apoint_llist_node_t *recur_get_apoint(long date, int num)
|
recur_apoint_llist_node_t *
|
||||||
|
recur_get_apoint(long date, int num)
|
||||||
{
|
{
|
||||||
recur_apoint_llist_node_t *o;
|
recur_apoint_llist_node_t *o;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -780,7 +812,8 @@ recur_apoint_llist_node_t *recur_get_apoint(long date, int num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a structure containing the selected recurrent event. */
|
/* Returns a structure containing the selected recurrent event. */
|
||||||
struct recur_event_s *recur_get_event(long date, int num)
|
struct recur_event_s *
|
||||||
|
recur_get_event(long date, int num)
|
||||||
{
|
{
|
||||||
struct recur_event_s *o;
|
struct recur_event_s *o;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -831,5 +864,4 @@ recur_apoint_switch_notify(long date, int recur_nb)
|
|||||||
fputs(_("FATAL ERROR in recur_apoint_switch_notify: no such item\n"),
|
fputs(_("FATAL ERROR in recur_apoint_switch_notify: no such item\n"),
|
||||||
stderr);
|
stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
23
src/recur.h
23
src/recur.h
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: recur.h,v 1.15 2007/08/15 15:37:31 culot Exp $ */
|
/* $calcurse: recur.h,v 1.16 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -54,6 +54,7 @@ typedef struct recur_apoint_llist_node {
|
|||||||
long dur; /* duration of the appointment */
|
long dur; /* duration of the appointment */
|
||||||
char state; /* 8 bits to store item state */
|
char state; /* 8 bits to store item state */
|
||||||
char *mesg; /* appointment description */
|
char *mesg; /* appointment description */
|
||||||
|
char *note; /* note attached to appointment */
|
||||||
} recur_apoint_llist_node_t;
|
} recur_apoint_llist_node_t;
|
||||||
|
|
||||||
typedef struct recur_apoint_llist {
|
typedef struct recur_apoint_llist {
|
||||||
@ -68,28 +69,30 @@ struct recur_event_s {
|
|||||||
int id; /* event type */
|
int id; /* event type */
|
||||||
long day; /* day at which event occurs */
|
long day; /* day at which event occurs */
|
||||||
char *mesg; /* event description */
|
char *mesg; /* event description */
|
||||||
|
char *note; /* note attached to event */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern recur_apoint_llist_t *recur_alist_p;
|
extern recur_apoint_llist_t *recur_alist_p;
|
||||||
extern struct recur_event_s *recur_elist;
|
extern struct recur_event_s *recur_elist;
|
||||||
|
|
||||||
int recur_apoint_llist_init(void);
|
int recur_apoint_llist_init(void);
|
||||||
recur_apoint_llist_node_t *recur_apoint_new(char *, long, long, char, int,
|
recur_apoint_llist_node_t *recur_apoint_new(char *, char *, long, long,
|
||||||
|
char, int, int, long, struct days_s *);
|
||||||
|
struct recur_event_s *recur_event_new(char *, char *, long, int, int,
|
||||||
int, long, struct days_s *);
|
int, long, struct days_s *);
|
||||||
struct recur_event_s *recur_event_new(char *, long, int, int, int,
|
|
||||||
long, struct days_s *);
|
|
||||||
char recur_def2char(recur_types_t);
|
char recur_def2char(recur_types_t);
|
||||||
int recur_char2def(char);
|
int recur_char2def(char);
|
||||||
recur_apoint_llist_node_t *recur_apoint_scan(FILE *, struct tm, struct tm,
|
recur_apoint_llist_node_t *recur_apoint_scan(FILE *, struct tm, struct tm,
|
||||||
char, int, struct tm, struct days_s *,
|
char, int, struct tm, char *,
|
||||||
char);
|
struct days_s *, char);
|
||||||
struct recur_event_s *recur_event_scan(FILE *, struct tm, int, char,
|
struct recur_event_s *recur_event_scan(FILE *, struct tm, int, char,
|
||||||
int, struct tm, struct days_s *);
|
int, struct tm, char *, struct days_s *);
|
||||||
void recur_save_data(FILE *);
|
void recur_save_data(FILE *);
|
||||||
unsigned recur_item_inday(long, struct days_s *, int,
|
unsigned recur_item_inday(long, struct days_s *, int,
|
||||||
int, long, long);
|
int, long, long);
|
||||||
void recur_event_erase(long, unsigned, unsigned);
|
void recur_event_erase(long, unsigned, unsigned, int);
|
||||||
void recur_apoint_erase(long, unsigned, unsigned);
|
void recur_apoint_erase(long, unsigned, unsigned,
|
||||||
|
int);
|
||||||
void recur_repeat_item(void);
|
void recur_repeat_item(void);
|
||||||
struct days_s *recur_exc_scan(FILE *);
|
struct days_s *recur_exc_scan(FILE *);
|
||||||
struct notify_app_s *recur_apoint_check_next(struct notify_app_s *,
|
struct notify_app_s *recur_apoint_check_next(struct notify_app_s *,
|
||||||
|
13
src/todo.c
13
src/todo.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: todo.c,v 1.17 2007/12/31 17:37:53 culot Exp $ */
|
/* $calcurse: todo.c,v 1.18 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -179,7 +179,6 @@ todo_delete_note_bynum(unsigned num)
|
|||||||
{
|
{
|
||||||
unsigned n;
|
unsigned n;
|
||||||
struct todo_s *i, **iptr;
|
struct todo_s *i, **iptr;
|
||||||
char fullname[BUFSIZ];
|
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
iptr = &todolist;
|
iptr = &todolist;
|
||||||
@ -189,13 +188,7 @@ todo_delete_note_bynum(unsigned num)
|
|||||||
ierror(
|
ierror(
|
||||||
_("FATAL ERROR in todo_delete_note_bynum: "
|
_("FATAL ERROR in todo_delete_note_bynum: "
|
||||||
"no note attached\n"), IERROR_FATAL);
|
"no note attached\n"), IERROR_FATAL);
|
||||||
snprintf(fullname, BUFSIZ, "%s%s", path_notes, i->note);
|
erase_note(&i->note);
|
||||||
if (unlink(fullname) != 0)
|
|
||||||
ierror(
|
|
||||||
_("FATAL ERROR in todo_delete_note_bynum: "
|
|
||||||
"could not remove note\n"), IERROR_FATAL);
|
|
||||||
free(i->note);
|
|
||||||
i->note = NULL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iptr = &i->next;
|
iptr = &i->next;
|
||||||
@ -221,7 +214,7 @@ todo_delete_bynum(unsigned num)
|
|||||||
*iptr = i->next;
|
*iptr = i->next;
|
||||||
free(i->mesg);
|
free(i->mesg);
|
||||||
if (i->note != NULL)
|
if (i->note != NULL)
|
||||||
free(i->note);
|
erase_note(&i->note);
|
||||||
free(i);
|
free(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
21
src/utils.c
21
src/utils.c
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: utils.c,v 1.38 2007/12/30 16:27:59 culot Exp $ */
|
/* $calcurse: utils.c,v 1.39 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -900,3 +900,20 @@ new_tempfile(const char *prefix, int trailing_len)
|
|||||||
|
|
||||||
return (strdup(fullname + prefix_len));
|
return (strdup(fullname + prefix_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Erase a note previously attached to a todo, event or appointment. */
|
||||||
|
void
|
||||||
|
erase_note(char **note)
|
||||||
|
{
|
||||||
|
char fullname[BUFSIZ];
|
||||||
|
|
||||||
|
if (*note == NULL)
|
||||||
|
ierror(_("FATAL ERROR in erase_note: null pointer!\n"),
|
||||||
|
IERROR_FATAL);
|
||||||
|
snprintf(fullname, BUFSIZ, "%s%s", path_notes, *note);
|
||||||
|
if (unlink(fullname) != 0)
|
||||||
|
ierror(_("FATAL ERROR in erase_note: could not remove note\n"),
|
||||||
|
IERROR_FATAL);
|
||||||
|
free(*note);
|
||||||
|
*note = NULL;
|
||||||
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* $calcurse: utils.h,v 1.24 2007/12/30 16:27:59 culot Exp $ */
|
/* $calcurse: utils.h,v 1.25 2008/01/13 12:40:45 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
* Copyright (c) 2004-2007 Frederic Culot
|
* Copyright (c) 2004-2008 Frederic Culot
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -93,5 +93,6 @@ char *mycpy(const char *);
|
|||||||
long mystrtol(const char *);
|
long mystrtol(const char *);
|
||||||
void print_option_incolor(WINDOW *, bool, int, int);
|
void print_option_incolor(WINDOW *, bool, int, int);
|
||||||
char *new_tempfile(const char *, int);
|
char *new_tempfile(const char *, int);
|
||||||
|
void erase_note(char **);
|
||||||
|
|
||||||
#endif /* CALCURSE_UTILS_H */
|
#endif /* CALCURSE_UTILS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user