]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.cpp
* do not lookup the same macro all the time
[lyx.git] / src / DocIterator.cpp
index f6b3b87293eed7509a020c3ad955fa477dc0d3a9..3ef66b46c705307d2ea416bf93df8d05d5d4df56 100644 (file)
@@ -191,7 +191,7 @@ Paragraph const & DocIterator::innerParagraph() const
                        return slices_[i].paragraph();
 
        // This case is in principe not possible. We _must_
-       // we inside a Paragraph.
+       // be inside a Paragraph.
        BOOST_ASSERT(false);
        return paragraph();
 }
@@ -432,6 +432,19 @@ void DocIterator::forwardPar()
 }
 
 
+void DocIterator::forwardIdx()
+{
+       CursorSlice & tip = top();
+
+       //prevent endless loops
+       BOOST_ASSERT(tip.idx() < lastidx());
+
+       ++tip.idx();
+       tip.pit() = 0;
+       tip.pos() = 0;
+}
+
+
 void DocIterator::forwardChar()
 {
        forwardPos();
@@ -553,6 +566,28 @@ std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
 }
 
 
+bool operator<(DocIterator const & p, DocIterator const & q)
+{
+       size_t depth = std::min(p.depth(), q.depth());
+       for (size_t i = 0 ; i < depth ; ++i) {
+               if (p[i] != q[i])
+                       return p[i] < q[i];
+       }
+       return p.depth() < q.depth();
+}
+
+
+bool operator>(DocIterator const & p, DocIterator const & q)
+{
+       return q < p;
+}
+
+
+bool operator<=(DocIterator const & p, DocIterator const & q)
+{
+       return !(q < p);
+}
+
 
 ///////////////////////////////////////////////////////