reverse test move operators out of struct

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2257 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-07-16 18:58:13 +00:00
parent 9b87031073
commit b10dd6dc0b
3 changed files with 46 additions and 16 deletions

View File

@ -1,3 +1,9 @@
2001-07-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
* math_cursor.C (operator==): moved ouf of struct
(operator<): ditto
(normalAnchor): reversed one test (but shouldn't it really be >= ?)
2001-07-12 André Pönitz <poenitz@htwm.de> 2001-07-12 André Pönitz <poenitz@htwm.de>
* math_cursor.[hC]: multicell selection (multicell pasete still defunct) * math_cursor.[hC]: multicell selection (multicell pasete still defunct)

View File

@ -144,8 +144,8 @@ struct Selection
std::vector<MathArray> data_; std::vector<MathArray> data_;
}; };
Selection theSelection;
Selection theSelection;
bool IsMacro(short tok, int id) bool IsMacro(short tok, int id)
@ -161,9 +161,11 @@ bool IsMacro(short tok, int id)
!(tok == LM_TK_SYM && id < 255); !(tok == LM_TK_SYM && id < 255);
} }
ostream & operator<<(ostream & os, MathCursorPos const & p)
std::ostream & operator<<(std::ostream & os, MathCursorPos const & p)
{ {
os << "(par: " << p.par_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ")"; os << "(par: " << p.par_ << " idx: " << p.idx_
<< " pos: " << p.pos_ << ")";
return os; return os;
} }
@ -206,6 +208,7 @@ MathInset * MathCursor::parInset(int i) const
return Cursor_[i].par_; return Cursor_[i].par_;
} }
void MathCursor::dump(char const * what) const void MathCursor::dump(char const * what) const
{ {
return; return;
@ -219,6 +222,7 @@ void MathCursor::dump(char const * what) const
<< "\n"; << "\n";
} }
void MathCursor::seldump(char const *) const void MathCursor::seldump(char const *) const
{ {
//lyxerr << "SEL: " << str << ": '" << theSelection << "'\n"; //lyxerr << "SEL: " << str << ": '" << theSelection << "'\n";
@ -261,6 +265,7 @@ bool MathCursor::openable(MathInset * p, bool sel, bool useupdown) const
return true; return true;
} }
bool MathCursor::plainLeft() bool MathCursor::plainLeft()
{ {
return array().prev(cursor().pos_); return array().prev(cursor().pos_);
@ -824,6 +829,7 @@ void MathCursor::SelCopy()
} }
} }
void MathCursor::SelCut() void MathCursor::SelCut()
{ {
seldump("SelCut"); seldump("SelCut");
@ -852,6 +858,7 @@ void MathCursor::SelPaste()
SelClear(); SelClear();
} }
void MathCursor::SelHandle(bool sel) void MathCursor::SelHandle(bool sel)
{ {
if (sel && !selection) if (sel && !selection)
@ -878,7 +885,6 @@ void MathCursor::SelClear()
} }
void MathCursor::drawSelection(Painter & pain) const void MathCursor::drawSelection(Painter & pain) const
{ {
if (!selection) if (!selection)
@ -969,6 +975,7 @@ void MathCursor::handleAccent(string const & name, int code)
push(p, true); push(p, true);
} }
void MathCursor::handleDelim(int l, int r) void MathCursor::handleDelim(int l, int r)
{ {
MathDelimInset * p = new MathDelimInset(l, r); MathDelimInset * p = new MathDelimInset(l, r);
@ -1060,6 +1067,7 @@ MathInset * MathCursor::enclosing(MathInsetTypes t, int & idx) const
return 0; return 0;
} }
void MathCursor::pullArg() void MathCursor::pullArg()
{ {
// pullArg // pullArg
@ -1127,6 +1135,7 @@ string MathCursorPos::readString()
} }
*/ */
MathInset * MathCursor::prevInset() const MathInset * MathCursor::prevInset() const
{ {
normalize(); normalize();
@ -1198,21 +1207,25 @@ int MathCursor::xpos() const
return xarray().pos2x(cursor().pos_); return xarray().pos2x(cursor().pos_);
} }
void MathCursor::gotoX(int x) void MathCursor::gotoX(int x)
{ {
cursor().pos_ = xarray().x2pos(x); cursor().pos_ = xarray().x2pos(x);
} }
void MathCursor::idxNext() void MathCursor::idxNext()
{ {
cursor().par_->idxNext(cursor().idx_, cursor().pos_); cursor().par_->idxNext(cursor().idx_, cursor().pos_);
} }
void MathCursor::idxPrev() void MathCursor::idxPrev()
{ {
cursor().par_->idxPrev(cursor().idx_, cursor().pos_); cursor().par_->idxPrev(cursor().idx_, cursor().pos_);
} }
void MathCursor::splitCell() void MathCursor::splitCell()
{ {
if (cursor().idx_ == cursor().par_->nargs() - 1) if (cursor().idx_ == cursor().par_->nargs() - 1)
@ -1225,6 +1238,7 @@ void MathCursor::splitCell()
array().insert(0, ar); array().insert(0, ar);
} }
void MathCursor::breakLine() void MathCursor::breakLine()
{ {
MathMatrixInset * p = static_cast<MathMatrixInset *>(formula()->par()); MathMatrixInset * p = static_cast<MathMatrixInset *>(formula()->par());
@ -1251,6 +1265,7 @@ void MathCursor::breakLine()
} }
} }
char MathCursor::valign() const char MathCursor::valign() const
{ {
int idx; int idx;
@ -1259,6 +1274,7 @@ char MathCursor::valign() const
return p ? p->valign() : 0; return p ? p->valign() : 0;
} }
char MathCursor::halign() const char MathCursor::halign() const
{ {
int idx; int idx;
@ -1311,20 +1327,21 @@ MathCursorPos const & MathCursor::cursor() const
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
bool MathCursorPos::operator==(const MathCursorPos & it) const bool operator==(MathCursorPos const & ti, MathCursorPos const & it)
{ {
return par_ == it.par_ && idx_ == it.idx_ && pos_ == it.pos_; return ti.par_ == it.par_ && ti.idx_ == it.idx_ && ti.pos_ == it.pos_;
} }
bool MathCursorPos::operator<(const MathCursorPos & it) const
bool operator<(MathCursorPos const & ti, MathCursorPos const & it)
{ {
if (par_ != it.par_) { if (ti.par_ != it.par_) {
lyxerr << "can't compare cursor and anchor in different insets\n"; lyxerr << "can't compare cursor and anchor in different insets\n";
return true; return true;
} }
if (idx_ != it.idx_) if (ti.idx_ != it.idx_)
return idx_ < it.idx_; return ti.idx_ < it.idx_;
return pos_ < it.pos_; return ti.pos_ < it.pos_;
} }
@ -1344,16 +1361,18 @@ MathXArray & MathCursorPos::xcell(int idx) const
return par_->xcell(idx); return par_->xcell(idx);
} }
MathXArray & MathCursorPos::xcell() const MathXArray & MathCursorPos::xcell() const
{ {
return par_->xcell(idx_); return par_->xcell(idx_);
} }
MathCursorPos MathCursor::normalAnchor() const MathCursorPos MathCursor::normalAnchor() const
{ {
// use Anchor on the same level as Cursor // use Anchor on the same level as Cursor
MathCursorPos normal = Anchor_[Cursor_.size() - 1]; MathCursorPos normal = Anchor_[Cursor_.size() - 1];
if (Cursor_.size() < Anchor_.size() && !(cursor() > normal)) { if (Cursor_.size() < Anchor_.size() && !(normal < cursor())) {
// anchor is behind cursor -> move anchor behind the inset // anchor is behind cursor -> move anchor behind the inset
normal.cell().next(normal.pos_); normal.cell().next(normal.pos_);
} }
@ -1362,21 +1381,25 @@ MathCursorPos MathCursor::normalAnchor() const
return normal; return normal;
} }
bool MathCursorPos::idxUp() bool MathCursorPos::idxUp()
{ {
return par_->idxUp(idx_, pos_); return par_->idxUp(idx_, pos_);
} }
bool MathCursorPos::idxDown() bool MathCursorPos::idxDown()
{ {
return par_->idxDown(idx_, pos_); return par_->idxDown(idx_, pos_);
} }
bool MathCursorPos::idxLeft() bool MathCursorPos::idxLeft()
{ {
return par_->idxLeft(idx_, pos_); return par_->idxLeft(idx_, pos_);
} }
bool MathCursorPos::idxRight() bool MathCursorPos::idxRight()
{ {
return par_->idxRight(idx_, pos_); return par_->idxRight(idx_, pos_);

View File

@ -39,10 +39,6 @@ struct MathCursorPos {
int idx_; int idx_;
/// cell position /// cell position
int pos_; int pos_;
///
bool operator==(const MathCursorPos &) const;
///
bool operator<(const MathCursorPos &) const;
/// returns cell corresponding to this position /// returns cell corresponding to this position
MathArray & cell() const; MathArray & cell() const;
/// returns cell corresponding to this position /// returns cell corresponding to this position
@ -61,6 +57,11 @@ struct MathCursorPos {
bool idxDown(); bool idxDown();
}; };
///
bool operator==(MathCursorPos const &, MathCursorPos const &);
///
bool operator<(MathCursorPos const &, MathCursorPos const &);
/// This is the external interface of Math's subkernel /// This is the external interface of Math's subkernel
class MathCursor { class MathCursor {