diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 9c04806f41..dd60e72fdd 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -518,7 +518,7 @@ bool MathCursor::up(bool sel) selHandle(sel); if (selection_) - return idxUp() || popLeft(); + return goUp(); // check whether we could move into an inset on the right or on the left MathInset * p = nextInset(); @@ -545,7 +545,7 @@ bool MathCursor::up(bool sel) } } - return idxUp() || popLeft(); + return goUp(); } @@ -556,7 +556,7 @@ bool MathCursor::down(bool sel) selHandle(sel); if (selection_) - return idxDown() || popLeft(); + return goDown(); // check whether we could move into an inset on the right or on the left MathInset * p = nextInset(); @@ -585,7 +585,7 @@ bool MathCursor::down(bool sel) } } - return idxDown() || popLeft(); + return goDown(); } @@ -1269,31 +1269,37 @@ void MathCursor::gotoX(int x) } -bool MathCursor::idxUp() +bool MathCursor::goUp() { - 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; + int x0; + int y0; + getPos(x0, y0); + std::vector save = Cursor_; + y0 -= xarray().ascent(); + for (int y = y0 - 4; y > outerPar()->yo() - outerPar()->ascent(); y -= 4) { + setPos(x0, y); + if (save != Cursor_ && xarray().yo() < y0) + return true; + } + Cursor_ = save; + return false; } -bool MathCursor::idxDown() +bool MathCursor::goDown() { - 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 x0; + int y0; + getPos(x0, y0); + std::vector save = Cursor_; + y0 += xarray().descent(); + for (int y = y0 + 4; y < outerPar()->yo() + outerPar()->descent(); y += 4) { + setPos(x0, y); + if (save != Cursor_ && xarray().yo() > y0) + return true; + } + Cursor_ = save; + return false; } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 8e700b943a..c8b4935afa 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -91,18 +91,18 @@ public: void first(); /// Put the cursor in the last position void last(); - /// + /// moves cursor position one cell to the left bool posLeft(); - /// + /// moves cursor position one cell to the right bool posRight(); - /// moves position one cell to the left + /// moves cursor index one cell to the left bool idxLeft(); - /// moves position one cell to the right + /// moves cursor index one cell to the right bool idxRight(); - /// moves position one cell up - bool idxUp(); - /// moves position one cell down - bool idxDown(); + /// moves position somehow up + bool goUp(); + /// moves position somehow down + bool goDown(); /// void idxNext(); ///