aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Roberts2005-01-12 06:13:08 +0000
committerNick Roberts2005-01-12 06:13:08 +0000
commitbf31a09320c3ec079e8cbb035f20533e8bfa5b7e (patch)
tree55e185041465e3ffe5fafc0b5b47a60d9636682d
parenta1c9fd1979349f5ae51ea7600f5c299e349be751 (diff)
downloademacs-bf31a09320c3ec079e8cbb035f20533e8bfa5b7e.tar.gz
emacs-bf31a09320c3ec079e8cbb035f20533e8bfa5b7e.zip
(xterm-mouse-translate, xterm-mouse-event): Enable
mouse clicks on mode-line, header-line and margin. (event-type): Give mouse event symbols an 'event-kind property with value 'mouse-click.
-rw-r--r--lisp/xt-mouse.el50
1 files changed, 16 insertions, 34 deletions
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 19b58475a93..de93456ad5a 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -43,14 +43,17 @@
43 43
44;; Support multi-click -- somehow. 44;; Support multi-click -- somehow.
45 45
46;; Clicking on the mode-line does not work, although it should.
47
48;;; Code: 46;;; Code:
49 47
50(define-key function-key-map "\e[M" 'xterm-mouse-translate) 48(define-key function-key-map "\e[M" 'xterm-mouse-translate)
51 49
52(defvar xterm-mouse-last) 50(defvar xterm-mouse-last)
53 51
52;; Mouse events symbols must have an 'event-kind property with
53;; the value 'mouse-click.
54(dolist (event-type '(mouse-1 mouse-2 mouse-3))
55 (put event-type 'event-kind 'mouse-click))
56
54(defun xterm-mouse-translate (event) 57(defun xterm-mouse-translate (event)
55 "Read a click and release event from XTerm." 58 "Read a click and release event from XTerm."
56 (save-excursion 59 (save-excursion
@@ -78,7 +81,7 @@
78 (click-where (nth 1 click-data))) 81 (click-where (nth 1 click-data)))
79 (if (memq down-binding '(nil ignore)) 82 (if (memq down-binding '(nil ignore))
80 (if (and (symbolp click-where) 83 (if (and (symbolp click-where)
81 (not (eq 'menu-bar click-where))) 84 (consp click-where))
82 (vector (list click-where click-data) click) 85 (vector (list click-where click-data) click)
83 (vector click)) 86 (vector click))
84 (setq unread-command-events 87 (setq unread-command-events
@@ -92,10 +95,9 @@
92 0 95 0
93 (list (intern (format "drag-mouse-%d" 96 (list (intern (format "drag-mouse-%d"
94 (+ 1 xterm-mouse-last))) 97 (+ 1 xterm-mouse-last)))
95 down-data click-data)) 98 down-data click-data)))))
96 )))
97 (if (and (symbolp down-where) 99 (if (and (symbolp down-where)
98 (not (eq 'menu-bar down-where))) 100 (consp down-where))
99 (vector (list down-where down-data) down) 101 (vector (list down-where down-data) down)
100 (vector down)))))))) 102 (vector down))))))))
101 103
@@ -124,30 +126,6 @@
124 (let* ((type (- (xterm-mouse-event-read) #o40)) 126 (let* ((type (- (xterm-mouse-event-read) #o40))
125 (x (- (xterm-mouse-event-read) #o40 1)) 127 (x (- (xterm-mouse-event-read) #o40 1))
126 (y (- (xterm-mouse-event-read) #o40 1)) 128 (y (- (xterm-mouse-event-read) #o40 1))
127 (point (cons x y))
128 (window (window-at x y))
129 (where (if window
130 (coordinates-in-window-p point window)
131 'menu-bar))
132 (pos (if (consp where)
133 (progn
134 (select-window window)
135 (goto-char (window-start window))
136 (move-to-window-line (-
137 (cdr where)
138 (if (or header-line-format
139 default-header-line-format)
140 1
141 0)))
142 (move-to-column (- (+ (car where) (current-column)
143 (if (string-match "\\` \\*Minibuf"
144 (buffer-name))
145 (- (minibuffer-prompt-width))
146 0)
147 (max 0 (1- (window-hscroll))))
148 left-margin-width))
149 (point))
150 where))
151 (mouse (intern 129 (mouse (intern
152 ;; For buttons > 3, the release-event looks 130 ;; For buttons > 3, the release-event looks
153 ;; differently (see xc/programs/xterm/button.c, 131 ;; differently (see xc/programs/xterm/button.c,
@@ -159,12 +137,16 @@
159 (format "mouse-%d" (+ 1 xterm-mouse-last))) 137 (format "mouse-%d" (+ 1 xterm-mouse-last)))
160 (t 138 (t
161 (setq xterm-mouse-last type) 139 (setq xterm-mouse-last type)
162 (format "down-mouse-%d" (+ 1 type))))))) 140 (format "down-mouse-%d" (+ 1 type))))))
141 (w (window-at x y)))
163 (setq xterm-mouse-x x 142 (setq xterm-mouse-x x
164 xterm-mouse-y y) 143 xterm-mouse-y y)
165 (list mouse 144 (if w
166 (list window pos point 145 (list mouse (posn-at-x-y x (if menu-bar-mode (- y 1) y) w))
167 (/ (nth 2 (current-time)) 1000))))) 146 (list mouse
147 (append (list nil 'menu-bar)
148 (nthcdr 2 (posn-at-x-y
149 x (if menu-bar-mode (- y 1) y) w)))))))
168 150
169;;;###autoload 151;;;###autoload
170(define-minor-mode xterm-mouse-mode 152(define-minor-mode xterm-mouse-mode