6 #include "math_inset.h"
8 #include "support/LAssert.h"
13 MathCursorPos::MathCursorPos()
14 : par_(0), idx_(0), pos_(0)
18 MathCursorPos::MathCursorPos(MathInset * p)
19 : par_(p), idx_(0), pos_(0)
26 MathArray & MathCursorPos::cell(MathArray::idx_type idx) const
29 return par_->cell(idx);
33 MathArray & MathCursorPos::cell() const
36 return par_->cell(idx_);
40 MathXArray & MathCursorPos::xcell(MathArray::idx_type idx) const
43 return par_->xcell(idx);
47 MathXArray & MathCursorPos::xcell() const
50 return par_->xcell(idx_);
54 int MathCursorPos::xpos() const
56 return xcell().xo() + xcell().pos2x(pos_);
60 int MathCursorPos::ypos() const
66 ostream & operator<<(ostream & os, MathCursorPos const & p)
68 os << "(par: " << p.par_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ")";
73 bool operator==(MathCursorPos const & p, MathCursorPos const & q)
75 return p.par_ == q.par_ && p.idx_ == q.idx_ && p.pos_ == q.pos_;
79 bool operator!=(MathCursorPos const & p, MathCursorPos const & q)
81 return p.par_ != q.par_ || p.idx_ != q.idx_ || p.pos_ != q.pos_;
85 bool operator<(MathCursorPos const & p, MathCursorPos const & q)
87 if (p.par_ != q.par_) {
88 lyxerr << "can't compare cursor and anchor in different insets\n";
92 return p.idx_ < q.idx_;
93 return p.pos_ < q.pos_;