]> git.lyx.org Git - lyx.git/blob - src/undo.h
white-space changes, removed definitions.h several enum changes because of this,...
[lyx.git] / src / undo.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-1999 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef UNDO_H
13 #define UNDO_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <list>
20 using std::list;
21
22 #include "lyxparagraph.h"
23
24
25 ///
26 class Undo {
27 public:
28         /// The undo kinds
29         enum undo_kind {
30                 ///
31                 INSERT,
32                 ///
33                 DELETE,
34                 ///
35                 EDIT,
36                 ///
37                 FINISH
38         };
39         ///
40         undo_kind kind;
41         ///
42         int number_of_before_par;
43         ///
44         int number_of_behind_par;
45         ///
46         int number_of_cursor_par;
47         ///
48         int cursor_pos; // valid if >= 0
49         ///
50         LyXParagraph * par;
51         ///
52         Undo(undo_kind kind_arg,
53              int number_before_arg, int number_behind_arg,
54              int cursor_par_arg, int cursor_pos_arg,
55              LyXParagraph * par_arg)
56         {
57                 kind = kind_arg;
58                 number_of_before_par = number_before_arg;
59                 number_of_behind_par = number_behind_arg;
60                 number_of_cursor_par = cursor_par_arg;
61                 cursor_pos = cursor_pos_arg;
62                 par = par_arg;
63         }
64         ///
65         ~Undo() {
66                 LyXParagraph * tmppar;
67                 while (par) {
68                         tmppar = par;
69                         par = par->next;
70                         delete tmppar;
71                 }
72         }
73 };
74
75
76 /// A limited Stack for the undo informations.
77 class UndoStack{
78 private:
79         ///
80         typedef list<Undo*> Stakk;
81         ///
82         Stakk stakk;
83         /// the maximum number of undo steps stored.
84         Stakk::size_type limit;
85 public:
86         ///
87         UndoStack();
88         ///
89         Undo * Pop();
90         ///
91         Undo * Top();
92         ///
93         ~UndoStack();
94         ///
95         void Clear();
96         ///
97         void SetStackLimit(Stakk::size_type l);
98         ///
99         void Push(Undo * undo_arg);
100 };
101
102 #endif