]> git.lyx.org Git - features.git/commitdiff
LFUN_SCREEN_UP/DOWN: Take into account the off-screen cursor case.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 15 Sep 2007 14:33:37 +0000 (14:33 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 15 Sep 2007 14:33:37 +0000 (14:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20288 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp

index 86b3b870387f3f992052daa3aececebe9b97320e..e82980df842e2feb35114d0f184fd265b034a618 100644 (file)
@@ -950,7 +950,16 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
 
        case LFUN_SCREEN_UP:
        case LFUN_SCREEN_DOWN: {
-               Point const p = bv_funcs::getPos(*this, cur, cur.boundary());
+               Point p = bv_funcs::getPos(*this, cur, cur.boundary());
+               if (p.y_ < 0 || p.y_ > height_) {
+                       // The cursor is off-screen so recenter before proceeding.
+                       center();
+                       updateMetrics(false);
+                       //FIXME: updateMetrics() does not update paragraph position
+                       // This is done at draw() time. So we need a redraw!
+                       buffer_.changed();
+                       p = bv_funcs::getPos(*this, cur, cur.boundary());
+               }
                scroll(cmd.action == LFUN_SCREEN_UP? - height_ : height_);
                cur.reset(buffer_.inset());
                text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_);