]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.cpp
* There are cases where updateLabels is not called because no
[lyx.git] / src / DocIterator.cpp
index 174dec29bfd97e1e3543ee9880a3563fea43187d..f444f42193a1e7c692c332635cd58bb36069ac4b 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <ostream>
 
+using namespace std;
 
 namespace lyx {
 
@@ -246,24 +247,16 @@ Inset * DocIterator::innerInsetOfType(int code) const
 }
 
 
-void DocIterator::forwardPos(bool ignorecollapsed)
+// This duplicates code above, but is in the critical path.
+// So please think twice before adding stuff
+void DocIterator::forwardPos()
 {
-       //this dog bites his tail
+       // this dog bites his tail
        if (empty()) {
                push_back(CursorSlice(*inset_));
                return;
        }
 
-       Inset * const nextinset = nextInset();
-       // 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() != Inset::HIGHLY_EDITABLE)) {
-               ++top().pos();
-               return;
-       }
-
        CursorSlice & tip = top();
        //lyxerr << "XXX\n" << *this << endl;
 
@@ -301,6 +294,20 @@ void DocIterator::forwardPos(bool ignorecollapsed)
 }
 
 
+void DocIterator::forwardPosIgnoreCollapsed()
+{
+       Inset * const nextinset = nextInset();
+       // FIXME: the check for asInsetMath() shouldn't be necessary
+       // but math insets do not return a sensible editable() state yet.
+       if (nextinset && !nextinset->asInsetMath()
+           && nextinset->editable() != Inset::HIGHLY_EDITABLE) {
+               ++top().pos();
+               return;
+       }
+       forwardPos();
+}
+
+
 void DocIterator::forwardPar()
 {
        forwardPos();
@@ -496,9 +503,9 @@ DocIterator::idx_type DocIterator::find(InsetMath const * inset) const
 }
 
 
-void DocIterator::cutOff(DocIterator::idx_type above, std::vector<CursorSlice> & cut)
+void DocIterator::cutOff(DocIterator::idx_type above, vector<CursorSlice> & cut)
 {
-       cut = std::vector<CursorSlice>(slices_.begin() + above + 1, slices_.end());
+       cut = vector<CursorSlice>(slices_.begin() + above + 1, slices_.end());
        slices_.resize(above + 1);
 }
 
@@ -509,7 +516,7 @@ void DocIterator::cutOff(DocIterator::idx_type above)
 }
 
 
-void DocIterator::append(std::vector<CursorSlice> const & x) 
+void DocIterator::append(vector<CursorSlice> const & x) 
 {
        slices_.insert(slices_.end(), x.begin(), x.end());
 }
@@ -523,7 +530,7 @@ void DocIterator::append(DocIterator::idx_type idx, pos_type pos)
 }
 
 
-std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
+ostream & operator<<(ostream & os, DocIterator const & dit)
 {
        for (size_t i = 0, n = dit.depth(); i != n; ++i)
                os << " " << dit[i] << "\n";
@@ -531,29 +538,6 @@ 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);
-}
-
-
 ///////////////////////////////////////////////////////
 
 StableDocIterator::StableDocIterator(DocIterator const & dit)
@@ -592,7 +576,7 @@ DocIterator StableDocIterator::asDocIterator(Inset * inset) const
 }
 
 
-std::ostream & operator<<(std::ostream & os, StableDocIterator const & dit)
+ostream & operator<<(ostream & os, StableDocIterator const & dit)
 {
        for (size_t i = 0, n = dit.data_.size(); i != n; ++i)
                os << " " << dit.data_[i] << "\n";