Add missing include, due to André LASSERT change
[lyx.git] / src / Undo.h
blob160f3ac40e6a24e0a3ac1d03e4d036aa26e6f5af
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.
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 * \author Abdelrazak Younes
14 * Full author contact details are available in file CREDITS.
17 #ifndef UNDO_H
18 #define UNDO_H
20 #include "support/types.h"
22 namespace lyx {
24 class Buffer;
25 class BufferParams;
26 class DocIterator;
27 class MathData;
28 class ParagraphList;
30 /// This is used to combine consecutive undo recordings of the same kind.
31 enum UndoKind {
32 /**
33 * Insert something - these will combine to one big chunk
34 * when many inserts come after each other.
36 INSERT_UNDO,
37 /**
38 * Delete something - these will combine to one big chunk
39 * when many deletes come after each other.
41 DELETE_UNDO,
42 /// Atomic - each of these will have its own entry in the stack
43 ATOMIC_UNDO
47 /**
48 * Record undo information - call with the current cursor and the 'other
49 * end' of the range of changed paragraphs. So we give an inclusive range.
50 * This is called before you make the changes to the paragraph, and it
51 * will record the original information of the paragraphs in the undo stack.
53 * FIXME: We need something to record undo in partial grids for mathed.
54 * Right now we use recordUndoInset if more than one cell is changed,
55 * but that puts the cursor in front of the inset after undo. We would need
56 * something like
57 * recordUndoGrid(DocIterator & cur, UndoKind kind, idx_type from, idx_type to);
58 * and store the cell information in class Undo.
60 class Undo
62 public:
64 Undo(Buffer &);
66 ~Undo();
68 /// this will undo the last action - returns false if no undo possible
69 bool textUndo(DocIterator &);
71 /// this will redo the last undo - returns false if no redo possible
72 bool textRedo(DocIterator &);
74 /// makes sure the next operation will be stored
75 void finishUndo();
77 ///
78 bool hasUndoStack() const;
79 ///
80 bool hasRedoStack() const;
82 /// The general case: prepare undo for an arbitrary range.
83 void recordUndo(DocIterator & cur, UndoKind kind,
84 pit_type from, pit_type to);
86 /// Convenience: prepare undo for the range between 'from' and cursor.
87 void recordUndo(DocIterator & cur, UndoKind kind, pit_type from);
89 /// Convenience: prepare undo for the single paragraph or cell
90 /// containing the cursor
91 void recordUndo(DocIterator & cur, UndoKind kind = ATOMIC_UNDO);
92 /// Convenience: prepare undo for the inset containing the cursor
93 void recordUndoInset(DocIterator & cur, UndoKind kind = ATOMIC_UNDO);
95 /// Convenience: prepare undo for the whole buffer
96 void recordUndoFullDocument(DocIterator & cur);
98 private:
99 struct Private;
100 Private * const d;
105 } // namespace lyx
107 #endif // UNDO_H