mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
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
This commit is contained in:
parent
f1cc244c8b
commit
95ced6f509
@ -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;
|
||||
|
@ -17,17 +17,6 @@
|
||||
#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;
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user