]> git.lyx.org Git - lyx.git/commitdiff
reverse test move operators out of struct
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 16 Jul 2001 18:58:13 +0000 (18:58 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 16 Jul 2001 18:58:13 +0000 (18:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2257 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/math_cursor.C
src/mathed/math_cursor.h

index 65ef82ed0d45fc7f88e5348d88914ca7d741e09e..b437db23f6fdfae07947fea5b248aa1cdfe7847a 100644 (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>
 
        * math_cursor.[hC]: multicell selection (multicell pasete still defunct)
 2001-07-12 André Pönitz  <poenitz@htwm.de>
 
        * math_cursor.[hC]: multicell selection (multicell pasete still defunct)
index a0f8013fdcb82d729e1f8f7125a14f1851c38c0c..6da2f7bbee2e656ae49fc723ea0ef7e51e9c286d 100644 (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
 {
        return;
 void MathCursor::dump(char const * what) const
 {
        return;
@@ -219,6 +222,7 @@ void MathCursor::dump(char const * what) const
                << "\n";
 }
 
                << "\n";
 }
 
+
 void MathCursor::seldump(char const *) const
 {
        //lyxerr << "SEL: " << str << ": '" << theSelection << "'\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;
 }
 
        return true;
 }
 
+
 bool MathCursor::plainLeft()
 {
        return array().prev(cursor().pos_);
 bool MathCursor::plainLeft()
 {
        return array().prev(cursor().pos_);
@@ -824,6 +829,7 @@ void MathCursor::SelCopy()
        }
 }
 
        }
 }
 
+
 void MathCursor::SelCut()
 {
        seldump("SelCut");
 void MathCursor::SelCut()
 {
        seldump("SelCut");
@@ -852,6 +858,7 @@ void MathCursor::SelPaste()
        SelClear();
 }
 
        SelClear();
 }
 
+
 void MathCursor::SelHandle(bool sel)
 {
        if (sel && !selection)
 void MathCursor::SelHandle(bool sel)
 {
        if (sel && !selection)
@@ -878,7 +885,6 @@ void MathCursor::SelClear()
 }
 
 
 }
 
 
-
 void MathCursor::drawSelection(Painter & pain) const
 {
        if (!selection)
 void MathCursor::drawSelection(Painter & pain) const
 {
        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)
 {
        MathDelimInset * p = new MathDelimInset(l, r);
 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;
 }
 
        return 0;
 }
 
+
 void MathCursor::pullArg()
 {
        // pullArg
 void MathCursor::pullArg()
 {
        // pullArg
@@ -1127,6 +1135,7 @@ string MathCursorPos::readString()
 }
 */
 
 }
 */
 
+
 MathInset * MathCursor::prevInset() const
 {
        normalize();
 MathInset * MathCursor::prevInset() const
 {
        normalize();
@@ -1198,21 +1207,25 @@ int MathCursor::xpos() const
        return xarray().pos2x(cursor().pos_);
 }
 
        return xarray().pos2x(cursor().pos_);
 }
 
+
 void MathCursor::gotoX(int x)
 {
        cursor().pos_ = xarray().x2pos(x);      
 }
 
 void MathCursor::gotoX(int x)
 {
        cursor().pos_ = xarray().x2pos(x);      
 }
 
+
 void MathCursor::idxNext()
 {
        cursor().par_->idxNext(cursor().idx_, cursor().pos_);
 }
 
 void MathCursor::idxNext()
 {
        cursor().par_->idxNext(cursor().idx_, cursor().pos_);
 }
 
+
 void MathCursor::idxPrev()
 {
        cursor().par_->idxPrev(cursor().idx_, cursor().pos_);
 }
 
 void MathCursor::idxPrev()
 {
        cursor().par_->idxPrev(cursor().idx_, cursor().pos_);
 }
 
+
 void MathCursor::splitCell()
 {
        if (cursor().idx_ == cursor().par_->nargs() - 1) 
 void MathCursor::splitCell()
 {
        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()
 {
        MathMatrixInset * p = static_cast<MathMatrixInset *>(formula()->par());
 void MathCursor::breakLine()
 {
        MathMatrixInset * p = static_cast<MathMatrixInset *>(formula()->par());
@@ -1251,6 +1265,7 @@ void MathCursor::breakLine()
        }
 }
 
        }
 }
 
+
 char MathCursor::valign() const
 {
        int idx;
 char MathCursor::valign() const
 {
        int idx;
@@ -1259,6 +1274,7 @@ char MathCursor::valign() const
        return p ? p->valign() : 0;
 }
 
        return p ? p->valign() : 0;
 }
 
+
 char MathCursor::halign() const
 {
        int idx;
 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;
        }
                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);
 }
 
        return par_->xcell(idx);
 }
 
+
 MathXArray & MathCursorPos::xcell() 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];
 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_);
        }
                // anchor is behind cursor -> move anchor behind the inset
                normal.cell().next(normal.pos_);
        }
@@ -1362,21 +1381,25 @@ MathCursorPos MathCursor::normalAnchor() const
        return normal;
 }
 
        return normal;
 }
 
+
 bool MathCursorPos::idxUp()
 {
        return par_->idxUp(idx_, pos_);
 }
 
 bool MathCursorPos::idxUp()
 {
        return par_->idxUp(idx_, pos_);
 }
 
+
 bool MathCursorPos::idxDown()
 {
        return par_->idxDown(idx_, pos_);
 }
 
 bool MathCursorPos::idxDown()
 {
        return par_->idxDown(idx_, pos_);
 }
 
+
 bool MathCursorPos::idxLeft()
 {
        return par_->idxLeft(idx_, pos_);
 }
 
 bool MathCursorPos::idxLeft()
 {
        return par_->idxLeft(idx_, pos_);
 }
 
+
 bool MathCursorPos::idxRight()
 {
        return par_->idxRight(idx_, pos_);
 bool MathCursorPos::idxRight()
 {
        return par_->idxRight(idx_, pos_);
index 1b4d5bc1b91a89995a8f1d0003aa381bb98ebd19..c46852cf3e681aad45b560a243abdc4927e75b9d 100644 (file)
@@ -39,10 +39,6 @@ struct MathCursorPos {
        int idx_;
        /// cell position
        int pos_;
        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
        /// returns cell corresponding to this position
        MathArray & cell() const;
        /// 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
 class MathCursor {
 
 /// This is the external interface of Math's subkernel
 class MathCursor {