aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-06-26 13:29:54 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-06-30 14:34:35 +0200
commit02c90ba53a658686bad5cb5f88c555d9eef06399 (patch)
tree4c9676d9e1bb703bb757cd05c6ce273e073e5c0e
parente1fbee0071ad6bb5d5c17865c5a7b67a63930e7d (diff)
downloadcalcurse-02c90ba53a658686bad5cb5f88c555d9eef06399.tar.gz
calcurse-02c90ba53a658686bad5cb5f88c555d9eef06399.zip
Revise *_delete{,_bynum}()
Always pass an item instead of passing a date and a index. This makes use of the NULL callback that was added with one of the previous patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/apoint.c6
-rw-r--r--src/calcurse.h10
-rw-r--r--src/day.c9
-rw-r--r--src/event.c5
-rw-r--r--src/interaction.c11
-rw-r--r--src/recur.c16
-rw-r--r--src/todo.c7
7 files changed, 26 insertions, 38 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 61acc49..e6e02c4 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -269,17 +269,15 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, char state,
return apoint_new(buf, note, tstart, tend - tstart, state);
}
-void apoint_delete_bynum(long start, unsigned num, enum eraseflg flag)
+void apoint_delete(struct apoint *apt, enum eraseflg flag)
{
- llist_item_t *i;
int need_check_notify = 0;
LLIST_TS_LOCK(&alist_p);
- i = LLIST_TS_FIND_NTH(&alist_p, num, &start, apoint_inday);
+ llist_item_t *i = LLIST_TS_FIND_FIRST(&alist_p, apt, NULL);
if (!i)
EXIT(_("no such appointment"));
- struct apoint *apt = LLIST_TS_GET_DATA(i);
switch (flag) {
case ERASE_FORCE_ONLY_NOTE:
diff --git a/src/calcurse.h b/src/calcurse.h
index 1702ffe..4f1da72 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -605,7 +605,7 @@ unsigned apoint_inday(struct apoint *, long *);
void apoint_sec2str(struct apoint *, long, char *, char *);
void apoint_write(struct apoint *, FILE *);
struct apoint *apoint_scan(FILE *, struct tm, struct tm, char, char *);
-void apoint_delete_bynum(long, unsigned, enum eraseflg);
+void apoint_delete(struct apoint *, enum eraseflg);
void apoint_scroll_pad_down(int, int);
void apoint_scroll_pad_up(int);
struct notify_app *apoint_check_next(struct notify_app *, long);
@@ -695,7 +695,7 @@ struct event *event_new(char *, char *, long, int);
unsigned event_inday(struct event *, long *);
void event_write(struct event *, FILE *);
struct event *event_scan(FILE *, struct tm, int, char *);
-void event_delete_bynum(long, unsigned, enum eraseflg);
+void event_delete(struct event *, enum eraseflg);
void event_paste_item(void);
/* help.c */
@@ -871,8 +871,8 @@ unsigned recur_event_find_occurrence(struct recur_event *, long, unsigned *);
unsigned recur_item_inday(long, long, llist_t *, int, int, long, long);
unsigned recur_apoint_inday(struct recur_apoint *, long *);
unsigned recur_event_inday(struct recur_event *, long *);
-void recur_event_erase(long, unsigned, unsigned, enum eraseflg);
-void recur_apoint_erase(long, unsigned, unsigned, enum eraseflg);
+void recur_event_erase(struct recur_event *, long, unsigned, enum eraseflg);
+void recur_apoint_erase(struct recur_apoint *, long, unsigned, enum eraseflg);
void recur_exc_scan(llist_t *, FILE *);
struct notify_app *recur_apoint_check_next(struct notify_app *, long, long);
void recur_apoint_switch_notify(struct recur_apoint *);
@@ -900,7 +900,7 @@ char *todo_saved_mesg(void);
struct todo *todo_add(char *, int, char *);
void todo_write(struct todo *, FILE *);
void todo_delete_note_bynum(unsigned);
-void todo_delete_bynum(unsigned);
+void todo_delete(struct todo *);
void todo_flag(void);
void todo_chg_priority(int);
void todo_update_panel(int);
diff --git a/src/day.c b/src/day.c
index a0b119f..e4a0265 100644
--- a/src/day.c
+++ b/src/day.c
@@ -607,17 +607,16 @@ int day_cut_item(long date, int item_number)
p = day_get_item(item_number);
switch (p->type) {
case EVNT:
- event_delete_bynum(date, day_item_nb(date, item_number, EVNT), ERASE_CUT);
+ event_delete(p->item.ev, ERASE_CUT);
break;
case RECUR_EVNT:
- recur_event_erase(date, day_item_nb(date, item_number, RECUR_EVNT),
- DELETE_WHOLE, ERASE_CUT);
+ recur_event_erase(p->item.rev, date, DELETE_WHOLE, ERASE_CUT);
break;
case APPT:
- apoint_delete_bynum(date, day_item_nb(date, item_number, APPT), ERASE_CUT);
+ apoint_delete(p->item.apt, ERASE_CUT);
break;
case RECUR_APPT:
- recur_apoint_erase(date, p->appt_pos, DELETE_WHOLE, ERASE_CUT);
+ recur_apoint_erase(p->item.rapt, date, DELETE_WHOLE, ERASE_CUT);
break;
default:
EXIT(_("unknwon type"));
diff --git a/src/event.c b/src/event.c
index 4af9f23..d135a2c 100644
--- a/src/event.c
+++ b/src/event.c
@@ -155,13 +155,12 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note)
}
/* Delete an event from the list. */
-void event_delete_bynum(long start, unsigned num, enum eraseflg flag)
+void event_delete(struct event *ev, enum eraseflg flag)
{
- llist_item_t *i = LLIST_FIND_NTH(&eventlist, num, &start, event_inday);
+ llist_item_t *i = LLIST_FIND_FIRST(&eventlist, ev, NULL);
if (!i)
EXIT(_("no such appointment"));
- struct event *ev = LLIST_TS_GET_DATA(i);
switch (flag) {
case ERASE_FORCE_ONLY_NOTE:
diff --git a/src/interaction.c b/src/interaction.c
index b90d61f..c1febe3 100644
--- a/src/interaction.c
+++ b/src/interaction.c
@@ -403,9 +403,9 @@ static int day_erase_item(long date, int item_number, enum eraseflg flag)
}
}
if (p->type == EVNT) {
- event_delete_bynum(date, day_item_nb(date, item_number, EVNT), flag);
+ event_delete(p->item.ev, flag);
} else if (p->type == APPT) {
- apoint_delete_bynum(date, day_item_nb(date, item_number, APPT), flag);
+ apoint_delete(p->item.apt, flag);
} else {
if (flag == ERASE_FORCE_ONLY_NOTE)
ans = 1;
@@ -424,10 +424,9 @@ static int day_erase_item(long date, int item_number, enum eraseflg flag)
}
if (p->type == RECUR_EVNT) {
- recur_event_erase(date, day_item_nb(date, item_number, RECUR_EVNT),
- delete_whole, flag);
+ recur_event_erase(p->item.rev, date, delete_whole, flag);
} else {
- recur_apoint_erase(date, p->appt_pos, delete_whole, flag);
+ recur_apoint_erase(p->item.rapt, date, delete_whole, flag);
}
}
if (flag == ERASE_FORCE_ONLY_NOTE)
@@ -666,7 +665,7 @@ void interact_todo_delete(void)
switch (answer) {
case 1:
- todo_delete_bynum(todo_hilt() - 1);
+ todo_delete(todo_get_item(todo_hilt()));
todo_set_nb(todo_nb() - 1);
if (todo_hilt() > 1)
todo_hilt_decrease(1);
diff --git a/src/recur.c b/src/recur.c
index 212a98d..f458a66 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -695,16 +695,13 @@ unsigned recur_event_inday(struct recur_event *rev, long *day_start)
* or delete only one occurence of the recurrent event.
*/
void
-recur_event_erase(long start, unsigned num, unsigned delete_whole,
+recur_event_erase(struct recur_event *rev, long start, unsigned delete_whole,
enum eraseflg flag)
{
- llist_item_t *i;
-
- i = LLIST_FIND_NTH(&recur_elist, num, &start, recur_event_inday);
+ llist_item_t *i = LLIST_FIND_FIRST(&recur_elist, rev, NULL);
if (!i)
EXIT(_("event not found"));
- struct recur_event *rev = LLIST_GET_DATA(i);
if (delete_whole) {
switch (flag) {
@@ -736,17 +733,14 @@ recur_event_erase(long start, unsigned num, unsigned delete_whole,
* or delete only one occurence of the recurrent appointment.
*/
void
-recur_apoint_erase(long start, unsigned num, unsigned delete_whole,
- enum eraseflg flag)
+recur_apoint_erase(struct recur_apoint *rapt, long start,
+ unsigned delete_whole, enum eraseflg flag)
{
- llist_item_t *i;
+ llist_item_t *i = LLIST_TS_FIND_FIRST(&recur_alist_p, rapt, NULL);
int need_check_notify = 0;
- i = LLIST_TS_FIND_NTH(&recur_alist_p, num, &start, recur_apoint_inday);
-
if (!i)
EXIT(_("appointment not found"));
- struct recur_apoint *rapt = LLIST_GET_DATA(i);
LLIST_TS_LOCK(&recur_alist_p);
if (notify_bar() && flag != ERASE_FORCE_ONLY_NOTE)
diff --git a/src/todo.c b/src/todo.c
index 053f9d6..2ca648d 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -170,13 +170,12 @@ void todo_delete_note_bynum(unsigned num)
}
/* Delete an item from the todo linked list. */
-void todo_delete_bynum(unsigned num)
+void todo_delete(struct todo *todo)
{
- llist_item_t *i = LLIST_NTH(&todolist, num);
+ llist_item_t *i = LLIST_FIND_FIRST(&todolist, todo, NULL);
if (!i)
EXIT(_("no such todo"));
- struct todo *todo = LLIST_TS_GET_DATA(i);
LLIST_REMOVE(&todolist, i);
mem_free(todo->mesg);
@@ -250,7 +249,7 @@ void todo_chg_priority(int action)
/* NOTREACHED */
}
- todo_delete_bynum(hilt - 1);
+ todo_delete(todo_get_item(hilt));
backup = todo_add(backup_mesg, backup_id, backup_note);
hilt = todo_get_position(backup);
}