aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-05-25 14:34:35 +0000
committerStefan Monnier2007-05-25 14:34:35 +0000
commit6ab93c85b827be908a86135d8f303cfea79d1e4b (patch)
tree0f110f16c03971a96853d99256a3fc236294be5d
parentdade3ed8e7efa44d9c07871733bffc790df04cad (diff)
downloademacs-6ab93c85b827be908a86135d8f303cfea79d1e4b.tar.gz
emacs-6ab93c85b827be908a86135d8f303cfea79d1e4b.zip
(xterm-mouse-truncate-wrap): New function.
(xterm-mouse-event): Use it.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/xt-mouse.el29
2 files changed, 27 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 560b0480810..a2976615ad1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12007-05-25 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * xt-mouse.el (xterm-mouse-truncate-wrap): New function.
4 (xterm-mouse-event): Use it.
5
12007-05-25 Juanma Barranquero <lekktu@gmail.com> 62007-05-25 Juanma Barranquero <lekktu@gmail.com>
2 7
3 * bs.el (bs-cycle-previous): Don't modify the cycle list until 8 * bs.el (bs-cycle-previous): Don't modify the cycle list until
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 3a7c8fd553a..349bfb3f764 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -126,6 +126,21 @@
126 (+ c #x8000000 128) 126 (+ c #x8000000 128)
127 c))) 127 c)))
128 128
129(defun xterm-mouse-truncate-wrap (f)
130 "Truncate with wrap-around."
131 (condition-case nil
132 ;; First try the built-in truncate, in case there's no overflow.
133 (truncate f)
134 ;; In case of overflow, do wraparound by hand.
135 (range-error
136 ;; In our case, we wrap around every 3 days or so, so if we assume
137 ;; a maximum of 65536 wraparounds, we're safe for a couple years.
138 ;; Using a power of 2 makes rounding errors less likely.
139 (let* ((maxwrap (* 65536 2048))
140 (dbig (truncate (/ f maxwrap)))
141 (fdiff (- f (* 1.0 maxwrap dbig))))
142 (+ (truncate fdiff) (* maxwrap dbig))))))
143
129(defun xterm-mouse-event () 144(defun xterm-mouse-event ()
130 "Convert XTerm mouse event to Emacs mouse event." 145 "Convert XTerm mouse event to Emacs mouse event."
131 (let* ((type (- (xterm-mouse-event-read) #o40)) 146 (let* ((type (- (xterm-mouse-event-read) #o40))
@@ -133,12 +148,12 @@
133 (y (- (xterm-mouse-event-read) #o40 1)) 148 (y (- (xterm-mouse-event-read) #o40 1))
134 ;; Emulate timestamp information. This is accurate enough 149 ;; Emulate timestamp information. This is accurate enough
135 ;; for default value of mouse-1-click-follows-link (450msec). 150 ;; for default value of mouse-1-click-follows-link (450msec).
136 (timestamp (truncate 151 (timestamp (xterm-mouse-truncate-wrap
137 (* 1000 152 (* 1000
138 (- (float-time) 153 (- (float-time)
139 (or xt-mouse-epoch 154 (or xt-mouse-epoch
140 (setq xt-mouse-epoch (float-time))))))) 155 (setq xt-mouse-epoch (float-time)))))))
141 (mouse (intern 156 (mouse (intern
142 ;; For buttons > 3, the release-event looks 157 ;; For buttons > 3, the release-event looks
143 ;; differently (see xc/programs/xterm/button.c, 158 ;; differently (see xc/programs/xterm/button.c,
144 ;; function EditorButton), and there seems to come in 159 ;; function EditorButton), and there seems to come in
@@ -210,5 +225,5 @@ down the SHIFT key while pressing the mouse button."
210 225
211(provide 'xt-mouse) 226(provide 'xt-mouse)
212 227
213;;; arch-tag: 84962d4e-fae9-4c13-a9d7-ef4925a4ac03 228;; arch-tag: 84962d4e-fae9-4c13-a9d7-ef4925a4ac03
214;;; xt-mouse.el ends here 229;;; xt-mouse.el ends here