]> git.lyx.org Git - features.git/commitdiff
remove more functions from MathIterator to prepare merger with text-ed
authorAndré Pönitz <poenitz@gmx.net>
Wed, 14 Jan 2004 17:46:46 +0000 (17:46 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 14 Jan 2004 17:46:46 +0000 (17:46 +0000)
cursor slice stack

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8349 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_cursor.C
src/mathed/math_iterator.C
src/mathed/math_iterator.h

index 4cea74dc7ae37fd87d2ea34d48a88feb034eeadd..4cb27cefed36d3ded615d172ecdaed47bf074f65 100644 (file)
@@ -1466,7 +1466,8 @@ DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
                        pos.asMathInset()->dispatch(cmd, pos.idx_, pos.pos_);
                if (res.dispatched()) {
                        if (res.val() == FINISHED) {
-                               Cursor_.shrink(i + 1);
+                               if (i + 1 < Cursor_.size())
+                                       Cursor_.erase(Cursor_.begin() + i + 1, Cursor_.end());
                                selClear();
                        }
                        return res;
index 8c11cad1196d5d6e76f1519ccec6b79336414807..e06157c864bfca74ad0c42029a66347dac85d1e8 100644 (file)
 #include <boost/assert.hpp>
 
 
-MathIterator::MathIterator()
-{}
-
-
-MathIterator::MathIterator(MathInset * p)
-{
-       push(p);
-}
-
-
-
 MathArray const & MathIterator::cell() const
 {
        CursorSlice const & top = back();
@@ -35,30 +24,6 @@ MathArray const & MathIterator::cell() const
 }
 
 
-
-void MathIterator::push(MathInset * p)
-{
-       //lyxerr << "push: " << p << endl;
-       push_back(CursorSlice(p));
-}
-
-
-void MathIterator::pop()
-{
-       //lyxerr << "pop: " << endl;
-       BOOST_ASSERT(size());
-       pop_back();
-}
-
-
-void MathIterator::goEnd()
-{
-       CursorSlice & top = back();
-       top.idx_ = top.asMathInset()->nargs() - 1;
-       top.pos_ = cell().size();
-}
-
-
 void MathIterator::operator++()
 {
        CursorSlice & top = back();
@@ -70,7 +35,7 @@ void MathIterator::operator++()
        if (top.pos_ != ar.size())
                n = (ar.begin() + top.pos_)->nucleus();
        if (n && n->isActive()) {
-               push(n);
+               push_back(CursorSlice(n));
                return;
        }
 
@@ -93,25 +58,12 @@ void MathIterator::operator++()
 
        // otherwise leave array, move on one back
        // this might yield pos() == size(), but that's a ok.
-       pop();
+       pop_back();
        // it certainly invalidates top
        ++back().pos_;
 }
 
 
-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);
@@ -126,13 +78,19 @@ bool operator!=(MathIterator const & it, MathIterator const & jt)
 
 MathIterator ibegin(MathInset * p)
 {
-       return MathIterator(p);
+       MathIterator it;
+       it.push_back(CursorSlice(p));
+       return it;
 }
 
 
 MathIterator iend(MathInset * p)
 {
-       MathIterator it(p);
-       it.goEnd();
+       MathIterator it;
+       it.push_back(CursorSlice(p));
+       return it;
+       CursorSlice & top = it.back();
+       top.idx_ = top.asMathInset()->nargs() - 1;
+       top.pos_ = it.cell().size();
        return it;
 }
index f47d72702537745fdac2edc8bfc9ed1a9fbf5298..8a98fc67a0efe109e29bb6ee4e27ee2a1e1675ee 100644 (file)
@@ -38,26 +38,10 @@ public:
        friend bool operator!=(MathIterator const &, MathIterator const &);
        friend bool operator==(MathIterator const &, MathIterator const &);
 
-       /// default constructor
-       MathIterator();
-       /// start with given inset
-       explicit MathIterator(MathInset * p);
        /// move on one step
        void operator++();
-       /// helper for iend
-       void goEnd();
        /// read access to top most item
        MathArray const & cell() const;
-       /// is this a non-end position
-       bool normal() const;
-       /// shrinks to at most i levels
-       void shrink(size_type i);
-
-private:
-       /// own level down
-       void push(MathInset *);
-       /// own level up
-       void pop();
 };
 
 ///