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();