]> git.lyx.org Git - features.git/blobdiff - src/Undo.h
The way this was done here is inconsistent with how it is done
[features.git] / src / Undo.h
index 95514ab0b259a1e5685a1cbe4362301b7cff4bc4..c2acf4af216b78060c7ed3893a965fbfecaa57aa 100644 (file)
@@ -117,6 +117,34 @@ private:
 };
 
 
+/** Helper class to simplify the use of undo groups across several buffers.
+ *
+ *  The undo group is created when the object is instanciated; it is
+ *  then ended as the object goes out of scope or the buffer is reset
+ *  (see below)
+ */
+class UndoGroupHelper {
+public:
+       UndoGroupHelper(Buffer * buf) : buffer_(0)
+       {
+               resetBuffer(buf);
+       }
+
+       ~UndoGroupHelper()
+       {
+               resetBuffer(0);
+       }
+
+       /** Close the current undo group if necessary and create a new one
+        * for buffer \c buf.
+        */
+       void resetBuffer(Buffer * buf);
+
+private:
+       Buffer * buffer_;
+};
+
+
 
 } // namespace lyx