• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/

Lines Matching defs:mouse

1 ;;; xt-mouse.el --- support the mouse when emacs run in an xterm
7 ;; Keywords: mouse, terminals
28 ;; Enable mouse support when running inside an xterm.
33 ;; It works by translating xterm escape codes into generic emacs mouse
34 ;; events so it should work with any package that uses the mouse.
36 ;; You don't have to turn off xterm mode to use the normal xterm mouse
38 ;; when you press the mouse button.
46 (define-key function-key-map "\e[M" 'xterm-mouse-translate)
48 (defvar xterm-mouse-last)
51 ;; the value 'mouse-click.
52 (dolist (event-type '(mouse-1 mouse-2 mouse-3
53 M-down-mouse-1 M-down-mouse-2 M-down-mouse-3))
54 (put event-type 'event-kind 'mouse-click))
56 (defun xterm-mouse-translate (event)
61 (let* ((xterm-mouse-last)
62 (down (xterm-mouse-event))
69 (is-click (string-match "^mouse" (symbol-name (car down)))))
77 (let* ((click (if is-click down (xterm-mouse-event)))
90 ;; Cheat `mouse-drag-region' with move event.
91 (list 'mouse-movement click-data)
95 (list (intern (format "drag-mouse-%d"
96 (+ 1 xterm-mouse-last)))
103 (defvar xterm-mouse-x 0
104 "Position of last xterm mouse event relative to the frame.")
106 (defvar xterm-mouse-y 0
107 "Position of last xterm mouse event relative to the frame.")
109 (defvar xt-mouse-epoch nil)
111 ;; Indicator for the xterm-mouse mode.
113 (defun xterm-mouse-position-function (pos)
114 "Bound to `mouse-position-function' in XTerm mouse mode."
115 (setcdr pos (cons xterm-mouse-x xterm-mouse-y))
119 (defun xterm-mouse-event-read ()
125 (defun xterm-mouse-truncate-wrap (f)
141 (defun xterm-mouse-event ()
142 "Convert XTerm mouse event to Emacs mouse event."
143 (let* ((type (- (xterm-mouse-event-read) #o40))
144 (x (- (xterm-mouse-event-read) #o40 1))
145 (y (- (xterm-mouse-event-read) #o40 1))
147 ;; for default value of mouse-1-click-follows-link (450msec).
148 (timestamp (xterm-mouse-truncate-wrap
151 (or xt-mouse-epoch
152 (setq xt-mouse-epoch (float-time)))))))
153 (mouse (intern
159 (format "mouse-%d" (- type 60)))
161 (setq xterm-mouse-last type)
162 (format "M-down-mouse-%d" (- type 7)))
164 (format "mouse-%d" (- xterm-mouse-last 7)))
166 (format "mouse-%d" (+ 1 xterm-mouse-last)))
168 (setq xterm-mouse-last type)
169 (format "down-mouse-%d" (+ 1 type))))))
175 (setq xterm-mouse-x x
176 xterm-mouse-y y)
179 (list mouse
188 (define-minor-mode xterm-mouse-mode
189 "Toggle XTerm mouse mode.
190 With prefix arg, turn XTerm mouse mode on iff arg is positive.
192 Turn it on to use Emacs mouse commands, and off to use xterm mouse commands.
194 works for simple uses of the mouse. Basically, only non-modified
196 mouse functionality for such clicks is still available by holding
197 down the SHIFT key while pressing the mouse button."
198 :global t :group 'mouse
199 (if xterm-mouse-mode
202 (setq mouse-position-function #'xterm-mouse-position-function)
203 (turn-on-xterm-mouse-tracking))
205 (turn-off-xterm-mouse-tracking 'force)
206 (setq mouse-position-function nil)))
208 (defun turn-on-xterm-mouse-tracking ()
209 "Enable Emacs mouse tracking in xterm."
210 (if xterm-mouse-mode
213 (defun turn-off-xterm-mouse-tracking (&optional force)
214 "Disable Emacs mouse tracking in xterm."
215 (if (or force xterm-mouse-mode)
218 ;; Restore normal mouse behaviour outside Emacs.
219 (add-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
220 (add-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
221 (add-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking)
223 (provide 'xt-mouse)
226 ;;; xt-mouse.el ends here