From: André Pönitz Date: Wed, 14 Jan 2004 17:46:46 +0000 (+0000) Subject: remove more functions from MathIterator to prepare merger with text-ed X-Git-Tag: 1.6.10~15572 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=95ced6f5094ef3b0d6cb272727c81d28fee77a20;p=features.git remove more functions from MathIterator to prepare merger with text-ed cursor slice stack git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8349 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 4cea74dc7a..4cb27cefed 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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; diff --git a/src/mathed/math_iterator.C b/src/mathed/math_iterator.C index 8c11cad119..e06157c864 100644 --- a/src/mathed/math_iterator.C +++ b/src/mathed/math_iterator.C @@ -17,17 +17,6 @@ #include -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; } diff --git a/src/mathed/math_iterator.h b/src/mathed/math_iterator.h index f47d727025..8a98fc67a0 100644 --- a/src/mathed/math_iterator.h +++ b/src/mathed/math_iterator.h @@ -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(); }; ///