summaryrefslogtreecommitdiff
path: root/src/apoint.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-06-27 08:52:42 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-06-30 14:34:36 +0200
commit6907ae73e76d11c201ff237663af79b3bbfc5385 (patch)
tree3863be2f3c8b31f7a0c138debc3e5927f9b06acd /src/apoint.c
parentb230e2949ef888010c133e4b6f7690f2e1ed2c09 (diff)
downloadcalcurse-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/apoint.c')
-rw-r--r--src/apoint.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 291d0d8..c8bc1f8 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -233,10 +233,12 @@ void apoint_delete(struct apoint *apt, enum eraseflg flag)
erase_note(&apt->note);
break;
case ERASE_CUT:
- apoint_free_bkp();
- apoint_dup(apt, &bkp_cut_apoint);
- erase_note(&apt->note);
- /* FALLTHROUGH */
+ if (notify_bar())
+ need_check_notify = notify_same_item(apt->start);
+ LLIST_TS_REMOVE(&alist_p, i);
+ if (need_check_notify)
+ notify_check_next_app(0);
+ break;
default:
if (notify_bar())
need_check_notify = notify_same_item(apt->start);
@@ -397,17 +399,14 @@ void apoint_update_panel(int which_pan)
win[APP].x + win[APP].w - 3 * bordr);
}
-void apoint_paste_item(void)
+void apoint_paste_item(struct apoint *apt, long date)
{
- long bkp_time, bkp_start;
+ apt->start = date + get_item_time(apt->start);
- bkp_time = get_item_time(bkp_cut_apoint.start);
- bkp_start = calendar_get_slctd_day_sec() + bkp_time;
- apoint_new(bkp_cut_apoint.mesg, bkp_cut_apoint.note, bkp_start,
- bkp_cut_apoint.dur, bkp_cut_apoint.state);
+ LLIST_TS_LOCK(&alist_p);
+ LLIST_TS_ADD_SORTED(&alist_p, apt, apoint_cmp_start);
+ LLIST_TS_UNLOCK(&alist_p);
if (notify_bar())
- notify_check_added(bkp_cut_apoint.mesg, bkp_start, bkp_cut_apoint.state);
-
- apoint_free_bkp();
+ notify_check_added(apt->mesg, apt->start, apt->state);
}