X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fdociterator.C;h=bb72fb6c2d71c669dffc61b936fc3a36c9e4beaa;hb=0da3d53269a49c66b24615d24e20e441dcf7c07e;hp=2e314e012f60708c06b95c607dcea98575a870a8;hpb=3b9338a3a8ba33fbbdf2c77cbffb3ff50d8fad86;p=lyx.git diff --git a/src/dociterator.C b/src/dociterator.C index 2e314e012f..bb72fb6c2d 100644 --- a/src/dociterator.C +++ b/src/dociterator.C @@ -15,16 +15,19 @@ #include "debug.h" #include "lyxtext.h" -#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 #include + +namespace lyx { + using std::endl; @@ -166,27 +169,13 @@ Paragraph const & DocIterator::paragraph() const } -Row & DocIterator::textRow() -{ - BOOST_ASSERT(!paragraph().rows().empty()); - return paragraph().getRow(pos(), boundary_); -} - - -Row const & DocIterator::textRow() const -{ - BOOST_ASSERT(!paragraph().rows().empty()); - return paragraph().getRow(pos(), boundary_); -} - - -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(); } @@ -245,18 +234,6 @@ MathArray & DocIterator::cell() } -bool DocIterator::inMathed() const -{ - return !empty() && inset().inMathed(); -} - - -bool DocIterator::inTexted() const -{ - return !empty() && !inset().inMathed(); -} - - LyXText * DocIterator::innerText() { BOOST_ASSERT(!empty()); @@ -297,11 +274,12 @@ void DocIterator::forwardPos(bool ignorecollapsed) return; } + InsetBase * const nextinset = nextInset(); // jump over collapsables if they are collapsed - // FIXME: the check for asMathInset() shouldn't be necessary + // FIXME: the check for asInsetMath() 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)) { + if (ignorecollapsed && nextinset && (!nextinset->asInsetMath() + && nextinset->editable() != InsetBase::HIGHLY_EDITABLE)) { ++top().pos(); return; } @@ -398,7 +376,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(); } @@ -406,26 +388,19 @@ void DocIterator::forwardPar() { forwardPos(); -#if 0 - DocIterator cmp(*this); -#endif - while (!empty() && (!inTexted() || pos() != 0)) { if (inTexted()) { pos_type const lastp = lastpos(); Paragraph const & par = paragraph(); pos_type & pos = top().pos(); - while (pos < lastp && !par.isInset(pos)) - ++pos; + if (par.insetlist.empty()) + pos = lastp; + else + while (pos < lastp && !par.isInset(pos)) + ++pos; } forwardPos(); } - -#if 0 - while (!cmp.empty() && (!cmp.inTexted() || cmp.pos() != 0)) - cmp.forwardPos(); - BOOST_ASSERT(cmp == *this); -#endif } @@ -440,8 +415,19 @@ void DocIterator::forwardChar() void DocIterator::forwardInset() { forwardPos(); - while (!empty() && (pos() == lastpos() || nextInset() == 0)) + + while (!empty() && !nextInset()) { + if (inTexted()) { + pos_type const lastp = lastpos(); + Paragraph const & par = paragraph(); + pos_type & pos = top().pos(); + while (pos < lastp && !par.isInset(pos)) + ++pos; + if (pos < lastp) + break; + } forwardPos(); + } } @@ -587,3 +573,6 @@ bool operator==(StableDocIterator const & dit1, StableDocIterator const & dit2) { return dit1.data_ == dit2.data_; } + + +} // namespace lyx