X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fdociterator.C;h=74c5aa38a6b510c4f547c3a62e00fe3040151509;hb=87cd77d1fc819bc8f14982fc6b20091720c011f5;hp=81f465826baa3d697e9c56a20b9d554464a5a6d3;hpb=aa491cdb98f6e99827324c41fede08bb789d67c6;p=lyx.git diff --git a/src/dociterator.C b/src/dociterator.C index 81f465826b..74c5aa38a6 100644 --- a/src/dociterator.C +++ b/src/dociterator.C @@ -138,6 +138,8 @@ LyXText const * DocIterator::text() const Paragraph & DocIterator::paragraph() { + if (!inTexted()) + lyxerr << *this << endl; BOOST_ASSERT(inTexted()); return top().paragraph(); } @@ -341,11 +343,66 @@ void DocIterator::forwardPos() } +void DocIterator::forwardPosNoDescend() +{ + CursorSlice & tip = top(); + pos_type const lastp = lastpos(); + + // move on one position if possible + if (tip.pos() < lastp) { + //lyxerr << "... next pos" << endl; + ++tip.pos(); + return; + } + //lyxerr << "... no next pos" << endl; + + // otherwise move on one paragraph if possible + if (tip.pit() < lastpit()) { + //lyxerr << "... next par" << endl; + ++tip.pit(); + tip.pos() = 0; + return; + } + //lyxerr << "... no next pit" << endl; + + // otherwise try to move on one cell if possible + if (tip.idx() < lastidx()) { + //lyxerr << "... next idx" << endl; + ++tip.idx(); + tip.pit() = 0; + tip.pos() = 0; + return; + } + //lyxerr << "... no next idx" << endl; + + // otherwise we can't move on +} + + void DocIterator::forwardPar() { forwardPos(); - while (!empty() && (!inTexted() || pos() != 0)) + +#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; + } forwardPos(); + } + +#if 0 + while (!cmp.empty() && (!cmp.inTexted() || cmp.pos() != 0)) + cmp.forwardPos(); + BOOST_ASSERT(cmp == *this); +#endif }