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
This commit is contained in:
Jürgen Spitzmüller 2006-01-28 09:46:58 +00:00
parent 0b281dcea7
commit 02127298e7
5 changed files with 30 additions and 9 deletions

View File

@ -1,3 +1,16 @@
2006-01-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* 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 <j.spitzmueller@gmx.de>
* buffer.C: change tracking (dvipost) doesn't require

View File

@ -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: "

View File

@ -128,7 +128,7 @@ namespace {
double best_dist = std::numeric_limits<double>::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_))) {

View File

@ -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;

View File

@ -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