Jean-Marc Lasgouttes wrote:
> Juergen> That would be the attached. Personally, I'd prefer this one.
>
> Wouldn't it be easier to add a bool ignorecollapsed (defaulting to
> true) to forwardPos? I know Andre' does not like it in general, but it
> seems reasonable.
Yes, why not (although it should default to false IMHO).
How about the attached, fourth version, then?
Jürgen
Index: src/bufferview_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v
retrieving revision 1.157
diff -p -u -r1.157 bufferview_funcs.C
--- src/bufferview_funcs.C 10 Nov 2005 08:28:06 -0000 1.157
+++ src/bufferview_funcs.C 27 Jan 2006 15:30:27 -0000
@@ -163,11 +163,7 @@ Point coordOffset(DocIterator const & di
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: "
Index: src/cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.142
diff -p -u -r1.142 cursor.C
--- src/cursor.C 19 Jan 2006 15:49:20 -0000 1.142
+++ src/cursor.C 27 Jan 2006 15:30:29 -0000
@@ -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_))) {
Index: src/dociterator.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.C,v
retrieving revision 1.33
diff -p -u -r1.33 dociterator.C
--- src/dociterator.C 24 Nov 2005 16:22:39 -0000 1.33
+++ src/dociterator.C 27 Jan 2006 15:30:29 -0000
@@ -289,11 +289,20 @@ InsetBase * DocIterator::innerInsetOfTyp
}
-void DocIterator::forwardPos()
+void DocIterator::forwardPos(bool ignorecollapsed)
{
//this dog bites his tail
if (empty()) {
push_back(CursorSlice(*inset_));
+ 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;
}
Index: src/dociterator.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.h,v
retrieving revision 1.25
diff -p -u -r1.25 dociterator.h
--- src/dociterator.h 24 Nov 2005 16:22:39 -0000 1.25
+++ src/dociterator.h 27 Jan 2006 15:30:30 -0000
@@ -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