diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-06-27 08:52:42 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-06-30 14:34:36 +0200 |
commit | 6907ae73e76d11c201ff237663af79b3bbfc5385 (patch) | |
tree | 3863be2f3c8b31f7a0c138debc3e5927f9b06acd /src/day.c | |
parent | b230e2949ef888010c133e4b6f7690f2e1ed2c09 (diff) | |
download | calcurse-6907ae73e76d11c201ff237663af79b3bbfc5385.zip |
Revise cut/pasting
Instead of calling type-specific duplication handlers and inserting
clones of the original items when pasting, save the generic day item and
remove the actual item from the linked list, so that it can be inserted
anywhere else later.
The cut/paste buffer is moved to the interaction unit, item-specific cut
operations are changed to remove the item from the linked list only
instead of copying and freeing it. An item is only freed if another item
is cut before the current cut/paste buffer is pasted. All paste
operations are changed and reinsert the actual item instead of creating
a clone.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/day.c')
-rw-r--r-- | src/day.c | 29 |
1 files changed, 12 insertions, 17 deletions
@@ -595,60 +595,55 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices) } /* Cut an item so it can be pasted somewhere else later. */ -int day_cut_item(long date, int item_number) +struct day_item *day_cut_item(long date, int item_number) { - const int DELETE_WHOLE = 1; - struct day_item *p; + struct day_item *p = day_get_item(item_number); - p = day_get_item(item_number); switch (p->type) { case EVNT: event_delete(p->item.ev, ERASE_CUT); break; case RECUR_EVNT: - recur_event_erase(p->item.rev, date, DELETE_WHOLE, ERASE_CUT); + recur_event_erase(p->item.rev, date, 1, ERASE_CUT); break; case APPT: apoint_delete(p->item.apt, ERASE_CUT); break; case RECUR_APPT: - recur_apoint_erase(p->item.rapt, date, DELETE_WHOLE, ERASE_CUT); + recur_apoint_erase(p->item.rapt, date, 1, ERASE_CUT); break; default: EXIT(_("unknwon type")); /* NOTREACHED */ } - return p->type; + return p; } /* Paste a previously cut item. */ -int day_paste_item(long date, int cut_item_type) +int day_paste_item(struct day_item *p, long date) { - int pasted_item_type; - - pasted_item_type = cut_item_type; - switch (cut_item_type) { + switch (p->type) { case 0: return 0; case EVNT: - event_paste_item(); + event_paste_item(p->item.ev, date); break; case RECUR_EVNT: - recur_event_paste_item(); + recur_event_paste_item(p->item.rev, date); break; case APPT: - apoint_paste_item(); + apoint_paste_item(p->item.apt, date); break; case RECUR_APPT: - recur_apoint_paste_item(); + recur_apoint_paste_item(p->item.rapt, date); break; default: EXIT(_("unknwon type")); /* NOTREACHED */ } - return pasted_item_type; + return p->type; } /* Returns a structure containing the selected item. */ |