[LyX/master] Add a constructor of UndoGroupHelper that uses a CursorData parameter
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Thu Jun 20 16:04:04 UTC 2024
commit e7b1ee47eadc35b75862baf6127a5207412bcf36
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Thu Jun 20 17:52:19 2024 +0200
Add a constructor of UndoGroupHelper that uses a CursorData parameter
This aloows to se the the `before' cursor of the undo group.
Not used for now.
---
src/Undo.cpp | 16 ++++++++++++++++
src/Undo.h | 6 ++++++
2 files changed, 22 insertions(+)
diff --git a/src/Undo.cpp b/src/Undo.cpp
index 8dcffff32b..80dff34baa 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -704,6 +704,12 @@ UndoGroupHelper::UndoGroupHelper(Buffer * buf) : d(new UndoGroupHelper::Impl)
}
+UndoGroupHelper::UndoGroupHelper(CursorData & cur) : d(new UndoGroupHelper::Impl)
+{
+ resetBuffer(cur);
+}
+
+
UndoGroupHelper::~UndoGroupHelper()
{
for (Buffer * buf : d->buffers_)
@@ -712,6 +718,7 @@ UndoGroupHelper::~UndoGroupHelper()
delete d;
}
+
void UndoGroupHelper::resetBuffer(Buffer * buf)
{
if (buf && d->buffers_.count(buf) == 0) {
@@ -721,4 +728,13 @@ void UndoGroupHelper::resetBuffer(Buffer * buf)
}
+void UndoGroupHelper::resetBuffer(CursorData & cur)
+{
+ if (!cur.empty() && d->buffers_.count(cur.buffer()) == 0) {
+ d->buffers_.insert(cur.buffer());
+ cur.buffer()->undo().beginUndoGroup(cur);
+ }
+}
+
+
} // namespace lyx
diff --git a/src/Undo.h b/src/Undo.h
index b6d84569c5..32be7d2ede 100644
--- a/src/Undo.h
+++ b/src/Undo.h
@@ -140,12 +140,18 @@ class UndoGroupHelper {
public:
// Begin a new undo group for buffer \c buf.
UndoGroupHelper(Buffer * buf);
+ // Begin an undo group for the buffer of \c cur with the the
+ // `before' cursor set to \c cur.
+ UndoGroupHelper(CursorData & cur);
// End all active undo groups.
~UndoGroupHelper();
// Begin if needed an undo group for buffer \c buf.
void resetBuffer(Buffer * buf);
+ // Begin if needed an undo group for the buffer of \c cur with the
+ // the `before' cursor set to \c cur.
+ void resetBuffer(CursorData & cur);
private:
class Impl;
Impl * const d;
More information about the lyx-cvs
mailing list