]> git.lyx.org Git - lyx.git/blob - src/undostack.C
fix typo that put too many include paths for most people
[lyx.git] / src / undostack.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "undostack.h"
18 #include "undo.h"
19 #include "paragraph.h"
20
21
22 UndoStack::UndoStack()
23         : limit(100) {}
24
25
26 void UndoStack::pop()
27 {
28         if (stakk.empty())
29                 return;
30         stakk.pop_front();
31 }
32
33
34 Undo * UndoStack::top() const
35 {
36         if (stakk.empty())
37                 return 0;
38         return stakk.front();
39 }
40
41
42 UndoStack::~UndoStack()
43 {
44         clear();
45 }
46
47
48 void UndoStack::clear()
49 {
50         while (!stakk.empty()) {
51                 Undo * tmp = stakk.front();
52                 stakk.pop_front();
53                 delete tmp;
54         }
55 }
56
57
58 void UndoStack::SetStackLimit(Stakk::size_type l)
59 {
60         limit = l;
61 }
62
63
64 void UndoStack::push(Undo * undo_arg)
65 {
66         if (!undo_arg)
67                 return;
68
69         stakk.push_front(undo_arg);
70         if (stakk.size() > limit) {
71                 Undo * tmp = stakk.back();
72                 stakk.pop_back();
73                 delete tmp;
74         }
75 }
76
77
78 bool UndoStack::empty() const
79 {
80         return stakk.empty();
81 }