From: Stephan Witt Date: Sun, 16 Aug 2020 14:54:03 +0000 (+0200) Subject: #6401 improve doc iterator to allow easy backward navigation X-Git-Tag: lyx-2.4.0dev-acb2ca7b~366 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ba21c946a1583d0b1f68f34f2ea378887ed502f9;p=features.git #6401 improve doc iterator to allow easy backward navigation --- diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp index 0f4bc10fac..6eba5a792e 100644 --- a/src/DocIterator.cpp +++ b/src/DocIterator.cpp @@ -500,6 +500,18 @@ void DocIterator::backwardPos() } +void DocIterator::backwardPosIgnoreCollapsed() +{ + backwardPos(); + if (inTexted()) { + Inset const * ins = realInset(); + if (ins && !ins->editable()) { + pop_back(); // move out of collapsed inset + } + } +} + + #if 0 // works, but currently not needed void DocIterator::backwardInset() diff --git a/src/DocIterator.h b/src/DocIterator.h index 8ee4d4e373..69930fcc7d 100644 --- a/src/DocIterator.h +++ b/src/DocIterator.h @@ -69,6 +69,8 @@ public: /// does this iterator have any content? bool empty() const { return slices_.empty(); } + /// is this the begin position? + bool atBegin() const { return depth() == 1 && pit() == 0 && pos() == 0; } /// is this the end position? bool atEnd() const { return slices_.empty(); } @@ -210,6 +212,8 @@ public: void forwardInset(); /// move backward one logical position void backwardPos(); + /// move backward one logical position, skip collapsed insets + void backwardPosIgnoreCollapsed(); /// move backward one physical character or inset void backwardChar(); /// move backward one paragraph