Juergen Spitzmueller wrote:
> Instead, we could implement a dociterator::forwardPosIgnoreCollapsed()
> method, which basically contains the same code.
That would be the attached. Personally, I'd prefer this one.
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 13:51:11 -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 13:51:12 -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.forwardPosIgnoreCollapsed()) {
// 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 13:51:13 -0000
@@ -393,6 +393,25 @@ void DocIterator::forwardPosNoDescend()
}
+void DocIterator::forwardPosIgnoreCollapsed()
+{
+ //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 (nextInset() && (!nextInset()->asMathInset()
+ && nextInset()->editable() != InsetBase::HIGHLY_EDITABLE)) {
+ ++top().pos();
+ return;
+ }
+ forwardPos();
+}
+
+
void DocIterator::forwardPar()
{
forwardPos();
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 13:51:14 -0000
@@ -178,6 +178,8 @@ public:
//
/// move on one logical position, do not descend into nested insets
void forwardPosNoDescend();
+ /// move on one logical position, do not descend into collapsed insets
+ void forwardPosIgnoreCollapsed();
/// move on one logical position, descend into nested insets
void forwardPos();
/// move on one physical character or inset