6 #include "math_inset.h"
8 #include "support/LAssert.h"
11 MathCursorPos::MathCursorPos()
12 : par_(0), idx_(0), pos_(0)
16 MathCursorPos::MathCursorPos(MathInset * p)
17 : par_(p), idx_(0), pos_(0)
24 MathArray & MathCursorPos::cell(MathArray::idx_type idx) const
27 return par_->cell(idx);
31 MathArray & MathCursorPos::cell() const
34 return par_->cell(idx_);
38 MathXArray & MathCursorPos::xcell(MathArray::idx_type idx) const
41 return par_->xcell(idx);
45 MathXArray & MathCursorPos::xcell() const
48 return par_->xcell(idx_);
52 int MathCursorPos::xpos() const
54 return xcell().xo() + xcell().pos2x(pos_);
58 int MathCursorPos::ypos() const
64 std::ostream & operator<<(std::ostream & os, MathCursorPos const & p)
66 os << "(par: " << p.par_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ")";
71 bool operator==(MathCursorPos const & p, MathCursorPos const & q)
73 return p.par_ == q.par_ && p.idx_ == q.idx_ && p.pos_ == q.pos_;
77 bool operator!=(MathCursorPos const & p, MathCursorPos const & q)
79 return p.par_ != q.par_ || p.idx_ != q.idx_ || p.pos_ != q.pos_;
83 bool operator<(MathCursorPos const & p, MathCursorPos const & q)
85 if (p.par_ != q.par_) {
86 lyxerr << "can't compare cursor and anchor in different insets\n";
90 return p.idx_ < q.idx_;
91 return p.pos_ < q.pos_;