]> git.lyx.org Git - lyx.git/blob - src/undo.C
white-space changes, removed definitions.h several enum changes because of this,...
[lyx.git] / src / undo.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-1999 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #include "undo.h"
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 UndoStack::UndoStack()
20         : limit(100) {}
21
22
23 Undo * UndoStack::Pop()
24 {
25         if (stakk.empty()) return 0;
26         Undo * result = stakk.front();
27         stakk.pop_front();
28         return result;
29 }
30
31
32 Undo * UndoStack::Top()
33 {
34         if (stakk.empty()) return 0;
35         return stakk.front();
36 }
37
38
39 UndoStack::~UndoStack()
40 {
41         Clear();
42 }
43
44
45 void UndoStack::Clear()
46 {
47         while (!stakk.empty()) {
48                 Undo * tmp = stakk.front();
49                 stakk.pop_front();
50                 delete tmp;
51         }
52 }
53
54
55 void UndoStack::SetStackLimit(Stakk::size_type l)
56 {
57         limit = l;
58 }
59
60
61 void UndoStack::Push(Undo * undo_arg)
62 {
63         if (!undo_arg) return;
64         
65         stakk.push_front(undo_arg);
66         if (stakk.size() > limit) {
67                 Undo * tmp = stakk.back();
68                 stakk.pop_back();
69                 delete tmp;
70         }
71 }