X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView.cpp;h=fc7c7bb80828f9a977d39c12ef906120a7c6a56c;hb=7c63b4f2603f2bccb00a9266fed08a14dcc0fb9c;hp=8d0539428aa0a21b8243032e0d117b26b5476743;hpb=624f725acb45d181fc46a1b79cfe7989fcd757bd;p=lyx.git diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 8d0539428a..fc7c7bb808 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -700,7 +700,6 @@ CursorStatus BufferView::cursorStatus(DocIterator const & dit) const void BufferView::bookmarkEditPosition() { - d->cursor_.markEditPosition(); // Don't eat cpu time for each keystroke if (d->cursor_.paragraph().id() == d->bookmark_edit_position_) return; @@ -1752,7 +1751,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) Inset * ins = cur.nextInset(); if (!ins) break; - docstring insname = ins->name(); + docstring insname = ins->layoutName(); while (!insname.empty()) { if (insname == name || name == from_utf8("*")) { cur.recordUndo(); @@ -2244,6 +2243,7 @@ TextMetrics const & BufferView::textMetrics(Text const * t) const TextMetrics & BufferView::textMetrics(Text const * t) { + LASSERT(t, /**/); TextMetricsCache::iterator tmc_it = d->text_metrics_.find(t); if (tmc_it == d->text_metrics_.end()) { tmc_it = d->text_metrics_.insert( @@ -2363,6 +2363,42 @@ void BufferView::putSelectionAt(DocIterator const & cur, } +bool BufferView::selectIfEmpty(DocIterator & cur) +{ + if (!cur.paragraph().empty()) + return false; + + pit_type const beg_pit = cur.pit(); + if (beg_pit > 0) { + // The paragraph associated to this item isn't + // the first one, so it can be selected + cur.backwardPos(); + } else { + // We have to resort to select the space between the + // end of this item and the begin of the next one + cur.forwardPos(); + } + if (cur.empty()) { + // If it is the only item in the document, + // nothing can be selected + return false; + } + pit_type const end_pit = cur.pit(); + pos_type const end_pos = cur.pos(); + d->cursor_.clearSelection(); + d->cursor_.reset(); + d->cursor_.setCursor(cur); + d->cursor_.pit() = beg_pit; + d->cursor_.pos() = 0; + d->cursor_.setSelection(false); + d->cursor_.resetAnchor(); + d->cursor_.pit() = end_pit; + d->cursor_.pos() = end_pos; + d->cursor_.setSelection(); + return true; +} + + Cursor & BufferView::cursor() { return d->cursor_;