X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView.cpp;h=2739e00ba31cb4b1f0ec4f374c1a888f6980e3ce;hb=ae676958d922068ff5890f29d7cf983c7ae00b6a;hp=b2da99880a220dc0023cb9ba821fabb81b808e7d;hpb=5aa342ed75e7774734a2dcff8c219970ddeb5a7e;p=lyx.git diff --git a/src/BufferView.cpp b/src/BufferView.cpp index b2da99880a..2739e00ba3 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -707,9 +707,7 @@ Change const BufferView::getCurrentChange() const DocIterator dit = d->cursor_.selectionBegin(); // The selected content might have been changed (see #7685) - while (dit.inMathed()) - // Find enclosing text cursor - dit.pop_back(); + dit = dit.getInnerText(); return dit.paragraph().lookupChange(dit.pos()); } @@ -1132,11 +1130,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag) case LFUN_CHANGE_PREVIOUS: case LFUN_ALL_CHANGES_ACCEPT: case LFUN_ALL_CHANGES_REJECT: - // TODO: context-sensitive enabling of LFUNs - // In principle, these command should only be enabled if there - // is a change in the document. However, without proper - // optimizations, this will inevitably result in poor performance. - flag.setEnabled(true); + flag.setEnabled(buffer_.areChangesPresent()); break; case LFUN_SCREEN_UP: @@ -1593,7 +1587,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) break; case LFUN_MARK_TOGGLE: - cur.setSelection(false); + cur.selection(false); if (cur.mark()) { cur.setMark(false); dr.setMessage(from_utf8(N_("Mark removed"))); @@ -1792,7 +1786,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) // Select the inset from outside. cur.pop(); cur.resetAnchor(); - cur.setSelection(true); + cur.selection(true); cur.posForward(); } else if (cells_selected) { // At least one complete cell is selected and inset is a table. @@ -1800,7 +1794,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) cur.idx() = 0; cur.pos() = 0; cur.resetAnchor(); - cur.setSelection(true); + cur.selection(true); cur.idx() = cur.lastidx(); cur.pos() = cur.lastpos(); } else { @@ -1808,7 +1802,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) cur.pit() = 0; cur.pos() = 0; cur.resetAnchor(); - cur.setSelection(true); + cur.selection(true); cur.pit() = cur.lastpit(); cur.pos() = cur.lastpos(); } @@ -2193,7 +2187,7 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0) Cursor old = cursor(); Cursor cur(*this); cur.push(buffer_.inset()); - cur.setSelection(d->cursor_.selection()); + cur.selection(d->cursor_.selection()); // Either the inset under the cursor or the // surrounding Text will handle this event. @@ -2380,7 +2374,7 @@ void BufferView::setCursorFromRow(int row, TexRow const & texrow) } d->cursor_.reset(); buffer_.text().setCursor(d->cursor_, newpit, newpos); - d->cursor_.setSelection(false); + d->cursor_.selection(false); d->cursor_.resetAnchor(); recenter(); } @@ -2466,7 +2460,7 @@ void BufferView::setCursor(DocIterator const & dit) dit[i].inset().edit(d->cursor_, true); d->cursor_.setCursor(dit); - d->cursor_.setSelection(false); + d->cursor_.selection(false); d->cursor_.setCurrentFont(); // FIXME // It seems on general grounds as if this is probably needed, but @@ -2595,7 +2589,7 @@ bool BufferView::selectIfEmpty(DocIterator & cur) d->cursor_.setCursor(cur); d->cursor_.pit() = beg_pit; d->cursor_.pos() = 0; - d->cursor_.setSelection(false); + d->cursor_.selection(false); d->cursor_.resetAnchor(); d->cursor_.pit() = end_pit; d->cursor_.pos() = end_pos; @@ -2920,15 +2914,26 @@ int BufferView::horizScrollOffset() const } -CursorSlice const & BufferView::currentRowSlice() const +int BufferView::horizScrollOffset(Text const * text, + pit_type pit, pos_type pos) const { - return d->current_row_slice_; + // Is this a row that is currently scrolled? + if (!d->current_row_slice_.empty() + && &text->inset() == d->current_row_slice_.inset().asInsetText() + && pit == d->current_row_slice_.pit() + && pos == d->current_row_slice_.pos()) + return d->horiz_scroll_offset_; + return 0; } -CursorSlice const & BufferView::lastRowSlice() const +bool BufferView::hadHorizScrollOffset(Text const * text, + pit_type pit, pos_type pos) const { - return d->last_row_slice_; + return !d->last_row_slice_.empty() + && &text->inset() == d->last_row_slice_.inset().asInsetText() + && pit == d->last_row_slice_.pit() + && pos == d->last_row_slice_.pos(); } @@ -2994,8 +2999,7 @@ void BufferView::checkCursorScrollOffset(PainterInfo & pi) bool const drawing = pi.pain.isDrawingEnabled(); pi.pain.setDrawingEnabled(false); // No need to care about vertical position. - RowPainter rp(pi, buffer().text(), d->cursor_.bottom().pit(), row, - -d->horiz_scroll_offset_, 0); + RowPainter rp(pi, buffer().text(), row, -d->horiz_scroll_offset_, 0); rp.paintText(); pi.pain.setDrawingEnabled(drawing); }