From 5a9653203f516def9b6bd9e77529f84a506dfc42 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 6 Mar 2008 12:41:38 +0000 Subject: [PATCH] Fix PageUp/Down select when at the top/bottom of a document. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23510 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 12 ++++++++++++ src/BufferView.h | 6 ++++++ src/TextMetrics.cpp | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index d5ee51739c..448d195857 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -312,6 +312,18 @@ int BufferView::leftMargin() const } +bool BufferView::isTopScreen() const +{ + return d->scrollbarParameters_.position == d->scrollbarParameters_.min; +} + + +bool BufferView::isBottomScreen() const +{ + return d->scrollbarParameters_.position == d->scrollbarParameters_.max; +} + + Intl & BufferView::getIntl() { return d->intl_; diff --git a/src/BufferView.h b/src/BufferView.h index a79c7bbb62..95d72c3358 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -96,6 +96,12 @@ public: /// left margin int leftMargin() const; + /// \return true if the BufferView is at the top of the document. + bool isTopScreen() const; + + /// \return true if the BufferView is at the bottom of the document. + bool isBottomScreen() const; + /// perform pending metrics updates. /** \c Update::FitCursor means first to do a FitCursor, and to * force an update if screen position changes. diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 8bcdfc7285..078b5907d4 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1613,6 +1613,14 @@ int TextMetrics::cursorY(CursorSlice const & sl, bool boundary) const void TextMetrics::cursorPrevious(Cursor & cur) { + if (bv_->isTopScreen()) { + lyx::dispatch(FuncRequest(cur.selection() + ? LFUN_BUFFER_BEGIN_SELECT : LFUN_BUFFER_BEGIN)); + cur.finishUndo(); + cur.updateFlags(Update::None); + return; + } + pos_type cpos = cur.pos(); pit_type cpar = cur.pit(); @@ -1638,6 +1646,14 @@ void TextMetrics::cursorPrevious(Cursor & cur) void TextMetrics::cursorNext(Cursor & cur) { + if (bv_->isBottomScreen()) { + lyx::dispatch(FuncRequest(cur.selection() + ? LFUN_BUFFER_END_SELECT : LFUN_BUFFER_END)); + cur.finishUndo(); + cur.updateFlags(Update::None); + return; + } + pos_type cpos = cur.pos(); pit_type cpar = cur.pit(); -- 2.39.2