[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bb666073d3: Allow interpolating scrolls via the Page Down and Pag
From: |
Po Lu |
Subject: |
master bb666073d3: Allow interpolating scrolls via the Page Down and Page Up keys |
Date: |
Sat, 25 Dec 2021 21:36:59 -0500 (EST) |
branch: master
commit bb666073d34369606a1f446bb0f79dba388cb564
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Allow interpolating scrolls via the Page Down and Page Up keys
* lisp/pixel-scroll.el (pixel-scroll-precision-mode-map): Define
new commands.
(pixel-scroll-precision-interpolate-page): New user option.
(pixel-scroll-interpolate-down):
(pixel-scroll-interpolate-up): New functions.
---
lisp/pixel-scroll.el | 71 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 24 deletions(-)
diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index b943365a3f..3abd4b2a72 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -96,30 +96,32 @@ is always with pixel resolution.")
(defvar pixel-scroll-precision-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map [wheel-down] #'pixel-scroll-precision)
- (define-key map [wheel-up] #'pixel-scroll-precision)
- (define-key map [touch-end] #'pixel-scroll-start-momentum)
- (define-key map [mode-line wheel-down] #'pixel-scroll-precision)
- (define-key map [mode-line wheel-up] #'pixel-scroll-precision)
- (define-key map [mode-line touch-end] #'pixel-scroll-start-momentum)
- (define-key map [header-line wheel-down] #'pixel-scroll-precision)
- (define-key map [header-line wheel-up] #'pixel-scroll-precision)
- (define-key map [header-line touch-end] #'pixel-scroll-start-momentum)
- (define-key map [vertical-scroll-bar wheel-down] #'pixel-scroll-precision)
- (define-key map [vertical-scroll-bar wheel-up] #'pixel-scroll-precision)
- (define-key map [vertical-scroll-bar touch-end]
#'pixel-scroll-start-momentum)
- (define-key map [left-margin wheel-down] #'pixel-scroll-precision)
- (define-key map [left-margin wheel-up] #'pixel-scroll-precision)
- (define-key map [left-margin touch-end] #'pixel-scroll-start-momentum)
- (define-key map [right-margin wheel-down] #'pixel-scroll-precision)
- (define-key map [right-margin wheel-up] #'pixel-scroll-precision)
- (define-key map [right-margin touch-end] #'pixel-scroll-start-momentum)
- (define-key map [left-fringe wheel-down] #'pixel-scroll-precision)
- (define-key map [left-fringe wheel-up] #'pixel-scroll-precision)
- (define-key map [left-fringe touch-end] #'pixel-scroll-start-momentum)
- (define-key map [right-fringe wheel-down] #'pixel-scroll-precision)
- (define-key map [right-fringe wheel-up] #'pixel-scroll-precision)
- (define-key map [right-fringe touch-end] #'pixel-scroll-start-momentum)
+ (define-key map [wheel-down] 'pixel-scroll-precision)
+ (define-key map [wheel-up] 'pixel-scroll-precision)
+ (define-key map [touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [mode-line wheel-down] 'pixel-scroll-precision)
+ (define-key map [mode-line wheel-up] 'pixel-scroll-precision)
+ (define-key map [mode-line touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [header-line wheel-down] 'pixel-scroll-precision)
+ (define-key map [header-line wheel-up] 'pixel-scroll-precision)
+ (define-key map [header-line touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [vertical-scroll-bar wheel-down] 'pixel-scroll-precision)
+ (define-key map [vertical-scroll-bar wheel-up] 'pixel-scroll-precision)
+ (define-key map [vertical-scroll-bar touch-end]
'pixel-scroll-start-momentum)
+ (define-key map [left-margin wheel-down] 'pixel-scroll-precision)
+ (define-key map [left-margin wheel-up] 'pixel-scroll-precision)
+ (define-key map [left-margin touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [right-margin wheel-down] 'pixel-scroll-precision)
+ (define-key map [right-margin wheel-up] 'pixel-scroll-precision)
+ (define-key map [right-margin touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [left-fringe wheel-down] 'pixel-scroll-precision)
+ (define-key map [left-fringe wheel-up] 'pixel-scroll-precision)
+ (define-key map [left-fringe touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [right-fringe wheel-down] 'pixel-scroll-precision)
+ (define-key map [right-fringe wheel-up] 'pixel-scroll-precision)
+ (define-key map [right-fringe touch-end] 'pixel-scroll-start-momentum)
+ (define-key map [next] 'pixel-scroll-interpolate-down)
+ (define-key map [prior] 'pixel-scroll-interpolate-up)
map)
"The key map used by `pixel-scroll-precision-mode'.")
@@ -180,6 +182,13 @@ Nil means to not interpolate such scrolls."
:type 'float
:version "29.1")
+(defcustom pixel-scroll-precision-interpolate-page nil
+ "Whether or not to interpolate scrolling via the Page Down and Page Up keys.
+This is only effective when `pixel-scroll-precision-mode' is enabled."
+ :group 'scrolling
+ :type 'boolean
+ :version "29.1")
+
(defun pixel-scroll-in-rush-p ()
"Return non-nil if next scroll should be non-smooth.
When scrolling request is delivered soon after the previous one,
@@ -751,6 +760,20 @@ It is a vector of the form [ VELOCITY TIME ]."
(aset state 0 (make-ring 10))
(aset state 1 nil))))))))
+(defun pixel-scroll-interpolate-down ()
+ "Interpolate a scroll downwards by one page."
+ (interactive)
+ (if pixel-scroll-precision-interpolate-page
+ (pixel-scroll-precision-interpolate (- (window-text-height nil t)))
+ (scroll-up)))
+
+(defun pixel-scroll-interpolate-up ()
+ "Interpolate a scroll upwards by one page."
+ (interactive)
+ (if pixel-scroll-precision-interpolate-page
+ (pixel-scroll-precision-interpolate (window-text-height nil t))
+ (scroll-down)))
+
;;;###autoload
(define-minor-mode pixel-scroll-precision-mode
"Toggle pixel scrolling.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master bb666073d3: Allow interpolating scrolls via the Page Down and Page Up keys,
Po Lu <=