]> git.lyx.org Git - lyx.git/commitdiff
Get rid of BufferView::scrollUp/Down
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 3 Sep 2024 16:13:02 +0000 (18:13 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 5 Sep 2024 14:56:13 +0000 (16:56 +0200)
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.

src/BufferView.cpp
src/BufferView.h

index 485daf4f31a39efd2f3bdfffc89b9cd48ec087ab..75d145fa752ee08098810b4c7979bf429b4d8a7b 100644 (file)
@@ -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<int>(scroll_quantity));
                else {
-                       int const scroll_value = convert<int>(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;
index 0b9ade2f3bd73aa1c4a753f70839d60f40a4cb35..57d602de7f1cf8c9b653f10cb7f214ad58e70597 100644 (file)
@@ -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);