[LyX/master] #6401 improve doc iterator to allow easy backward navigation
Stephan Witt
switt at lyx.org
Sun Aug 16 14:28:19 UTC 2020
commit ba21c946a1583d0b1f68f34f2ea378887ed502f9
Author: Stephan Witt <switt at lyx.org>
Date: Sun Aug 16 16:54:03 2020 +0200
#6401 improve doc iterator to allow easy backward navigation
---
src/DocIterator.cpp | 12 ++++++++++++
src/DocIterator.h | 4 ++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp
index 0f4bc10..6eba5a7 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 8ee4d4e..69930fc 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
More information about the lyx-cvs
mailing list