X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fcursor_slice.C;h=eda679a2e95750fa10c79da8517003c57dd63ba3;hb=61133c4b5625993f600ffa7d209c3e2bc28d26f6;hp=3cf9cdffa9bf1b1c0150946004217dc9c5d10575;hpb=bddfd8ff662d7c9e750f6d7713e4b3d62f92efc4;p=lyx.git diff --git a/src/cursor_slice.C b/src/cursor_slice.C index 3cf9cdffa9..eda679a2e9 100644 --- a/src/cursor_slice.C +++ b/src/cursor_slice.C @@ -21,80 +21,38 @@ #include "mathed/math_inset.h" #include "mathed/math_data.h" -#include "insets/updatableinset.h" - - #include using std::endl; CursorSlice::CursorSlice() - : inset_(0), idx_(0), par_(0), pos_(0), boundary_(false) + : inset_(0), idx_(0), pit_(0), pos_(0) {} CursorSlice::CursorSlice(InsetBase & p) - : inset_(&p), idx_(0), par_(0), pos_(0), boundary_(false) -{ - BOOST_ASSERT(inset_); -} - - -size_t CursorSlice::nargs() const + : inset_(&p), idx_(0), pit_(0), pos_(0) { BOOST_ASSERT(inset_); - return inset_->nargs(); -} - - -size_t CursorSlice::nrows() const -{ - BOOST_ASSERT(inset_); - return inset_->nrows(); -} - - -size_t CursorSlice::ncols() const -{ - BOOST_ASSERT(inset_); - return inset_->ncols(); -} - - -CursorSlice::idx_type CursorSlice::idx() const -{ - return idx_; -} - - -CursorSlice::idx_type & CursorSlice::idx() -{ - return idx_; -} - - -CursorSlice::par_type CursorSlice::par() const -{ - return par_; } -CursorSlice::par_type & CursorSlice::par() +MathArray & CursorSlice::cell() const { - return par_; + return inset_->asMathInset()->cell(idx_); } -CursorSlice::pos_type CursorSlice::pos() const +Paragraph & CursorSlice::paragraph() { - return pos_; + return text()->getPar(pit_); } -CursorSlice::pos_type & CursorSlice::pos() +Paragraph const & CursorSlice::paragraph() const { - return pos_; + return text()->getPar(pit_); } @@ -105,18 +63,6 @@ CursorSlice::pos_type CursorSlice::lastpos() const } -bool CursorSlice::boundary() const -{ - return boundary_; -} - - -bool & CursorSlice::boundary() -{ - return boundary_; -} - - CursorSlice::row_type CursorSlice::row() const { BOOST_ASSERT(asMathInset()); @@ -131,55 +77,11 @@ CursorSlice::col_type CursorSlice::col() const } -MathInset * CursorSlice::asMathInset() const -{ - BOOST_ASSERT(inset_); - return inset_->asMathInset(); -} - - -UpdatableInset * CursorSlice::asUpdatableInset() const -{ - BOOST_ASSERT(inset_); - return inset_->asUpdatableInset(); -} - - -MathArray & CursorSlice::cell() const -{ - BOOST_ASSERT(asMathInset()); - return asMathInset()->cell(idx_); -} - - -LyXText * CursorSlice::text() const -{ - BOOST_ASSERT(inset_); - return inset_->getText(idx_); -} - - -Paragraph & CursorSlice::paragraph() -{ - // access to the main lyx text must be handled in the cursor - BOOST_ASSERT(text()); - return *text()->getPar(par_); -} - - -Paragraph const & CursorSlice::paragraph() const -{ - // access to the main lyx text must be handled in the cursor - BOOST_ASSERT(text()); - return *text()->getPar(par_); -} - - bool operator==(CursorSlice const & p, CursorSlice const & q) { return &p.inset() == &q.inset() && p.idx() == q.idx() - && p.par() == q.par() + && p.pit() == q.pit() && p.pos() == q.pos(); } @@ -188,7 +90,7 @@ bool operator!=(CursorSlice const & p, CursorSlice const & q) { return &p.inset() != &q.inset() || p.idx() != q.idx() - || p.par() != q.par() + || p.pit() != q.pit() || p.pos() != q.pos(); } @@ -198,12 +100,12 @@ bool operator<(CursorSlice const & p, CursorSlice const & q) if (&p.inset() != &q.inset()) { lyxerr << "can't compare cursor and anchor in different insets\n" << "p: " << p << '\n' << "q: " << q << endl; - return true; + BOOST_ASSERT(false); } if (p.idx() != q.idx()) return p.idx() < q.idx(); - if (p.par() != q.par()) - return p.par() < q.par(); + if (p.pit() != q.pit()) + return p.pit() < q.pit(); return p.pos() < q.pos(); } @@ -214,13 +116,19 @@ bool operator>(CursorSlice const & p, CursorSlice const & q) } +bool operator<=(CursorSlice const & p, CursorSlice const & q) +{ + return !(q < p); +} + + std::ostream & operator<<(std::ostream & os, CursorSlice const & item) { return os << "inset: " << &item.inset() // << " text: " << item.text() << " idx: " << item.idx() - << " par: " << item.par() + << " par: " << item.pit() << " pos: " << item.pos() // << " x: " << item.inset().x() // << " y: " << item.inset().y()