whitespace.
[lyx.git] / src / Undo.h
blobc89bb4a8113312c7f914ef8cd83c8c7721beae90
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 class Undo
49 public:
51 Undo(Buffer &);
53 ~Undo();
55 /// this will undo the last action - returns false if no undo possible
56 bool textUndo(DocIterator &);
58 /// this will redo the last undo - returns false if no redo possible
59 bool textRedo(DocIterator &);
61 /// End a sequence of INSERT_UNDO or DELETE_UNDO type of undo
62 /// operations (grouping of consecutive characters insertion/deletion).
63 void finishUndo();
65 ///
66 bool hasUndoStack() const;
67 ///
68 bool hasRedoStack() const;
70 /// open a new group of undo operations.
71 /**
72 * Groups can be nested. Such a nested group e.g. { {} {} } is undone in
73 * a single step. This means you can add a group whenever you are not sure.
75 void beginUndoGroup();
77 /// end the current undo group.
78 void endUndoGroup();
80 /// The general case: record undo information for an arbitrary range.
81 /**
82 * Record undo information - call with the current cursor and
83 * the 'other end' of the range of changed paragraphs. So we
84 * give an inclusive range. This is called before you make the
85 * changes to the paragraph, and it will record the original
86 * information of the paragraphs in the undo stack.
88 void recordUndo(DocIterator const & cur, UndoKind kind,
89 pit_type from, pit_type to);
91 /// Convenience: record undo information for the range between
92 /// 'from' and cursor.
93 void recordUndo(DocIterator const & cur, UndoKind kind, pit_type from);
95 /// Convenience: record undo information for the single
96 /// paragraph or cell containing the cursor.
97 void recordUndo(DocIterator const & cur, UndoKind kind = ATOMIC_UNDO);
99 /// Convenience: record undo information for the inset
100 /// containing the cursor.
101 void recordUndoInset(DocIterator const & cur,
102 UndoKind kind = ATOMIC_UNDO);
104 /// Convenience: prepare undo for the whole buffer
105 void recordUndoFullDocument(DocIterator const & cur);
107 private:
108 struct Private;
109 Private * const d;
114 } // namespace lyx
116 #endif // UNDO_H