2 #include "undostackitem.h"
5 UndoStack::UndoStack() : List<UndoStackItem>()
10 UndoStack::~UndoStack()
14 void UndoStack::push(UndoStackItem *item)
16 // current is only 0 if before first undo
18 current = insert_after(current, item);
20 current = insert_before(first, item);
22 // delete future undos if necessary
23 if(current && current->next)
25 while(current->next) remove(last);
31 if(current) current = PREVIOUS;
34 UndoStackItem* UndoStack::pull_next()
36 // use first entry if none
37 if(!current) current = first;
39 // use next entry if there is a next entry
42 // don't change current if there is no next entry
49 // enforces that the undo stack does not exceed a size of UNDOMEMORY
50 // except that it always has at least UNDOMINLEVELS entries
51 void UndoStack::prune()
56 UndoStackItem* i = last;
57 while (i != 0 && (levels < UNDOMINLEVELS || size <= UNDOMEMORY))
59 size += i->get_size();
66 // truncate everything before and including i