From 3ba3389ede36e018f5fa3f82cdb283fa8f0d39c9 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 6 Mar 2008 10:14:36 +0000 Subject: [PATCH] Fix http://bugzilla.lyx.org/show_bug.cgi?id=4494 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23509 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/TextMetrics.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index ca2670b6e1..8bcdfc7285 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -32,6 +32,7 @@ #include "InsetList.h" #include "Layout.h" #include "Length.h" +#include "LyXFunc.h" #include "LyXRC.h" #include "MetricsInfo.h" #include "paragraph_funcs.h" @@ -1615,8 +1616,14 @@ void TextMetrics::cursorPrevious(Cursor & cur) pos_type cpos = cur.pos(); pit_type cpar = cur.pit(); - int x = cur.x_target(); - setCursorFromCoordinates(cur, x, 0); + // Memorize current position. + Point p = bv_->getPos(cur, cur.boundary()); + // Scroll one full page. + lyx::dispatch(FuncRequest(LFUN_SCROLL, "page up")); + // Try to place the cursor to the same coordinates. + setCursorFromCoordinates(cur, p.x_, p.y_); + // And move one line up in order to acknowledge in inset movement and/or + // selection. cur.dispatch(FuncRequest(cur.selection()? LFUN_UP_SELECT: LFUN_UP)); if (cpar == cur.pit() && cpos == cur.pos()) @@ -1634,8 +1641,14 @@ void TextMetrics::cursorNext(Cursor & cur) pos_type cpos = cur.pos(); pit_type cpar = cur.pit(); - int x = cur.x_target(); - setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); + // Memorize current position. + Point p = bv_->getPos(cur, cur.boundary()); + // Scroll one full page. + lyx::dispatch(FuncRequest(LFUN_SCROLL, "page down")); + // Try to place the cursor to the same coordinates. + setCursorFromCoordinates(cur, p.x_, p.y_); + // And move one line down in order to acknowledge in inset movement and/or + // selection. cur.dispatch(FuncRequest(cur.selection()? LFUN_DOWN_SELECT: LFUN_DOWN)); if (cpar == cur.pit() && cpos == cur.pos()) -- 2.39.2