From: André Pönitz Date: Wed, 8 Aug 2001 09:47:44 +0000 (+0000) Subject: change 'cursor down in \frac denominator' behaviour. X-Git-Tag: 1.6.10~20894 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1cc8461767a75003b2e1cc545c3d84146f0e7514;p=features.git change 'cursor down in \frac denominator' behaviour. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2451 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 6efdbdf294..9c04806f41 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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(const_cast(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(const_cast(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; }