]> git.lyx.org Git - features.git/commitdiff
change 'cursor down in \frac denominator' behaviour.
authorAndré Pönitz <poenitz@gmx.net>
Wed, 8 Aug 2001 09:47:44 +0000 (09:47 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 8 Aug 2001 09:47:44 +0000 (09:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2451 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_cursor.C

index 6efdbdf294c24d755891d1da28b36986f5444d5c..9c04806f4146639d6529ae467b1046cd4a4e93c3 100644 (file)
@@ -1238,128 +1238,134 @@ MathCursorPos const & MathCursor::cursor() const
 }
 
 
-
-////////////////////////////////////////////////////////////////////////
-
-
-bool operator==(MathCursorPos const & ti, MathCursorPos const & it)
+int MathCursor::cellXOffset() const
 {
-       return ti.par_ == it.par_ && ti.idx_ == it.idx_ && ti.pos_ == it.pos_;
+       return par()->cellXOffset(idx());
 }
 
 
-bool operator<(MathCursorPos const & ti, MathCursorPos const & it)
+int MathCursor::cellYOffset() const
 {
-       if (ti.par_ != it.par_) {
-               lyxerr << "can't compare cursor and anchor in different insets\n";
-               return true;
-       }
-       if (ti.idx_ != it.idx_)
-               return ti.idx_ < it.idx_;
-       return ti.pos_ < it.pos_;
+       return par()->cellYOffset(idx());
 }
 
 
-MathArray & MathCursorPos::cell(int idx) const
+int MathCursor::xpos() const
 {
-       return par_->cell(idx);
+       return cellXOffset() + xarray().pos2x(pos());
 }
 
-MathArray & MathCursorPos::cell() const
+
+int MathCursor::ypos() const
 {
-       return par_->cell(idx_);
+       return cellYOffset();
 }
 
 
-MathXArray & MathCursorPos::xcell(int idx) const
+
+void MathCursor::gotoX(int x) 
 {
-       return par_->xcell(idx);
+       pos() = xarray().x2pos(x - cellXOffset());
 }
 
 
-MathXArray & MathCursorPos::xcell() const
+bool MathCursor::idxUp()
 {
-       return par_->xcell(idx_);
+       int x = par()->xo() + xpos();
+       do {
+               if (par()->idxUp(idx(), pos())) {
+                       gotoX(x - par()->xo());
+                       return true;
+               }
+       } while (popLeft());
+       gotoX(x - par()->xo());
+       return true;
 }
 
 
-MathCursorPos MathCursor::normalAnchor() const
+bool MathCursor::idxDown()
 {
-       // use Anchor on the same level as Cursor
-       MathCursorPos normal = Anchor_[Cursor_.size() - 1];
-       if (Cursor_.size() < Anchor_.size() && !(normal < cursor())) {
-               // anchor is behind cursor -> move anchor behind the inset
-               ++normal.pos_;
-       }
-       return normal;
+       int x = par()->xo() + xpos();
+       do {
+               if (par()->idxDown(idx(), pos())) {
+                       gotoX(x - par()->xo());
+                       return true;
+               }
+       } while (popLeft());
+       gotoX(x - par()->xo());
+       return true;
 }
 
 
-int MathCursor::cellXOffset() const
+bool MathCursor::idxLeft()
 {
-       return par()->cellXOffset(idx());
+       return par()->idxLeft(idx(), pos());
 }
 
 
-int MathCursor::cellYOffset() const
+bool MathCursor::idxRight()
 {
-       return par()->cellYOffset(idx());
+       return par()->idxRight(idx(), pos());
 }
 
 
-int MathCursor::xpos() const
+MathMatrixInset * MathCursor::outerPar() const
 {
-       return cellXOffset() + xarray().pos2x(pos());
+       return
+               static_cast<MathMatrixInset *>(const_cast<MathInset *>(formula_->par()));
 }
 
+////////////////////////////////////////////////////////////////////////
+
 
-int MathCursor::ypos() const
+bool operator==(MathCursorPos const & ti, MathCursorPos const & it)
 {
-       return cellYOffset();
+       return ti.par_ == it.par_ && ti.idx_ == it.idx_ && ti.pos_ == it.pos_;
 }
 
 
-
-void MathCursor::gotoX(int x) 
+bool operator<(MathCursorPos const & ti, MathCursorPos const & it)
 {
-       pos() = xarray().x2pos(x - cellXOffset());
+       if (ti.par_ != it.par_) {
+               lyxerr << "can't compare cursor and anchor in different insets\n";
+               return true;
+       }
+       if (ti.idx_ != it.idx_)
+               return ti.idx_ < it.idx_;
+       return ti.pos_ < it.pos_;
 }
 
 
-bool MathCursor::idxUp()
+MathArray & MathCursorPos::cell(int idx) const
 {
-       int x = xpos();
-       if (!par()->idxUp(idx(), pos()))
-               return false;
-       gotoX(x);
-       return true;
+       return par_->cell(idx);
 }
 
-
-bool MathCursor::idxDown()
+MathArray & MathCursorPos::cell() const
 {
-       int x = xpos();
-       if (!par()->idxDown(idx(), pos()))
-               return false;
-       gotoX(x);
-       return true;
+       return par_->cell(idx_);
 }
 
 
-bool MathCursor::idxLeft()
+MathXArray & MathCursorPos::xcell(int idx) const
 {
-       return par()->idxLeft(idx(), pos());
+       return par_->xcell(idx);
 }
 
 
-bool MathCursor::idxRight()
+MathXArray & MathCursorPos::xcell() const
 {
-       return par()->idxRight(idx(), pos());
+       return par_->xcell(idx_);
 }
 
 
-MathMatrixInset * MathCursor::outerPar() const
+MathCursorPos MathCursor::normalAnchor() const
 {
-       return
-               static_cast<MathMatrixInset *>(const_cast<MathInset *>(formula_->par()));
+       // use Anchor on the same level as Cursor
+       MathCursorPos normal = Anchor_[Cursor_.size() - 1];
+       if (Cursor_.size() < Anchor_.size() && !(normal < cursor())) {
+               // anchor is behind cursor -> move anchor behind the inset
+               ++normal.pos_;
+       }
+       return normal;
 }