From: Lars Gullik Bjønnes Date: Mon, 16 Jul 2001 18:58:13 +0000 (+0000) Subject: reverse test move operators out of struct X-Git-Tag: 1.6.10~21068 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b10dd6dc0b79a4f112733acdd8cff8e09e315340;p=features.git reverse test move operators out of struct git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2257 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 65ef82ed0d..b437db23f6 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,9 @@ +2001-07-16 Lars Gullik Bjønnes + + * 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 * math_cursor.[hC]: multicell selection (multicell pasete still defunct) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index a0f8013fdc..6da2f7bbee 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -144,8 +144,8 @@ struct Selection std::vector data_; }; -Selection theSelection; +Selection theSelection; bool IsMacro(short tok, int id) @@ -161,9 +161,11 @@ bool IsMacro(short tok, int id) !(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; } @@ -206,6 +208,7 @@ MathInset * MathCursor::parInset(int i) const return Cursor_[i].par_; } + void MathCursor::dump(char const * what) const { return; @@ -219,6 +222,7 @@ void MathCursor::dump(char const * what) const << "\n"; } + void MathCursor::seldump(char const *) const { //lyxerr << "SEL: " << str << ": '" << theSelection << "'\n"; @@ -261,6 +265,7 @@ bool MathCursor::openable(MathInset * p, bool sel, bool useupdown) const return true; } + bool MathCursor::plainLeft() { return array().prev(cursor().pos_); @@ -824,6 +829,7 @@ void MathCursor::SelCopy() } } + void MathCursor::SelCut() { seldump("SelCut"); @@ -852,6 +858,7 @@ void MathCursor::SelPaste() SelClear(); } + void MathCursor::SelHandle(bool sel) { if (sel && !selection) @@ -878,7 +885,6 @@ void MathCursor::SelClear() } - void MathCursor::drawSelection(Painter & pain) const { if (!selection) @@ -969,6 +975,7 @@ void MathCursor::handleAccent(string const & name, int code) push(p, true); } + void MathCursor::handleDelim(int l, int r) { MathDelimInset * p = new MathDelimInset(l, r); @@ -1060,6 +1067,7 @@ MathInset * MathCursor::enclosing(MathInsetTypes t, int & idx) const return 0; } + void MathCursor::pullArg() { // pullArg @@ -1127,6 +1135,7 @@ string MathCursorPos::readString() } */ + MathInset * MathCursor::prevInset() const { normalize(); @@ -1198,21 +1207,25 @@ int MathCursor::xpos() const return xarray().pos2x(cursor().pos_); } + void MathCursor::gotoX(int x) { cursor().pos_ = xarray().x2pos(x); } + void MathCursor::idxNext() { cursor().par_->idxNext(cursor().idx_, cursor().pos_); } + void MathCursor::idxPrev() { cursor().par_->idxPrev(cursor().idx_, cursor().pos_); } + void MathCursor::splitCell() { if (cursor().idx_ == cursor().par_->nargs() - 1) @@ -1225,6 +1238,7 @@ void MathCursor::splitCell() array().insert(0, ar); } + void MathCursor::breakLine() { MathMatrixInset * p = static_cast(formula()->par()); @@ -1251,6 +1265,7 @@ void MathCursor::breakLine() } } + char MathCursor::valign() const { int idx; @@ -1259,6 +1274,7 @@ char MathCursor::valign() const return p ? p->valign() : 0; } + char MathCursor::halign() const { 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"; return true; } - if (idx_ != it.idx_) - return idx_ < it.idx_; - return pos_ < it.pos_; + if (ti.idx_ != it.idx_) + return ti.idx_ < it.idx_; + return ti.pos_ < it.pos_; } @@ -1344,16 +1361,18 @@ MathXArray & MathCursorPos::xcell(int idx) const return par_->xcell(idx); } + MathXArray & MathCursorPos::xcell() const { return par_->xcell(idx_); } + MathCursorPos MathCursor::normalAnchor() const { // use Anchor on the same level as Cursor 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 normal.cell().next(normal.pos_); } @@ -1362,21 +1381,25 @@ MathCursorPos MathCursor::normalAnchor() const return normal; } + bool MathCursorPos::idxUp() { return par_->idxUp(idx_, pos_); } + bool MathCursorPos::idxDown() { return par_->idxDown(idx_, pos_); } + bool MathCursorPos::idxLeft() { return par_->idxLeft(idx_, pos_); } + bool MathCursorPos::idxRight() { return par_->idxRight(idx_, pos_); diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 1b4d5bc1b9..c46852cf3e 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -39,10 +39,6 @@ struct MathCursorPos { int idx_; /// cell position int pos_; - /// - bool operator==(const MathCursorPos &) const; - /// - bool operator<(const MathCursorPos &) const; /// returns cell corresponding to this position MathArray & cell() const; /// returns cell corresponding to this position @@ -61,6 +57,11 @@ struct MathCursorPos { bool idxDown(); }; +/// +bool operator==(MathCursorPos const &, MathCursorPos const &); +/// +bool operator<(MathCursorPos const &, MathCursorPos const &); + /// This is the external interface of Math's subkernel class MathCursor {