]> git.lyx.org Git - lyx.git/blobdiff - src/dociterator.C
* Painter.h:
[lyx.git] / src / dociterator.C
index 0b3e0567ec476da5f79e0194247707858ceccd6b..47e7526e5e00d0af03eaa4357c73f84ac0bd3f4d 100644 (file)
 #include "lyxrow.h"
 #include "paragraph.h"
 
-#include "mathed/math_data.h"
-#include "mathed/math_inset.h"
+#include "mathed/MathData.h"
+#include "mathed/InsetMath.h"
+
 #include "insets/insettabular.h"
 
 #include <boost/assert.hpp>
 #include <boost/current_function.hpp>
 
+
+namespace lyx {
+
 using std::endl;
 
 
@@ -180,13 +184,13 @@ Row const & DocIterator::textRow() const
 }
 
 
-DocIterator::pit_type DocIterator::lastpit() const
+pit_type DocIterator::lastpit() const
 {
        return inMathed() ? 0 : text()->paragraphs().size() - 1;
 }
 
 
-DocIterator::pos_type DocIterator::lastpos() const
+pos_type DocIterator::lastpos() const
 {
        return inMathed() ? cell().size() : paragraph().size();
 }
@@ -289,7 +293,7 @@ InsetBase * DocIterator::innerInsetOfType(int code) const
 }
 
 
-void DocIterator::forwardPos()
+void DocIterator::forwardPos(bool ignorecollapsed)
 {
        //this dog bites his tail
        if (empty()) {
@@ -297,6 +301,15 @@ void DocIterator::forwardPos()
                return;
        }
 
+       // jump over collapsables if they are collapsed
+       // FIXME: the check for asInsetMath() shouldn't be necessary
+       // but math insets do not return a sensible editable() state yet.
+       if (ignorecollapsed && nextInset() && (!nextInset()->asInsetMath()
+           && nextInset()->editable() != InsetBase::HIGHLY_EDITABLE)) {
+               ++top().pos();
+               return;
+       }
+
        CursorSlice & tip = top();
        //lyxerr << "XXX\n" << *this << endl;
 
@@ -389,7 +402,11 @@ void DocIterator::forwardPosNoDescend()
        }
        //lyxerr << "... no next idx" << endl;
 
-       // otherwise we can't move on
+       // otherwise leave inset and jump over inset as a whole
+       pop_back();
+       // 'top' is invalid now...
+       if (!empty())
+               ++top().pos();
 }
 
 
@@ -503,7 +520,7 @@ bool DocIterator::hasPart(DocIterator const & it) const
 }
 
 
-void DocIterator::updateInsets(InsetBase * inset) 
+void DocIterator::updateInsets(InsetBase * inset)
 {
        // this function re-creates the cache of inset pointers.
        // code taken in part from StableDocIterator::asDocIterator.
@@ -579,3 +596,5 @@ bool operator==(StableDocIterator const & dit1, StableDocIterator const & dit2)
        return dit1.data_ == dit2.data_;
 }
 
+
+} // namespace lyx