From 02127298e723a5c1f7aab241d7f04fc1cfb38be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 28 Jan 2006 09:46:58 +0000 Subject: [PATCH] Implement a dociterator::forwardPos() variant that skips collapsed insets and use that in bruteFind() (fixes bug 2241 and bug 2094) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10782 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 13 +++++++++++++ src/bufferview_funcs.C | 6 +----- src/cursor.C | 2 +- src/dociterator.C | 11 ++++++++++- src/dociterator.h | 7 +++++-- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index da39916d4b..83dd478997 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2006-01-28 Jürgen Spitzmüller + + * bufferview_funcs.C (coordOffset): remove the check for + collapsed collapsables (fix for bug 2094). This is now done + on a more general level (cursor.C). + + * dociterator.[Ch] (forwardPos): add an optional argument + bool "ignorecollapsed" (default false), which lets forwardPos + skip collapsed insets. + + * cursor.C (bruteFind): use forwardPos(ignorecollapsed = true) + (fixes bug 2241 and 2094). + 2006-01-26 Jürgen Spitzmüller * buffer.C: change tracking (dvipost) doesn't require diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 41f94771b8..fedeccdd6b 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -163,11 +163,7 @@ Point coordOffset(DocIterator const & dit, bool boundary) CursorSlice const & sl = dit[i]; int xx = 0; int yy = 0; - //FIXME: the check for asMathInset() shouldn't be necessary - // but math insets do not return a sensible editable() state yet. - if (sl.inset().asMathInset() - || sl.inset().editable() == InsetBase::HIGHLY_EDITABLE) - sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy); + sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy); x += xx; y += yy; //lyxerr << "LCursor::getPos, i: " diff --git a/src/cursor.C b/src/cursor.C index a173178581..de6463b518 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -128,7 +128,7 @@ namespace { double best_dist = std::numeric_limits::max();; DocIterator best_cursor = et; - for ( ; it != et; it.forwardPos()) { + for ( ; it != et; it.forwardPos(true)) { // avoid invalid nesting when selecting if (bv_funcs::status(&cursor.bv(), it) == bv_funcs::CUR_INSIDE && (!cursor.selection() || positionable(it, cursor.anchor_))) { diff --git a/src/dociterator.C b/src/dociterator.C index 0b3e0567ec..565a43f894 100644 --- a/src/dociterator.C +++ b/src/dociterator.C @@ -289,7 +289,7 @@ InsetBase * DocIterator::innerInsetOfType(int code) const } -void DocIterator::forwardPos() +void DocIterator::forwardPos(bool ignorecollapsed) { //this dog bites his tail if (empty()) { @@ -297,6 +297,15 @@ void DocIterator::forwardPos() return; } + // jump over collapsables if they are collapsed + // FIXME: the check for asMathInset() shouldn't be necessary + // but math insets do not return a sensible editable() state yet. + if (ignorecollapsed && nextInset() && (!nextInset()->asMathInset() + && nextInset()->editable() != InsetBase::HIGHLY_EDITABLE)) { + ++top().pos(); + return; + } + CursorSlice & tip = top(); //lyxerr << "XXX\n" << *this << endl; diff --git a/src/dociterator.h b/src/dociterator.h index fa6824b88f..f8f4b490f5 100644 --- a/src/dociterator.h +++ b/src/dociterator.h @@ -178,8 +178,11 @@ public: // /// move on one logical position, do not descend into nested insets void forwardPosNoDescend(); - /// move on one logical position, descend into nested insets - void forwardPos(); + /** + * move on one logical position, descend into nested insets + * skip collapsed insets if \p ignorecollapsed is true + */ + void forwardPos(bool ignorecollapsed = false); /// move on one physical character or inset void forwardChar(); /// move on one paragraph