[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1450fa1: Make it work to pixel scroll by deltas larger than the w
From: |
Po Lu |
Subject: |
master 1450fa1: Make it work to pixel scroll by deltas larger than the window |
Date: |
Fri, 3 Dec 2021 20:10:42 -0500 (EST) |
branch: master
commit 1450fa16ed9ae41993ff32db51f380e3c99c908e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Make it work to pixel scroll by deltas larger than the window
* lisp/pixel-scroll.el
(pixel-scroll-precision-scroll-down-page):
(pixel-scroll-precision-scroll-up-page): New functions.
(pixel-scroll-precision-scroll-up)
(pixel-scroll-precision-scroll-down): Make it safe to scroll
by deltas larger than the current window.
---
lisp/pixel-scroll.el | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index 1c2d956..740aaf9 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -401,10 +401,7 @@ Otherwise, redisplay will reset the window's vscroll."
(set-window-start nil (pixel-point-at-unseen-line) t)
(set-window-vscroll nil vscroll t))
-;; FIXME: This doesn't work when DELTA is larger than the height
-;; of the current window, and someone should probably fix that
-;; at some point.
-(defun pixel-scroll-precision-scroll-down (delta)
+(defun pixel-scroll-precision-scroll-down-page (delta)
"Scroll the current window down by DELTA pixels.
Note that this function doesn't work if DELTA is larger than
the height of the current window."
@@ -440,8 +437,18 @@ the height of the current window."
(set-window-start nil desired-start t))
(set-window-vscroll nil desired-vscroll t))))
-(defun pixel-scroll-precision-scroll-up (delta)
- "Scroll the current window up by DELTA pixels."
+(defun pixel-scroll-precision-scroll-down (delta)
+ "Scroll the current window down by DELTA pixels."
+ (let ((max-height (window-text-height nil t)))
+ (while (> delta max-height)
+ (pixel-scroll-precision-scroll-down-page max-height)
+ (setq delta (- delta max-height)))
+ (pixel-scroll-precision-scroll-down-page delta)))
+
+(defun pixel-scroll-precision-scroll-up-page (delta)
+ "Scroll the current window up by DELTA pixels.
+Note that this function doesn't work if DELTA is larger than
+the height of the current window."
(let* ((edges (window-edges nil t nil t))
(max-y (- (nth 3 edges)
(nth 1 edges)))
@@ -490,6 +497,14 @@ the height of the current window."
(set-window-vscroll nil desired-vscroll t))
(set-window-vscroll nil (abs delta) t)))))))
+(defun pixel-scroll-precision-scroll-up (delta)
+ "Scroll the current window up by DELTA pixels."
+ (let ((max-height (window-text-height nil t)))
+ (while (> delta max-height)
+ (pixel-scroll-precision-scroll-up-page max-height)
+ (setq delta (- delta max-height)))
+ (pixel-scroll-precision-scroll-up-page delta)))
+
;; FIXME: This doesn't _always_ work when there's an image above the
;; current line that is taller than the window, and scrolling can
;; sometimes be jumpy in that case.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 1450fa1: Make it work to pixel scroll by deltas larger than the window,
Po Lu <=