]> git.lyx.org Git - lyx.git/blob - src/undo.h
fix reading the author field.
[lyx.git] / src / undo.h
1 // -*- C++ -*-
2 /**
3  * \file undo.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  * \author André Pönitz
11  * \author Jürgen Vigna
12  *
13  * Full author contact details are available in file CREDITS.
14  */
15
16 #ifndef UNDO_H
17 #define UNDO_H
18
19 #include "dociterator.h"
20 #include "ParagraphList_fwd.h"
21
22 #include "support/types.h"
23
24 #include <string>
25
26 class LCursor;
27 class BufferView;
28
29
30 /**
31  * These are the elements put on the undo stack. Each object
32  * contains complete paragraphs and sufficient information
33  * to restore the state.
34  */
35 struct Undo {
36         /// This is used to combine consecutive undo recordings of the same kind.
37         enum undo_kind {
38                 /**
39                  * Insert something - these will combine to one big chunk
40                  * when many inserts come after each other.
41                  */
42                 INSERT,
43                 /**
44                  * Delete something - these will combine to one big chunk
45                  * when many deletes come after each other.
46                  */
47                 DELETE,
48                 /// Atomic - each of these will have its own entry in the stack
49                 ATOMIC
50         };
51
52         /// Which kind of operation are we recording for?
53         undo_kind kind;
54         /// the position of the cursor
55         StableDocIterator cursor;
56         /// counted from begin of buffer
57         lyx::par_type from;
58         /// complement to end of this cell
59         lyx::par_type end;
60         /// the contents of the saved paragraphs (for texted)
61         ParagraphList pars;
62         /// the contents of the saved matharray (for mathed)
63         std::string array;
64 };
65
66
67 /// this will undo the last action - returns false if no undo possible
68 bool textUndo(BufferView &);
69
70 /// this will redo the last undo - returns false if no redo possible
71 bool textRedo(BufferView &);
72
73 /// makes sure the next operation will be stored
74 void finishUndo();
75
76
77 /**
78  * Record undo information - call with the current cursor and the 'other
79  * end' of the range of changed  paragraphs.  So we give an inclusive range.
80  * This is called before you make the changes to the paragraph, and it
81  * will record the original information of the paragraphs in the undo stack.
82  */
83
84 /// The general case: prepare undo for an arbitrary range.
85 void recordUndo(LCursor & cur, Undo::undo_kind kind,
86         lyx::par_type from, lyx::par_type to);
87
88 /// Convenience: prepare undo for the range between 'from' and cursor.
89 void recordUndo(LCursor & cur, Undo::undo_kind kind, lyx::par_type from);
90
91 /// Convenience: prepare undo for the single paragraph or cell
92 /// containing the cursor
93 void recordUndo(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
94 /// Convenience: prepare undo for the inset containing the cursor
95 void recordUndoInset(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
96 /// Convenience: prepare undo for the selected paragraphs
97 void recordUndoSelection(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
98
99 /// Convenience: prepare undo for the single paragraph containing the cursor
100 void recordUndoFullDocument(LCursor & cur);
101
102 #endif // UNDO_FUNCS_H