From: Jean-Marc Lasgouttes Date: Tue, 3 Sep 2024 16:13:02 +0000 (+0200) Subject: Get rid of BufferView::scrollUp/Down X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=439b7bb9c97ba2f267a4ccc9ae3d9af5eab100f9;p=lyx.git Get rid of BufferView::scrollUp/Down LFUN_SCROLL was the last user, change it to use only scroll(). Take this opportunity to improve a bit this dispatch code. Also improve somewhat the methods documentation. --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 485daf4f31..75d145fa75 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2168,18 +2168,24 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) scroll_step = d->scrollbarParameters_.single_step; else if (scroll_type == "page") scroll_step = d->scrollbarParameters_.page_step; - else + else { + dispatched = false; return; + } + string const scroll_quantity = cmd.getArg(1); + if (scroll_quantity == "up") - scrollUp(scroll_step); + scroll(-scroll_step); else if (scroll_quantity == "down") - scrollDown(scroll_step); + scroll(scroll_step); + else if (isStrInt(scroll_quantity)) + scroll(scroll_step * convert(scroll_quantity)); else { - int const scroll_value = convert(scroll_quantity); - if (scroll_value) - scroll(scroll_step * scroll_value); + dispatched = false; + return; } + dr.screenUpdate(Update::ForceDraw); dr.forceBufferUpdate(); break; @@ -2859,20 +2865,6 @@ int BufferView::scroll(int pixels) } -int BufferView::scrollDown(int pixels) -{ - d->anchor_ypos_ -= pixels; - return -pixels; -} - - -int BufferView::scrollUp(int pixels) -{ - d->anchor_ypos_ += pixels; - return pixels; -} - - bool BufferView::setCursorFromRow(int row) { TexRow::TextEntry start, end; diff --git a/src/BufferView.h b/src/BufferView.h index 0b9ade2f3b..57d602de7f 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -218,17 +218,17 @@ public: /// Ensure the passed cursor \p dit is visible. /// This method will automatically scroll and update the BufferView /// (metrics+drawing) if needed. - /// \param how Use this scroll strategy + /// \param how: where the cursor should appear (visible/top/center) void showCursor(DocIterator const & dit, ScrollType how); /// Scroll to the cursor. - /// \param how Use this scroll strategy + /// This only updates the anchor vertical position, but does not + /// recompute metrics nor trigger a screen refresh. + /// \param how: where the cursor should appear (visible/top/center) /// \return true if screen was scrolled bool scrollToCursor(DocIterator const & dit, ScrollType how); - /// scroll down document by the given number of pixels. - int scrollDown(int pixels); - /// scroll up document by the given number of pixels. - int scrollUp(int pixels); - /// scroll document by the given number of pixels. + /// scroll the view by the given number of pixels. This only + /// updates the anchor vertical position, but does not recompute + /// metrics nor trigger a screen refresh. int scroll(int pixels); /// Scroll the view by a number of pixels. void scrollDocView(int pixels);