]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView_pimpl.C
* remove various xforms relicts, in particular:
[lyx.git] / src / BufferView_pimpl.C
index 673332de9bba2eae367bbde9d902578064d0b53d..2365d64f11a17e1f5110d7c4ef7332305fc41e8f 100644 (file)
@@ -681,47 +681,52 @@ bool BufferView::Pimpl::multiParSel()
 }
 
 
+ViewMetricsInfo const & BufferView::Pimpl::viewMetricsInfo()
+{
+       return metrics_info_;
+}
+
+
 void BufferView::Pimpl::update(Update::flags flags)
 {
-       lyxerr[Debug::DEBUG]
-               << BOOST_CURRENT_FUNCTION
-               << "[fitcursor = " << (flags & Update::FitCursor)
-               << ", forceupdate = " << (flags & Update::Force)
-               << ", singlepar = " << (flags & Update::SinglePar)
-               << "]  buffer: " << buffer_ << endl;
+       // This is close to a hot-path.
+       if (lyxerr.debugging(Debug::DEBUG)) {
+               lyxerr[Debug::DEBUG]
+                       << BOOST_CURRENT_FUNCTION
+                       << "[fitcursor = " << (flags & Update::FitCursor)
+                       << ", forceupdate = " << (flags & Update::Force)
+                       << ", singlepar = " << (flags & Update::SinglePar)
+                       << "]  buffer: " << buffer_ << endl;
+       }
 
        // Check needed to survive LyX startup
        if (buffer_) {
                // Update macro store
                buffer_->buildMacros();
 
-               CoordCache backup;
-               std::swap(theCoords, backup);
-
                // This, together with doneUpdating(), verifies (using
                // asserts) that screen redraw is not called from
                // within itself.
                theCoords.startUpdating();
 
                // First drawing step
-               ViewMetricsInfo vi = metrics(flags & Update::SinglePar);
+               bool singlePar = flags & Update::SinglePar;
                bool forceupdate(flags & (Update::Force | Update::SinglePar));
 
-               if ((flags & Update::FitCursor) && fitCursor()) {
+               if ((flags & (Update::FitCursor | Update::MultiParSel))
+                   && (fitCursor() || multiParSel())) {
                        forceupdate = true;
-                       vi = metrics();
-               }
-               if ((flags & Update::MultiParSel) && multiParSel()) {
-                       forceupdate = true;
-                       vi = metrics();
+                       singlePar = false;
                }
+
                if (forceupdate) {
                        // Second drawing step
-                       owner_->workArea()->redraw(*bv_, vi);
+                       updateMetrics(singlePar);
+                       owner_->workArea()->redraw(*bv_);
                } else {
                        // Abort updating of the coord
                        // cache - just restore the old one
-                       std::swap(theCoords, backup);
+                       theCoords.doneUpdating();
                }
        } else
                owner_->workArea()->greyOut();
@@ -1404,7 +1409,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
 }
 
 
-ViewMetricsInfo BufferView::Pimpl::metrics(bool singlepar)
+void BufferView::Pimpl::updateMetrics(bool singlepar)
 {
        // Remove old position cache
        theCoords.clear();
@@ -1501,5 +1506,5 @@ ViewMetricsInfo BufferView::Pimpl::metrics(bool singlepar)
                << "size: " << size
                << endl;
 
-       return ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size);
+       metrics_info_ = ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size);
 }