#include "mathed/math_inset.h"
#include <boost/assert.hpp>
+#include <boost/current_function.hpp>
using std::endl;
// We could be able to get rid of this if only every BufferView were
// associated to a buffer on construction.
DocIterator::DocIterator()
- : inset_(0)
+ : boundary_(false), inset_(0)
{}
DocIterator::DocIterator(InsetBase & inset)
- : inset_(&inset)
+ : boundary_(false), inset_(&inset)
{}
Paragraph & DocIterator::paragraph()
{
+ if (!inTexted())
+ lyxerr << *this << endl;
BOOST_ASSERT(inTexted());
return top().paragraph();
}
Row & DocIterator::textRow()
{
BOOST_ASSERT(!paragraph().rows().empty());
- return paragraph().getRow(pos());
+ return paragraph().getRow(pos(), boundary_);
}
Row const & DocIterator::textRow() const
{
BOOST_ASSERT(!paragraph().rows().empty());
- return paragraph().getRow(pos());
+ return paragraph().getRow(pos(), boundary_);
}
}
+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
}
os << " " << dit.data_[i] << "\n";
return os;
}
+
+
+bool operator==(StableDocIterator const & dit1, StableDocIterator const & dit2)
+{
+ return dit1.data_ == dit2.data_;
+}
+