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