]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_iterator.C
IU of clone() and getLabelList()
[lyx.git] / src / mathed / math_iterator.C
index 8b70f3d52303d2b861e851e394583e762a00df20..bf207171816772bd13d4ac4560b5f2f43374269e 100644 (file)
@@ -1,3 +1,4 @@
+
 #include <config.h>
 
 #include "math_iterator.h"
@@ -16,22 +17,22 @@ MathIterator::MathIterator(MathInset * p)
 }
 
 
-MathInset const * MathIterator::par() const
+MathInset const * MathIterator::inset() const
 {
-       return back().par_;
+       return back().inset_;
 }
 
 
-MathInset * MathIterator::par()
+MathInset * MathIterator::inset()
 {
-       return back().par_;
+       return back().inset_;
 }
 
 
 MathArray const & MathIterator::cell() const
 {
-       MathCursorPos const & top = back();
-       return top.par_->cell(top.idx_);
+       CursorPos const & top = back();
+       return top.inset_->cell(top.idx_);
 }
 
 
@@ -39,7 +40,7 @@ MathArray const & MathIterator::cell() const
 void MathIterator::push(MathInset * p)
 {
        //lyxerr << "push: " << p << endl;
-       push_back(MathCursorPos(p));
+       push_back(CursorPos(p));
 }
 
 
@@ -51,13 +52,13 @@ void MathIterator::pop()
 }
 
 
-MathCursorPos const & MathIterator::operator*() const
+CursorPos const & MathIterator::operator*() const
 {
        return back();
 }
 
 
-MathCursorPos const & MathIterator::operator->() const
+CursorPos const & MathIterator::operator->() const
 {
        return back();
 }
@@ -65,16 +66,16 @@ MathCursorPos const & MathIterator::operator->() const
 
 void MathIterator::goEnd()
 {
-       MathCursorPos & top = back();
-       top.idx_ = top.par_->nargs() - 1;
+       CursorPos & top = back();
+       top.idx_ = top.inset_->nargs() - 1;
        top.pos_ = cell().size();
 }
 
 
 void MathIterator::operator++()
 {
-       MathCursorPos   & top = back();
-       MathArray & ar  = top.par_->cell(top.idx_);
+       CursorPos & top = back();
+       MathArray     & ar  = top.inset_->cell(top.idx_);
 
        // move into the current inset if possible
        // it is impossible for pos() == size()!
@@ -94,10 +95,10 @@ void MathIterator::operator++()
        }
 
        // otherwise try to move on one cell if possible
-       while (top.idx_ + 1 < top.par_->nargs()) {
+       while (top.idx_ + 1 < top.inset_->nargs()) {
                // idx() == nargs() is _not_ valid!
                ++top.idx_;
-               if (top.par_->validCell(top.idx_)) {
+               if (top.inset_->validCell(top.idx_)) {
                        top.pos_ = 0;
                        return;
                }
@@ -119,6 +120,19 @@ void MathIterator::jump(difference_type i)
 }
 
 
+bool MathIterator::normal() const
+{
+       return back().pos_ < cell().size();
+}
+
+
+void MathIterator::shrink(size_type i)
+{
+       if (i < size())
+               erase(begin() + i, end());
+}
+
+
 bool operator==(MathIterator const & it, MathIterator const & jt)
 {
        return MathIterator::base_type(it) == MathIterator::base_type(jt);