]> git.lyx.org Git - features.git/commitdiff
Code factoring: introduce BufferView::busy()
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 3 May 2023 09:52:27 +0000 (11:52 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 3 May 2023 09:57:31 +0000 (11:57 +0200)
The WorkArea should not have to look at details of the undo stack.
No change intended.

src/Buffer.cpp
src/Buffer.h
src/BufferView.cpp
src/BufferView.h
src/frontends/qt/GuiWorkArea.cpp

index a7f6588f4b4a100ac143e13941ecf1bbe0a3edd5..e4392425024ebefb4d6baed419156bd01fd10568 100644 (file)
@@ -802,6 +802,12 @@ Undo & Buffer::undo()
 }
 
 
+Undo const & Buffer::undo() const
+{
+       return d->undo_;
+}
+
+
 void Buffer::setChild(DocIterator const & dit, Buffer * child)
 {
        d->children_positions[child] = dit;
index 8f4474d311d4fef7b3342cd8a15a8e2891488937..67826a3d5ccc211ad3f87179a303475001e74422 100644 (file)
@@ -651,6 +651,8 @@ public:
 
        ///
        Undo & undo();
+       ///
+       Undo const & undo() const;
 
        /// This function is called when the buffer is changed.
        void changed(bool update_metrics) const;
index ae0c71461a2876caad4b5f6278c5f34eb51b5de3..bf1eb7b1e7c1627fd0162a14167fab8a6b3939d4 100644 (file)
@@ -3527,6 +3527,12 @@ void BufferView::checkCursorScrollOffset()
 }
 
 
+bool BufferView::busy() const
+{
+       return buffer().undo().activeUndoGroup();
+}
+
+
 void BufferView::draw(frontend::Painter & pain, bool paint_caret)
 {
        if (height_ == 0 || width_ == 0)
index 6cdc68534b3b3d2eed93d7547b1dd8ccf256a421..b64b4314b663722e80c33e84e896670ebe26ba6d 100644 (file)
@@ -339,6 +339,8 @@ public:
        /// the shape of the caret
        frontend::CaretGeometry const & caretGeometry() const;
 
+       /// Returns true when the BufferView is not ready for drawing
+       bool busy() const;
        ///
        void draw(frontend::Painter & pain, bool paint_caret);
 
index ae693328b7c378b6bb74a68a83cec600875e0e53..1a3a9c017895512034b51e804d9d2aa4c319f3e9 100644 (file)
@@ -39,7 +39,6 @@
 #include "LyXVC.h"
 #include "Text.h"
 #include "TextMetrics.h"
-#include "Undo.h"
 #include "version.h"
 
 #include "support/convert.h"
@@ -311,8 +310,7 @@ void GuiWorkArea::startBlinkingCaret()
 
        // Don't start blinking if the cursor isn't on screen, unless we
        // are not ready to know whether the cursor is on screen.
-       if (!d->buffer_view_->buffer().undo().activeUndoGroup()
-           && !d->buffer_view_->caretInView())
+       if (!d->buffer_view_->busy() && !d->buffer_view_->caretInView())
                return;
 
        d->showCaret();
@@ -498,8 +496,7 @@ void GuiWorkArea::Private::updateCaretGeometry()
 {
        // we cannot update geometry if not ready and we do not need to if
        // caret is not in view.
-       if (buffer_view_->buffer().undo().activeUndoGroup()
-           || !buffer_view_->caretInView())
+       if (buffer_view_->busy() || !buffer_view_->caretInView())
                return;
 
 
@@ -1240,7 +1237,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
        // Do not trigger the painting machinery if we are not ready (see
        // bug #10989). The second test triggers when in the middle of a
        // dispatch operation.
-       if (view().busy() || d->buffer_view_->buffer().undo().activeUndoGroup()) {
+       if (view().busy() || d->buffer_view_->busy()) {
                // Since the screen may have turned black at this point, our
                // backing store has to be copied to screen. This is a no-op
                // except when our drawing strategy is "backingstore" (macOS,