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.h"
21 #include "bufferparams.h"
23 #include "support/types.h"
33 These are the elements put on the undo stack. Each object contains complete
34 paragraphs from some cell and sufficient information to restore the cursor
37 The cell is given by a DocIterator pointing to this cell, the 'interesting'
38 range of paragraphs by counting them from begin and end of cell,
41 The cursor is also given as DocIterator and should point to some place in
42 the stored paragraph range. In case of math, we simply store the whole
43 cell, as there usually is just a simple paragraph in a cell.
45 The idea is to store the contents of 'interesting' paragraphs in some
46 structure ('Undo') _before_ it is changed in some edit operation.
47 Obviously, the stored ranged should be as small as possible. However, it
48 there is a lower limit: The StableDocIterator pointing stored in the undo
49 class must be valid after the changes, too, as it will used as a pointer
50 where to insert the stored bits when performining undo.
56 /// This is used to combine consecutive undo recordings of the same kind.
59 * Insert something - these will combine to one big chunk
60 * when many inserts come after each other.
64 * Delete something - these will combine to one big chunk
65 * when many deletes come after each other.
68 /// Atomic - each of these will have its own entry in the stack
72 /// Which kind of operation are we recording for?
74 /// the position of the cursor
75 StableDocIterator cursor;
76 /// the position of the cell described
77 StableDocIterator cell;
78 /// counted from begin of cell
80 /// complement to end of this cell
82 /// the contents of the saved Paragraphs (for texted)
84 /// the stringified contents of the saved MathArray (for mathed)
86 /// Only used in case of full backups
88 /// Only used in case of full backups
93 /// this will undo the last action - returns false if no undo possible
94 bool textUndo(BufferView & bv);
96 /// this will redo the last undo - returns false if no redo possible
97 bool textRedo(BufferView & bv);
99 /// makes sure the next operation will be stored
104 * Record undo information - call with the current cursor and the 'other
105 * end' of the range of changed paragraphs. So we give an inclusive range.
106 * This is called before you make the changes to the paragraph, and it
107 * will record the original information of the paragraphs in the undo stack.
109 * FIXME: We need something to record undo in partial grids for mathed.
110 * Right now we use recordUndoInset if more than one cell is changed,
111 * but that puts the cursor in front of the inset after undo. We would need
113 * recordUndoGrid(LCursor & cur, Undo::undo_kind kind, idx_type from, idx_type to);
114 * and store the cell information in class Undo.
117 /// The general case: prepare undo for an arbitrary range.
118 void recordUndo(LCursor & cur, Undo::undo_kind kind,
119 lyx::pit_type from, lyx::pit_type to);
121 /// Convenience: prepare undo for the range between 'from' and cursor.
122 void recordUndo(LCursor & cur, Undo::undo_kind kind, lyx::pit_type from);
124 /// Convenience: prepare undo for the single paragraph or cell
125 /// containing the cursor
126 void recordUndo(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
127 /// Convenience: prepare undo for the inset containing the cursor
128 void recordUndoInset(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
129 /// Convenience: prepare undo for the selected paragraphs
130 void recordUndoSelection(LCursor & cur, Undo::undo_kind kind = Undo::ATOMIC);
132 /// Convenience: prepare undo for the whole buffer
133 void recordUndoFullDocument(BufferView * bv);
135 #endif // UNDO_FUNCS_H