3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 #include "math_inset.h"
17 #include <boost/assert.hpp>
22 CursorPos::CursorPos()
23 : inset_(0), idx_(0), pos_(0)
27 CursorPos::CursorPos(MathInset * p)
28 : inset_(p), idx_(0), pos_(0)
35 MathArray & CursorPos::cell(MathArray::idx_type idx) const
38 return inset_->cell(idx);
42 MathArray & CursorPos::cell() const
45 return inset_->cell(idx_);
49 void CursorPos::getPos(int & x, int & y) const
51 inset_->getPos(idx_, pos_, x, y);
55 void CursorPos::setPos(MathArray::pos_type pos)
61 std::ostream & operator<<(std::ostream & os, CursorPos const & p)
63 os << "(par: " << p.inset_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ')';
68 bool operator==(CursorPos const & p, CursorPos const & q)
70 return p.inset_ == q.inset_ && p.idx_ == q.idx_ && p.pos_ == q.pos_;
74 bool operator!=(CursorPos const & p, CursorPos const & q)
76 return p.inset_ != q.inset_ || p.idx_ != q.idx_ || p.pos_ != q.pos_;
80 bool operator<(CursorPos const & p, CursorPos const & q)
82 if (p.inset_ != q.inset_) {
83 lyxerr << "can't compare cursor and anchor in different insets\n"
84 << "p: " << p << '\n' << "q: " << q << endl;
88 return p.idx_ < q.idx_;
89 return p.pos_ < q.pos_;