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());
}
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:
break;
case LFUN_MARK_TOGGLE:
- cur.setSelection(false);
+ cur.selection(false);
if (cur.mark()) {
cur.setMark(false);
dr.setMessage(from_utf8(N_("Mark removed")));
// 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.
cur.idx() = 0;
cur.pos() = 0;
cur.resetAnchor();
- cur.setSelection(true);
+ cur.selection(true);
cur.idx() = cur.lastidx();
cur.pos() = cur.lastpos();
} else {
cur.pit() = 0;
cur.pos() = 0;
cur.resetAnchor();
- cur.setSelection(true);
+ cur.selection(true);
cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
}
if (!cur.nextInset() || cur.nextInset() == ins)
cur.forwardInset();
}
- cur.endUndoGroup();
cur = savecur;
cur.fixIfBroken();
+ /** This is a dummy undo record only to remember the cursor
+ * that has just been set; this will be used on a redo action
+ * (see ticket #10097)
+
+ * FIXME: a better fix would be to have a way to set the
+ * cursor value directly, but I am not sure it is worth it.
+ */
+ cur.recordUndo();
+ cur.endUndoGroup();
dr.screenUpdate(Update::Force);
dr.forceBufferUpdate();
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.
}
d->cursor_.reset();
buffer_.text().setCursor(d->cursor_, newpit, newpos);
- d->cursor_.setSelection(false);
+ d->cursor_.selection(false);
d->cursor_.resetAnchor();
recenter();
}
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
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;
}
-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();
}
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);
}