]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
More requires --> required, for C++2a.
[lyx.git] / src / BufferView.cpp
index 2068f050cfeddf283516763aecc57adab3c6a8e6..af0ad368b32d29188f56f3c5a03138b82d5b7e62 100644 (file)
@@ -345,9 +345,10 @@ BufferView::~BufferView()
        // That is to say, if a cursor is in a nested inset, it will be
        // restore to the left of the top level inset.
        LastFilePosSection::FilePos fp;
+       fp.file = buffer_.fileName();
        fp.pit = d->cursor_.bottom().pit();
        fp.pos = d->cursor_.bottom().pos();
-       theSession().lastFilePos().save(buffer_.fileName(), fp);
+       theSession().lastFilePos().save(fp);
 
        if (d->last_inset_)
                d->last_inset_->setMouseHover(this, false);
@@ -526,7 +527,13 @@ void BufferView::processUpdateFlags(Update::flags flags)
        // Then make sure that the screen contains the cursor if needed
        if (flags & Update::FitCursor) {
                if (needsFitCursor()) {
-                       scrollToCursor(d->cursor_, false);
+                       // First try to make the selection start visible
+                       // (which is just the cursor when there is no selection)
+                       scrollToCursor(d->cursor_.selectionBegin(), false);
+                       // Is the cursor visible? (only useful if cursor is at end of selection)
+                       if (needsFitCursor())
+                               // then try to make cursor visible instead
+                               scrollToCursor(d->cursor_, false);
                        // Metrics have to be recomputed (maybe again)
                        updateMetrics(flags);
                }
@@ -1532,12 +1539,18 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
        case LFUN_CHANGE_NEXT:
                findNextChange(this);
+               if (cur.inset().isTable())
+                       // In tables, there might be whole changed rows or columns
+                       cur.dispatch(cmd);
                // FIXME: Move this LFUN to Buffer so that we don't have to do this:
                dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
 
        case LFUN_CHANGE_PREVIOUS:
                findPreviousChange(this);
+               if (cur.inset().isTable())
+                       // In tables, there might be whole changed rows or columns
+                       cur.dispatch(cmd);
                // FIXME: Move this LFUN to Buffer so that we don't have to do this:
                dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
@@ -1550,32 +1563,43 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                }
                break;
 
-       case LFUN_ALL_CHANGES_ACCEPT:
+       case LFUN_ALL_CHANGES_ACCEPT: {
                // select complete document
                cur.reset();
                cur.selHandle(true);
                buffer_.text().cursorBottom(cur);
                // accept everything in a single step to support atomic undo
+               // temporarily disable track changes in order to end with really
+               // no new (e.g., DPSM-caused) changes (see #7487)
+               bool const track = buffer_.params().track_changes;
+               buffer_.params().track_changes = false;
                buffer_.text().acceptOrRejectChanges(cur, Text::ACCEPT);
+               buffer_.params().track_changes = track;
                cur.resetAnchor();
                // FIXME: Move this LFUN to Buffer so that we don't have to do this:
                dr.screenUpdate(Update::Force | Update::FitCursor);
                dr.forceBufferUpdate();
                break;
+       }
 
-       case LFUN_ALL_CHANGES_REJECT:
+       case LFUN_ALL_CHANGES_REJECT: {
                // select complete document
                cur.reset();
                cur.selHandle(true);
                buffer_.text().cursorBottom(cur);
                // reject everything in a single step to support atomic undo
-               // Note: reject does not work recursively; the user may have to repeat the operation
+               // temporarily disable track changes in order to end with really
+               // no new (e.g., DPSM-caused) changes (see #7487)
+               bool const track = buffer_.params().track_changes;
+               buffer_.params().track_changes = false;
                buffer_.text().acceptOrRejectChanges(cur, Text::REJECT);
+               buffer_.params().track_changes = track;
                cur.resetAnchor();
                // FIXME: Move this LFUN to Buffer so that we don't have to do this:
                dr.screenUpdate(Update::Force | Update::FitCursor);
                dr.forceBufferUpdate();
                break;
+       }
 
        case LFUN_WORD_FIND_FORWARD:
        case LFUN_WORD_FIND_BACKWARD: {
@@ -3044,11 +3068,16 @@ void BufferView::caretPosAndHeight(Point & p, int & h) const
 }
 
 
-bool BufferView::cursorInView(Point const & p, int h) const
+bool BufferView::caretInView() const
 {
-       Cursor const & cur = cursor();
+       if (!paragraphVisible(cursor()))
+               return false;
+       Point p;
+       int h;
+       caretPosAndHeight(p, h);
+
        // does the cursor touch the screen ?
-       if (p.y_ + h < 0 || p.y_ >= workHeight() || !paragraphVisible(cur))
+       if (p.y_ + h < 0 || p.y_ >= workHeight())
                return false;
        return true;
 }
@@ -3179,7 +3208,6 @@ void BufferView::draw(frontend::Painter & pain, bool paint_caret)
                // however, the different coordinates of insets and paragraphs
                // needs to be updated.
                LYXERR(Debug::PAINTING, "Strategy: NoScreenUpdate");
-               pi.full_repaint = false;
                if (pain.isNull()) {
                        pi.full_repaint = true;
                        tm.draw(pi, 0, y);