4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup
8 * \author Lars Gullik Bjønnes
10 * \author André Pönitz
11 * \author Jürgen Vigna
13 * Full author contact details are available in file CREDITS.
19 #include "dociterator.h"
20 #include "ParagraphList_fwd.h"
22 #include "support/types.h"
31 These are the elements put on the undo stack. Each object contains complete
32 paragraphs from some cell and sufficient information to restore the cursor
35 The cell is given by a DocIterator pointing to this cell, the 'interesting'
36 range of paragraphs by counting them from begin and end of cell,
39 The cursor is also given as DocIterator and should point to some place in
40 the stored paragraph range. In case of math, we simply store the whole
41 cell, as there usually is just a simple paragraph in a cell.
43 The idea is to store the contents of 'interesting' paragraphs in some
44 structure ('Undo') _before_ it is changed in some edit operation.
45 Obviously, the stored ranged should be as small as possible. However, it
46 there is a lower limit: The StableDocIterator pointing stored in the undo
47 class must be valid after the changes, too, as it will used as a pointer
48 where to insert the stored bits when performining undo.
54 /// This is used to combine consecutive undo recordings of the same kind.
57 * Insert something - these will combine to one big chunk
58 * when many inserts come after each other.
62 * Delete something - these will combine to one big chunk
63 * when many deletes come after each other.
66 /// Atomic - each of these will have its own entry in the stack
70 /// Which kind of operation are we recording for?
72 /// the position of the cursor
73 StableDocIterator cursor;
74 /// the position of the cell described
75 StableDocIterator cell;
76 /// counted from begin of cell
78 /// complement to end of this cell
80 /// the contents of the saved Paragraphs (for texted)
82 /// the stringified contents of the saved MathArray (for mathed)
87 /// this will undo the last action - returns false if no undo possible
88 bool textUndo(BufferView & bv);
90 /// this will redo the last undo - returns false if no redo possible
91 bool textRedo(BufferView & bv);
93 /// makes sure the next operation will be stored
98 * Record undo information - call with the current cursor and the 'other
99 * end' of the range of changed paragraphs. So we give an inclusive range.
100 * This is called before you make the changes to the paragraph, and it
101 * will record the original information of the paragraphs in the undo stack.
104 /// The general case: prepare undo for an arbitrary range.
105 void recordUndo(LCursor & cur, Undo::undo_kind kind,
106 lyx::pit_type from, lyx::pit_type to);
108 /// Convenience: prepare undo for the range between 'from' and cursor.
109 void recordUndo(LCursor & cur, Undo::undo_kind kind, lyx::pit_type from);
111 /// Convenience: prepare undo for the single paragraph or cell
112 /// containing the cursor
113 void recordUndo(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
114 /// Convenience: prepare undo for the inset containing the cursor
115 void recordUndoInset(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
116 /// Convenience: prepare undo for the selected paragraphs
117 void recordUndoSelection(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
119 /// Convenience: prepare undo for the single paragraph containing the cursor
120 void recordUndoFullDocument(LCursor & cur);
122 #endif // UNDO_FUNCS_H