}
+void BufferView::setSelection(DocIterator const & from,
+ DocIterator const & to)
+{
+ if (from.pit() != to.pit()) {
+ // there are multiple paragraphs in selection
+ cursor().setCursor(from);
+ cursor().clearSelection();
+ cursor().selection(true);
+ cursor().setCursor(to);
+ cursor().selection(true);
+ } else {
+ // only single paragraph
+ int const size = to.pos() - from.pos();
+ putSelectionAt(from, size, false);
+ }
+ processUpdateFlags(Update::Force | Update::FitCursor);
+}
+
+
bool BufferView::selectIfEmpty(DocIterator & cur)
{
if ((cur.inTexted() && !cur.paragraph().empty())
*/
void putSelectionAt(DocIterator const & cur,
int length, bool backwards);
+ /// set a selection between \p from and \p to
+ void setSelection(DocIterator const & from,
+ DocIterator const & to);
/// selects the item at cursor if its paragraph is empty.
bool selectIfEmpty(DocIterator & cur);
void check();
/// close the spell checker dialog
void hide() const;
- /// make/restore a selection between from and to
- void setSelection(DocIterator const & from, DocIterator const & to) const;
/// if no selection was checked:
/// ask the user if the check should start over
bool continueFromBeginning();
if (isCurrentBuffer(bvcur)) {
if (!begin_.empty() && !end_.empty()) {
// restore previous selection
- setSelection(begin_, end_);
+ bv->setSelection(begin_, end_);
} else {
// restore cursor position
bvcur.setCursor(start_);
}
}
-void SpellcheckerWidget::Private::setSelection(
- DocIterator const & from, DocIterator const & to) const
-{
- BufferView * bv = gv_->documentBufferView();
- DocIterator end = to;
-
- if (from.pit() != end.pit()) {
- // there are multiple paragraphs in selection
- Cursor & bvcur = bv->cursor();
- bvcur.setCursor(from);
- bvcur.clearSelection();
- bvcur.selection(true);
- bvcur.setCursor(end);
- bvcur.selection(true);
- } else {
- // FIXME LFUN
- // If we used a LFUN, dispatch would do all of this for us
- int const size = end.pos() - from.pos();
- bv->putSelectionAt(from, size, false);
- }
- bv->processUpdateFlags(Update::Force | Update::FitCursor);
-}
-
void SpellcheckerWidget::Private::forward()
{
DocIterator const from = cursor();
return;
setLanguage(word_lang.lang());
// mark misspelled word
- setSelection(from, to);
+ bv->setSelection(from, to);
// enable relevant widgets
updateView();
}
return true;
}
-void setSelection(BufferView * bv, DocIterator const & from, DocIterator const & to)
-{
- DocIterator end = to;
-
- if (from.pit() != end.pit()) {
- // there are multiple paragraphs in selection
- Cursor & bvcur = bv->cursor();
- bvcur.setCursor(from);
- bvcur.clearSelection();
- bvcur.selection(true);
- bvcur.setCursor(end);
- bvcur.selection(true);
- } else {
- // FIXME LFUN
- // If we used a LFUN, dispatch would do all of this for us
- int const size = end.pos() - from.pos();
- bv->putSelectionAt(from, size, false);
- }
- bv->processUpdateFlags(Update::Force | Update::FitCursor);
-}
-
} // namespace
// restore original selection
if (had_selection) {
bv->cursor().resetAnchor();
- setSelection(bv, startcur, endcur);
+ bv->setSelection(startcur, endcur);
}
return false;
}
if (had_selection) {
endcur.fixIfBroken();
bv->cursor().resetAnchor();
- setSelection(bv, startcur, endcur);
+ bv->setSelection(startcur, endcur);
}
return num;