aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-02-22 11:57:31 +0000
committerDave Love2000-02-22 11:57:31 +0000
commitb2497d2e515ee895b2b9bc5664c05b749c03faa8 (patch)
tree5e851894c197b9c2c30c028a36f77a3d42e2e7bf
parent3d8700e8f12b88386ab09fbe2106e06b8720851e (diff)
downloademacs-b2497d2e515ee895b2b9bc5664c05b749c03faa8.tar.gz
emacs-b2497d2e515ee895b2b9bc5664c05b749c03faa8.zip
Doc fixes.
(xterm-mouse-position-function): New function, replacing advice of mouse-position. (xterm-mouse-mode): Use it.
-rw-r--r--lisp/xt-mouse.el39
1 files changed, 19 insertions, 20 deletions
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 66afcb016a7..808923ac578 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -1,6 +1,6 @@
1;;; xt-mouse.el --- Support the mouse when emacs run in an xterm. 1;;; xt-mouse.el --- Support the mouse when emacs run in an xterm.
2 2
3;; Copyright (C) 1994 Free Software Foundation 3;; Copyright (C) 1994, 2000 Free Software Foundation
4 4
5;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6;; Keywords: mouse, terminals 6;; Keywords: mouse, terminals
@@ -22,7 +22,7 @@
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA. 23;; Boston, MA 02111-1307, USA.
24 24
25;;; Comments: 25;;; Commentary:
26 26
27;; Enable mouse support when running inside an xterm or Linux console. 27;; Enable mouse support when running inside an xterm or Linux console.
28 28
@@ -45,14 +45,14 @@
45 45
46;; Clicking on the mode-line does not work, although it should. 46;; Clicking on the mode-line does not work, although it should.
47 47
48;;; Code: 48;;; Code:
49 49
50(define-key function-key-map "\e[M" 'xterm-mouse-translate) 50(define-key function-key-map "\e[M" 'xterm-mouse-translate)
51 51
52(defvar xterm-mouse-last) 52(defvar xterm-mouse-last)
53 53
54(defun xterm-mouse-translate (event) 54(defun xterm-mouse-translate (event)
55 ;; Read a click and release event from XTerm. 55 "Read a click and release event from XTerm."
56 (save-excursion 56 (save-excursion
57 (save-window-excursion 57 (save-window-excursion
58 (deactivate-mark) 58 (deactivate-mark)
@@ -86,7 +86,8 @@
86 ;; Generate a drag event. 86 ;; Generate a drag event.
87 (if (symbolp down-where) 87 (if (symbolp down-where)
88 0 88 0
89 (list (intern (format "drag-mouse-%d" (+ 1 xterm-mouse-last))) 89 (list (intern (format "drag-mouse-%d"
90 (+ 1 xterm-mouse-last)))
90 down-data click-data)) 91 down-data click-data))
91 ))) 92 )))
92 (if (and (symbolp down-where) 93 (if (and (symbolp down-where)
@@ -103,22 +104,19 @@
103;; Indicator for the xterm-mouse mode. 104;; Indicator for the xterm-mouse mode.
104(defvar xterm-mouse-mode nil) 105(defvar xterm-mouse-mode nil)
105 106
106(defadvice mouse-position (around xterm-mouse activate) 107(defun xterm-mouse-position-function (pos)
107 "Use last key from xterm-mouse-mode if available." 108 "Bound to `mouse-position-function' in XTerm mouse mode."
108 (let ((answer ad-do-it)) 109 (setcdr pos (cons xterm-mouse-x xterm-mouse-y))
109 (setq ad-return-value 110 pos)
110 (if xterm-mouse-mode
111 (cons (car answer) (cons xterm-mouse-x xterm-mouse-y))
112 answer))))
113 111
114(defun xterm-mouse-event () 112(defun xterm-mouse-event ()
115 ;; Convert XTerm mouse event to Emacs mouse event. 113 "Convert XTerm mouse event to Emacs mouse event."
116 (let* ((type (- (read-char) ? )) 114 (let* ((type (- (read-char) ? ))
117 (x (- (read-char) ? 1)) 115 (x (- (read-char) ? 1))
118 (y (- (read-char) ? 1)) 116 (y (- (read-char) ? 1))
119 (point (cons x y)) 117 (point (cons x y))
120 (window (window-at x y)) 118 (window (window-at x y))
121 (where (if window 119 (where (if window
122 (coordinates-in-window-p point window) 120 (coordinates-in-window-p point window)
123 'menu-bar)) 121 'menu-bar))
124 (pos (if (consp where) 122 (pos (if (consp where)
@@ -161,22 +159,23 @@ Turn it on to use emacs mouse commands, and off to use xterm mouse commands."
161 (if xterm-mouse-mode 159 (if xterm-mouse-mode
162 (progn 160 (progn
163 (turn-off-xterm-mouse-tracking) 161 (turn-off-xterm-mouse-tracking)
164 (setq xterm-mouse-mode nil) 162 (setq xterm-mouse-mode nil
163 mouse-position-function nil)
165 (set-buffer-modified-p (buffer-modified-p)))) 164 (set-buffer-modified-p (buffer-modified-p))))
166 ;;Turn it on 165 ;;Turn it on
167 (if xterm-mouse-mode 166 (unless (or window-systemxterm-mouse-mode)
168 () 167 (setq xterm-mouse-mode t
169 (setq xterm-mouse-mode t) 168 mouse-position-function #'xterm-mouse-position-function)
170 (turn-on-xterm-mouse-tracking) 169 (turn-on-xterm-mouse-tracking)
171 (set-buffer-modified-p (buffer-modified-p))))) 170 (set-buffer-modified-p (buffer-modified-p)))))
172 171
173(defun turn-on-xterm-mouse-tracking () 172(defun turn-on-xterm-mouse-tracking ()
174 ;; Enable emacs mouse tracking in xterm. 173 "Enable Emacs mouse tracking in xterm."
175 (if xterm-mouse-mode 174 (if xterm-mouse-mode
176 (send-string-to-terminal "\e[?1000h"))) 175 (send-string-to-terminal "\e[?1000h")))
177 176
178(defun turn-off-xterm-mouse-tracking () 177(defun turn-off-xterm-mouse-tracking ()
179 ;; Disable disable emacs mouse tracking in xterm. 178 "Disable disable Emacs mouse tracking in xterm."
180 (if xterm-mouse-mode 179 (if xterm-mouse-mode
181 (send-string-to-terminal "\e[?1000l"))) 180 (send-string-to-terminal "\e[?1000l")))
182 181