From e454df24f55c359dd522751079e94df9ab0f87fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 8 Aug 2001 11:03:53 +0000 Subject: [PATCH] somewhat better corser up/down handling git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2452 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.C | 54 ++++++++++++++++++++++------------------ src/mathed/math_cursor.h | 16 ++++++------ 2 files changed, 38 insertions(+), 32 deletions(-) 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(); /// -- 2.39.2