Mercurial > emacs
comparison lisp/mwheel.el @ 38582:96ca8702243e
(mouse-wheel-down-button, mouse-wheel-up-button):
New user-options.
(mouse-wheel-change-button): New function.
(mouse-wheel-mode): Use mouse-wheel-{up,down}-button.
(mwheel-scroll): Ditto.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 27 Jul 2001 08:41:12 +0000 |
parents | 791ce66d397e |
children | 9985a0fdea47 |
comparison
equal
deleted
inserted
replaced
38581:9f3e1a8c8870 | 38582:96ca8702243e |
---|---|
1 ;;; mwheel.el --- Mouse support for MS intelli-mouse type mice | 1 ;;; mwheel.el --- Mouse support for MS intelli-mouse type mice |
2 | 2 |
3 ;; Copyright (C) 1998, 2000, Free Software Foundation, Inc. | 3 ;; Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. |
4 ;; Maintainer: William M. Perry <wmperry@gnu.org> | 4 ;; Maintainer: William M. Perry <wmperry@gnu.org> |
5 ;; Keywords: mouse | 5 ;; Keywords: mouse |
6 | 6 |
7 ;; This file is part of GNU Emacs. | 7 ;; This file is part of GNU Emacs. |
8 | 8 |
38 ;; (mwheel-install) | 38 ;; (mwheel-install) |
39 | 39 |
40 ;;; Code: | 40 ;;; Code: |
41 | 41 |
42 (require 'custom) | 42 (require 'custom) |
43 | |
44 ;; Setter function for mouse-button user-options. Switch Mouse Wheel | |
45 ;; mode off and on again so that the old button is unbound and | |
46 ;; new button is bound to mwheel-scroll. | |
47 | |
48 (defun mouse-wheel-change-button (var button) | |
49 (set-default var button) | |
50 (when mouse-wheel-mode | |
51 (mouse-wheel-mode 0) | |
52 (mouse-wheel-mode 1))) | |
53 | |
54 (defcustom mouse-wheel-down-button 4 | |
55 "Mouse button number for scrolling down." | |
56 :group 'mouse | |
57 :type 'integer | |
58 :set 'mouse-wheel-change-button) | |
59 | |
60 (defcustom mouse-wheel-up-button 5 | |
61 "Mouse button number for scrolling up." | |
62 :group 'mouse | |
63 :type 'integer | |
64 :set 'mouse-wheel-change-button) | |
43 | 65 |
44 (defcustom mouse-wheel-scroll-amount '(5 . 1) | 66 (defcustom mouse-wheel-scroll-amount '(5 . 1) |
45 "Amount to scroll windows by when spinning the mouse wheel. | 67 "Amount to scroll windows by when spinning the mouse wheel. |
46 This is actually a cons cell, where the first item is the amount to scroll | 68 This is actually a cons cell, where the first item is the amount to scroll |
47 on a normal wheel event, and the second is the amount to scroll when the | 69 on a normal wheel event, and the second is the amount to scroll when the |
87 (amt (if (memq 'shift (event-modifiers event)) | 109 (amt (if (memq 'shift (event-modifiers event)) |
88 (cdr mouse-wheel-scroll-amount) | 110 (cdr mouse-wheel-scroll-amount) |
89 (car mouse-wheel-scroll-amount)))) | 111 (car mouse-wheel-scroll-amount)))) |
90 (unwind-protect | 112 (unwind-protect |
91 (let ((button (mwheel-event-button event))) | 113 (let ((button (mwheel-event-button event))) |
92 (cond ((= button 4) (scroll-down amt)) | 114 (cond ((= button mouse-wheel-down-button) (scroll-down amt)) |
93 ((= button 5) (scroll-up amt)) | 115 ((= button mouse-wheel-up-button) (scroll-up amt)) |
94 (t (error "Bad binding in mwheel-scroll")))) | 116 (t (error "Bad binding in mwheel-scroll")))) |
95 (if curwin (select-window curwin))))) | 117 (if curwin (select-window curwin))))) |
96 | 118 |
97 | 119 |
98 ;;; Note this definition must be at the end of the file, because | 120 ;;; Note this definition must be at the end of the file, because |
110 ;; (S-)*mouse-[45], since those are aliases for the button | 132 ;; (S-)*mouse-[45], since those are aliases for the button |
111 ;; equivalents in XEmacs, but I want this to work in as many | 133 ;; equivalents in XEmacs, but I want this to work in as many |
112 ;; versions of XEmacs as it can. | 134 ;; versions of XEmacs as it can. |
113 (let ((keys | 135 (let ((keys |
114 (if (featurep 'xemacs) | 136 (if (featurep 'xemacs) |
115 '(button4 [(shift button4)] button5 [(shift button5)]) | 137 (let ((down (intern (format "button%d" mouse-wheel-down-button))) |
116 '([mouse-4] [S-mouse-4] [mouse-5] [S-mouse-5])))) | 138 (up (intern (format "button%d" mouse-wheel-up-button)))) |
139 `(,down [(shift ,down)] ,up [(shift ,up)])) | |
140 (let ((down (intern (format "mouse-%d" mouse-wheel-down-button))) | |
141 (s-down (intern (format "S-mouse-%d" mouse-wheel-down-button))) | |
142 (up (intern (format "mouse-%d" mouse-wheel-up-button))) | |
143 (s-up (intern (format "S-mouse-%d" mouse-wheel-up-button)))) | |
144 `([,down] [,s-down] [,up] [,s-up]))))) | |
117 ;; This condition-case is here because Emacs 19 will throw an error | 145 ;; This condition-case is here because Emacs 19 will throw an error |
118 ;; if you try to define a key that it does not know about. I for one | 146 ;; if you try to define a key that it does not know about. I for one |
119 ;; prefer to just unconditionally do a mwheel-install in my .emacs, so | 147 ;; prefer to just unconditionally do a mwheel-install in my .emacs, so |
120 ;; that if the wheeled-mouse is there, it just works, and this way it | 148 ;; that if the wheeled-mouse is there, it just works, and this way it |
121 ;; doesn't yell at me if I'm on my laptop or another machine, etc. | 149 ;; doesn't yell at me if I'm on my laptop or another machine, etc. |
131 ;;;###autoload | 159 ;;;###autoload |
132 (defun mwheel-install (&optional uninstall) | 160 (defun mwheel-install (&optional uninstall) |
133 "Enable mouse wheel support." | 161 "Enable mouse wheel support." |
134 (mouse-wheel-mode t)) | 162 (mouse-wheel-mode t)) |
135 | 163 |
136 | |
137 (provide 'mwheel) | 164 (provide 'mwheel) |
138 | 165 |
139 ;;; mwheel.el ends here | 166 ;;; mwheel.el ends here |