Cosmetics.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22934 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-02-11 08:03:03 +00:00
parent 00189c2ebd
commit 260acacf1b
2 changed files with 54 additions and 56 deletions

View File

@ -68,7 +68,7 @@ pos_type CursorSlice::lastpos() const
pit_type CursorSlice::lastpit() const pit_type CursorSlice::lastpit() const
{ {
if (inset().inMathed()) if (inset_->inMathed())
return 0; return 0;
return text()->paragraphs().size() - 1; return text()->paragraphs().size() - 1;
} }
@ -91,58 +91,58 @@ CursorSlice::col_type CursorSlice::col() const
void CursorSlice::forwardPos() void CursorSlice::forwardPos()
{ {
// move on one position if possible // move on one position if possible
if (pos() < lastpos()) { if (pos_ < lastpos()) {
//lyxerr << "... next pos" << endl; //lyxerr << "... next pos" << endl;
++pos(); ++pos_;
return; return;
} }
// otherwise move on one paragraph if possible // otherwise move on one paragraph if possible
if (pit() < lastpit()) { if (pit_ < lastpit()) {
//lyxerr << "... next par" << endl; //lyxerr << "... next par" << endl;
++pit(); ++pit_;
pos() = 0; pos_ = 0;
return; return;
} }
// otherwise move on one cell // otherwise move on one cell
//lyxerr << "... next idx" << endl; //lyxerr << "... next idx" << endl;
BOOST_ASSERT(idx() < nargs()); BOOST_ASSERT(idx_ < nargs());
++idx(); ++idx_;
pit() = 0; pit_ = 0;
pos() = 0; pos_ = 0;
} }
void CursorSlice::forwardIdx() void CursorSlice::forwardIdx()
{ {
BOOST_ASSERT(idx() < nargs()); BOOST_ASSERT(idx_ < nargs());
++idx(); ++idx_;
pit() = 0; pit_ = 0;
pos() = 0; pos_ = 0;
} }
void CursorSlice::backwardPos() void CursorSlice::backwardPos()
{ {
if (pos() != 0) { if (pos_ != 0) {
--pos(); --pos_;
return; return;
} }
if (pit() != 0) { if (pit_ != 0) {
--pit(); --pit_;
pos() = lastpos(); pos_ = lastpos();
return; return;
} }
if (idx() != 0) { if (idx_ != 0) {
--idx(); --idx_;
pit() = lastpit(); pit_ = lastpit();
pos() = lastpos(); pos_ = lastpos();
return; return;
} }
@ -152,46 +152,46 @@ void CursorSlice::backwardPos()
bool CursorSlice::at_end() const bool CursorSlice::at_end() const
{ {
return idx() == lastidx() && pit() == lastpit() && pos() == lastpos(); return idx_ == lastidx() && pit_ == lastpit() && pos_ == lastpos();
} }
bool CursorSlice::at_begin() const bool CursorSlice::at_begin() const
{ {
return idx() == 0 && pit() == 0 && pos() == 0; return idx_ == 0 && pit_ == 0 && pos_ == 0;
} }
bool operator==(CursorSlice const & p, CursorSlice const & q) bool operator==(CursorSlice const & p, CursorSlice const & q)
{ {
return &p.inset() == &q.inset() return &p.inset_ == &q.inset_
&& p.idx() == q.idx() && p.idx_ == q.idx_
&& p.pit() == q.pit() && p.pit_ == q.pit_
&& p.pos() == q.pos(); && p.pos_ == q.pos_;
} }
bool operator!=(CursorSlice const & p, CursorSlice const & q) bool operator!=(CursorSlice const & p, CursorSlice const & q)
{ {
return &p.inset() != &q.inset() return &p.inset_ != &q.inset_
|| p.idx() != q.idx() || p.idx_ != q.idx_
|| p.pit() != q.pit() || p.pit_ != q.pit_
|| p.pos() != q.pos(); || p.pos_ != q.pos_;
} }
bool operator<(CursorSlice const & p, CursorSlice const & q) bool operator<(CursorSlice const & p, CursorSlice const & q)
{ {
if (&p.inset() != &q.inset()) { if (&p.inset_ != &q.inset_) {
LYXERR0("can't compare cursor and anchor in different insets\n" LYXERR0("can't compare cursor and anchor in different insets\n"
<< "p: " << p << '\n' << "q: " << q); << "p: " << p << '\n' << "q: " << q);
BOOST_ASSERT(false); BOOST_ASSERT(false);
} }
if (p.idx() != q.idx()) if (p.idx_ != q.idx_)
return p.idx() < q.idx(); return p.idx_ < q.idx_;
if (p.pit() != q.pit()) if (p.pit_ != q.pit_)
return p.pit() < q.pit(); return p.pit_ < q.pit_;
return p.pos() < q.pos(); return p.pos_ < q.pos_;
} }
@ -210,13 +210,13 @@ bool operator<=(CursorSlice const & p, CursorSlice const & q)
ostream & operator<<(ostream & os, CursorSlice const & item) ostream & operator<<(ostream & os, CursorSlice const & item)
{ {
return os return os
<< "inset: " << (void *)&item.inset() << "inset: " << (void *)&item.inset_
// << " text: " << item.text() // << " text: " << item.text()
<< " idx: " << item.idx() << " idx: " << item.idx_
<< " par: " << item.pit() << " par: " << item.pit_
<< " pos: " << item.pos() << " pos: " << item.pos_
// << " x: " << item.inset().x() // << " x: " << item.inset_.x()
// << " y: " << item.inset().y() // << " y: " << item.inset_.y()
; ;
} }

View File

@ -56,6 +56,15 @@ public:
/// ///
explicit CursorSlice(Inset &); explicit CursorSlice(Inset &);
/// comparison operators.
//@{
friend bool operator==(CursorSlice const &, CursorSlice const &);
friend bool operator!=(CursorSlice const &, CursorSlice const &);
friend bool operator<(CursorSlice const &, CursorSlice const &);
friend bool operator>(CursorSlice const &, CursorSlice const &);
friend bool operator<=(CursorSlice const &, CursorSlice const &);
//@}
/// the current inset /// the current inset
Inset & inset() const { return *inset_; } Inset & inset() const { return *inset_; }
/// return the cell this cursor is in /// return the cell this cursor is in
@ -154,17 +163,6 @@ private:
pos_type pos_; pos_type pos_;
}; };
/// test for equality
bool operator==(CursorSlice const &, CursorSlice const &);
/// test for inequality
bool operator!=(CursorSlice const &, CursorSlice const &);
/// test for order
bool operator<(CursorSlice const &, CursorSlice const &);
/// test for order
bool operator>(CursorSlice const &, CursorSlice const &);
/// test for order
bool operator<=(CursorSlice const &, CursorSlice const &);
} // namespace lyx } // namespace lyx