From: Jean-Marc Lasgouttes Date: Tue, 3 Sep 2024 13:55:34 +0000 (+0200) Subject: Simplify greatly Buffer::scroll/Up/Down methods X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=86d2313ce323fd20fadd63f103625e15704ae527;p=lyx.git Simplify greatly Buffer::scroll/Up/Down methods The code there that checks whether we scroll beyond the top/bottom of document is not needed anymore, this is handled later by BufferView::update(bool). Note that this methods may disappear with time. No change intended. --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 2a3a9c58c4..0985f6f7f6 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2848,34 +2848,13 @@ int BufferView::minVisiblePart() int BufferView::scroll(int pixels) { - if (pixels > 0) - return scrollDown(pixels); - if (pixels < 0) - return scrollUp(-pixels); - return 0; + d->anchor_ypos_ -= pixels; + return -pixels; } int BufferView::scrollDown(int pixels) { - Text * text = &buffer_.text(); - TextMetrics & tm = d->text_metrics_[text]; - int const ymax = height_ + pixels; - while (true) { - pair last = tm.last(); - int bottom_pos = last.second->bottom(); - if (lyxrc.scroll_below_document) - bottom_pos += height_ - minVisiblePart(); - if (last.first + 1 == int(text->paragraphs().size())) { - if (bottom_pos <= height_) - return 0; - pixels = min(pixels, bottom_pos - height_); - break; - } - if (bottom_pos > ymax) - break; - tm.newParMetricsDown(); - } d->anchor_ypos_ -= pixels; return -pixels; } @@ -2883,22 +2862,6 @@ int BufferView::scrollDown(int pixels) int BufferView::scrollUp(int pixels) { - Text * text = &buffer_.text(); - TextMetrics & tm = d->text_metrics_[text]; - int ymin = - pixels; - while (true) { - pair first = tm.first(); - int top_pos = first.second->top(); - if (first.first == 0) { - if (top_pos >= 0) - return 0; - pixels = min(pixels, - top_pos); - break; - } - if (top_pos < ymin) - break; - tm.newParMetricsUp(); - } d->anchor_ypos_ += pixels; return pixels; }