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)
23 MathArray & MathCursorPos::cell(MathArray::idx_type idx) const
26 return par_->cell(idx);
30 MathArray & MathCursorPos::cell() const
33 return par_->cell(idx_);
37 MathXArray & MathCursorPos::xcell(MathArray::idx_type idx) const
40 return par_->xcell(idx);
44 MathXArray & MathCursorPos::xcell() const
47 return par_->xcell(idx_);
51 int MathCursorPos::xpos() const
53 return xcell().xo() + xcell().pos2x(pos_);
57 int MathCursorPos::ypos() const
63 std::ostream & operator<<(std::ostream & os, MathCursorPos const & p)
65 os << "(par: " << p.par_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ")";
70 bool operator==(MathCursorPos const & p, MathCursorPos const & q)
72 return p.par_ == q.par_ && p.idx_ == q.idx_ && p.pos_ == q.pos_;
76 bool operator!=(MathCursorPos const & p, MathCursorPos const & q)
78 return p.par_ != q.par_ || p.idx_ != q.idx_ || p.pos_ != q.pos_;
82 bool operator<(MathCursorPos const & p, MathCursorPos const & q)
84 if (p.par_ != q.par_) {
85 lyxerr << "can't compare cursor and anchor in different insets\n";
89 return p.idx_ < q.idx_;
90 return p.pos_ < q.pos_;