#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 <boost/assert.hpp>
#include <boost/current_function.hpp>
+
+namespace lyx {
+
using std::endl;
}
-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();
}
}
-void DocIterator::forwardPos()
+void DocIterator::forwardPos(bool ignorecollapsed)
{
//this dog bites his tail
if (empty()) {
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;
}
//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();
}
{
forwardPos();
-#if 0
- DocIterator cmp(*this);
-#endif
-
while (!empty() && (!inTexted() || pos() != 0)) {
if (inTexted()) {
pos_type const lastp = lastpos();
}
forwardPos();
}
-
-#if 0
- while (!cmp.empty() && (!cmp.inTexted() || cmp.pos() != 0))
- cmp.forwardPos();
- BOOST_ASSERT(cmp == *this);
-#endif
}
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();
+ }
}
}
-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.
return dit1.data_ == dit2.data_;
}
+
+} // namespace lyx