diff options
| author | Stefan Monnier | 2001-11-19 21:57:30 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2001-11-19 21:57:30 +0000 |
| commit | d3b32bfd6c06350902768deee33a095e5a112fab (patch) | |
| tree | a9610d43022384b343ff3dffa6126067057c463d | |
| parent | 70af2445b343a7c5908e88df5e07f12d85787187 (diff) | |
| download | emacs-d3b32bfd6c06350902768deee33a095e5a112fab.tar.gz emacs-d3b32bfd6c06350902768deee33a095e5a112fab.zip | |
(mouse-wheel-scroll-amount): Allow float values.
(mouse-wheel-scroll-amount): New var.
(mwheel-scroll): Use it and handle float values.
| -rw-r--r-- | lisp/mwheel.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 461ae41575b..6f2fe95eb72 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el | |||
| @@ -70,16 +70,26 @@ on a normal wheel event, and the second is the amount to scroll when the | |||
| 70 | wheel is moved with the shift key depressed. | 70 | wheel is moved with the shift key depressed. |
| 71 | 71 | ||
| 72 | Each item should be the number of lines to scroll, or `nil' for near | 72 | Each item should be the number of lines to scroll, or `nil' for near |
| 73 | full screen. | 73 | full screen. It can also be a floating point number, specifying |
| 74 | the fraction of the window to scroll. | ||
| 74 | A near full screen is `next-screen-context-lines' less than a full screen." | 75 | A near full screen is `next-screen-context-lines' less than a full screen." |
| 75 | :group 'mouse | 76 | :group 'mouse |
| 76 | :type '(cons | 77 | :type '(cons |
| 77 | (choice :tag "Normal" | 78 | (choice :tag "Normal" |
| 78 | (const :tag "Full screen" :value nil) | 79 | (const :tag "Full screen" :value nil) |
| 79 | (integer :tag "Specific # of lines")) | 80 | (integer :tag "Specific # of lines") |
| 81 | (float :tag "Fraction of window")) | ||
| 80 | (choice :tag "Shifted" | 82 | (choice :tag "Shifted" |
| 81 | (const :tag "Full screen" :value nil) | 83 | (const :tag "Full screen" :value nil) |
| 82 | (integer :tag "Specific # of lines")))) | 84 | (integer :tag "Specific # of lines") |
| 85 | (float :tag "Fraction of window")))) | ||
| 86 | |||
| 87 | (defcustom mouse-wheel-progessive-speed t | ||
| 88 | "If non-nil, the faster the user moves the wheel, the faster the scrolling. | ||
| 89 | Note that this has no effect when `mouse-wheel-scroll-amount' specifies | ||
| 90 | a \"near full screen\" scroll." | ||
| 91 | :group 'mouse | ||
| 92 | :type 'boolean) | ||
| 83 | 93 | ||
| 84 | (defcustom mouse-wheel-follow-mouse nil | 94 | (defcustom mouse-wheel-follow-mouse nil |
| 85 | "Whether the mouse wheel should scroll the window that the mouse is over. | 95 | "Whether the mouse wheel should scroll the window that the mouse is over. |
| @@ -101,6 +111,8 @@ This can be slightly disconcerting, but some people may prefer it." | |||
| 101 | (fset 'mwheel-event-window 'event-window)) | 111 | (fset 'mwheel-event-window 'event-window)) |
| 102 | 112 | ||
| 103 | (defun mwheel-scroll (event) | 113 | (defun mwheel-scroll (event) |
| 114 | "Scroll up or down according to the EVENT. | ||
| 115 | This should only be bound to mouse buttons 4 and 5." | ||
| 104 | (interactive "e") | 116 | (interactive "e") |
| 105 | (let ((curwin (if mouse-wheel-follow-mouse | 117 | (let ((curwin (if mouse-wheel-follow-mouse |
| 106 | (prog1 | 118 | (prog1 |
| @@ -109,6 +121,11 @@ This can be slightly disconcerting, but some people may prefer it." | |||
| 109 | (amt (if (memq 'shift (event-modifiers event)) | 121 | (amt (if (memq 'shift (event-modifiers event)) |
| 110 | (cdr mouse-wheel-scroll-amount) | 122 | (cdr mouse-wheel-scroll-amount) |
| 111 | (car mouse-wheel-scroll-amount)))) | 123 | (car mouse-wheel-scroll-amount)))) |
| 124 | (if (floatp amt) (setq amt (1+ (truncate (* amt (window-height)))))) | ||
| 125 | (when (and mouse-wheel-progessive-speed (numberp amt)) | ||
| 126 | ;; When the double-mouse-N comes in, a mouse-N has been executed already, | ||
| 127 | ;; So by adding things up we get a squaring up (1, 3, 6, 10, 16, ...). | ||
| 128 | (setq amt (* amt (event-click-count event)))) | ||
| 112 | (unwind-protect | 129 | (unwind-protect |
| 113 | (let ((button (mwheel-event-button event))) | 130 | (let ((button (mwheel-event-button event))) |
| 114 | (cond ((= button mouse-wheel-down-button) (scroll-down amt)) | 131 | (cond ((= button mouse-wheel-down-button) (scroll-down amt)) |
| @@ -117,10 +134,6 @@ This can be slightly disconcerting, but some people may prefer it." | |||
| 117 | (if curwin (select-window curwin))))) | 134 | (if curwin (select-window curwin))))) |
| 118 | 135 | ||
| 119 | 136 | ||
| 120 | ;;; Note this definition must be at the end of the file, because | ||
| 121 | ;;; `define-minor-mode' actually calls the mode-function if the | ||
| 122 | ;;; associated variable is non-nil, which requires that all needed | ||
| 123 | ;;; functions be already defined. | ||
| 124 | ;;;###autoload | 137 | ;;;###autoload |
| 125 | (define-minor-mode mouse-wheel-mode | 138 | (define-minor-mode mouse-wheel-mode |
| 126 | "Toggle mouse wheel support. | 139 | "Toggle mouse wheel support. |