]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
* BufferView::workAreaDispatch(): prepare for finer grained updates.
[lyx.git] / src / BufferView.C
index 39c8da3162fa7937a02aed839964b2219a31f679..1ba092af0dcb3272003d2e7a1e9c045463e1e953 100644 (file)
@@ -367,7 +367,7 @@ bool BufferView::update(Update::flags flags)
 
        // The second drawing step is done in WorkArea::redraw() if needed.
        bool const need_second_step =
-               (flags & (Update::Force | Update::FitCursor | Update::MultiParSel))
+               (flags & (Update::SinglePar | Update::Force | Update::FitCursor | Update::MultiParSel))
                && (fitCursor() || multiParSel());
 
        return need_second_step;
@@ -1001,19 +1001,16 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
        // LFUN_FILE_OPEN generated by drag-and-drop.
        FuncRequest cmd = cmd0;
 
+       // E.g. Qt mouse press when no buffer
        if (!buffer_)
                return false;
 
+       bool needRedraw = false;
+
        LCursor cur(*this);
        cur.push(buffer_->inset());
        cur.selection() = cursor_.selection();
-
-       // Doesn't go through lyxfunc, so we need to update
-       // the layout choice etc. ourselves
-
-       // E.g. Qt mouse press when no buffer
-       if (!buffer_)
-               return false;
+       needRedraw |= cur.selection();
 
        // Either the inset under the cursor or the
        // surrounding LyXText will handle this event.
@@ -1021,6 +1018,7 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
        // Build temporary cursor.
        cmd.y = min(max(cmd.y, -1), height_);
        InsetBase * inset = buffer_->text().editXY(cur, cmd.x, cmd.y);
+
        //lyxerr << BOOST_CURRENT_FUNCTION
        //       << " * hit inset at tip: " << inset << endl;
        //lyxerr << BOOST_CURRENT_FUNCTION
@@ -1033,8 +1031,10 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
        // via the temp cursor. If the inset wishes to change the real
        // cursor it has to do so explicitly by using
        //  cur.bv().cursor() = cur;  (or similar)
-       if (inset)
+       if (inset) {
                inset->dispatch(cur, cmd);
+               needRedraw = true;
+       }
 
        // Now dispatch to the temporary cursor. If the real cursor should
        // be modified, the inset's dispatch has to do so explicitly.
@@ -1044,11 +1044,13 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
        if (cur.result().dispatched()) {
                // Redraw if requested or necessary.
                if (cur.result().update())
-                       update(Update::FitCursor | Update::Force);
+                       needRedraw |= update(Update::FitCursor | Update::Force);
                else
-                       update(Update::FitCursor | Update::MultiParSel);
+                       needRedraw |= update(Update::FitCursor | Update::MultiParSel);
        }
 
+       // When the above and the inner function are fixed, we can do this:
+       //return needRedraw;
        return true;
 }
 
@@ -1201,14 +1203,9 @@ ViewMetricsInfo const & BufferView::viewMetricsInfo()
 
 void BufferView::updateMetrics(bool singlepar)
 {
-       // FIXME (Abdel 19/10/2006):
-       // There's something fishy in tabular. The coord_cache_ is not
-       // correctly reconstructed when a character is trying to be inserted.
-       // Not clearing out the coord_cache_ fixes the crash but there is a
-       // bad side effect: buffer-begin and buffer-end do not update the screen.
-       //
-       // Remove old position cache
-       coord_cache_.clear();
+       // Clear out the position cache in case of full screen redraw.
+       //if (!singlepar)
+               coord_cache_.clear();
 
        LyXText & buftext = buffer_->text();
        pit_type size = int(buftext.paragraphs().size());
@@ -1369,6 +1366,7 @@ void BufferView::menuInsertLyXFile(string const & filenm)
                ErrorList & el = buffer_->errorList("Parse");
                // Copy the inserted document error list into the current buffer one.
                el = buf.errorList("Parse");
+               recordUndo(cursor_);
                cap::pasteParagraphList(cursor_, buf.paragraphs(),
                                             buf.params().textclass, el);
                res = _("Document %1$s inserted.");