annotate lisp/xt-mouse.el @ 13785:67493ecbff07

(LIBXMU, NO_EDITRES): Define only if not HAVE_LIBXMU.
author Karl Heuer <kwzh@gnu.org>
date Thu, 21 Dec 1995 17:19:05 +0000
parents 5de4c8a3f702
children 3a5b5eeba5b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13163
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; xt-mouse.el --- Support the mouse when emacs run in an xterm.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; Copyright (C) 1994 Free Software Foundation
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Keywords: mouse, terminals
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; This program is free software; you can redistribute it and/or modify
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; any later version.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;;
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; This program is distributed in the hope that it will be useful,
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU General Public License for more details.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;;
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; along with this program; if not, write to the Free Software
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;;; Comments:
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Enable mouse support when running inside an xterm.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; This is actually useful when you are running X11 locally, but is
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; working on remote machine over a modem line or through a gateway.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; It works by translating xterm escape codes into generic emacs mouse
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; events so it should work with any package that uses the mouse.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;; Todo:
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; Support multi-click -- somehow.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; Clicking on the mode-line does not work, although it should.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;; Code:
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (define-key function-key-map "\e[M" 'xterm-mouse-translate)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (defun xterm-mouse-translate (event)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; Read a click and release event from XTerm.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (save-excursion
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (save-window-excursion
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (deactivate-mark)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (let* ((last)
13500
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
47 (down (xterm-mouse-event))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
48 (down-command (nth 0 down))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
49 (down-data (nth 1 down))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
50 (down-where (nth 1 down-data))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
51 (down-binding (key-binding (if (symbolp down-where)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
52 (vector down-where down-command)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
53 (vector down-command)))))
13163
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (or (and (eq (read-char) ?\e)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (eq (read-char) ?\[)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (eq (read-char) ?M))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (error "Unexpected escape sequence from XTerm"))
13500
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
58 (let* ((click (xterm-mouse-event))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
59 (click-command (nth 0 click))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
60 (click-data (nth 1 click))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
61 (click-where (nth 1 click-data)))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
62 (if (memq down-binding '(nil ignore))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
63 (if (and (symbolp click-where)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
64 (not (eq 'menu-bar click-where)))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
65 (vector (list click-where click-data) click)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
66 (vector click))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
67 (setq unread-command-events
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
68 (if (eq down-where click-where)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
69 (list click)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
70 (list
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
71 ;; Cheat `mouse-drag-region' with move event.
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
72 (list 'mouse-movement click-data)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
73 ;; Generate a drag event.
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
74 (if (symbolp down-where)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
75 0
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
76 (list (intern (concat "drag-mouse-" (+ 1 last)))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
77 down-data click-data))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
78 )))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
79 (if (and (symbolp down-where)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
80 (not (eq 'menu-bar down-where)))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
81 (vector (list down-where down-data) down)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
82 (vector down))))))))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
83
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
84 (defvar xterm-mouse-x 0
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
85 "Position of last xterm mouse event relative to the frame.")
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
86
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
87 (defvar xterm-mouse-y 0
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
88 "Position of last xterm mouse event relative to the frame.")
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
89
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
90 (defadvice mouse-position (around xterm-mouse activate)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
91 "Use last key from xterm-mouse-mode if available."
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
92 (let ((answer ad-do-it))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
93 (setq ad-return-value
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
94 (if xterm-mouse-mode
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
95 (cons (car answer) (cons xterm-mouse-x xterm-mouse-y))
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
96 answer))))
13163
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (defun xterm-mouse-event ()
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; Convert XTerm mouse event to Emacs mouse event.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (let* ((type (- (read-char) ? ))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (x (- (read-char) ? 1))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (y (- (read-char) ? 1))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (point (cons x y))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (window (window-at x y))
13500
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
105 (where (if window
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
106 (coordinates-in-window-p point window)
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
107 'menu-bar))
13163
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (pos (if (consp where)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (progn
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (select-window window)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (goto-char (window-start window))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (move-to-window-line (cdr where))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (move-to-column (+ (car where) (current-column)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (max 0 (1- (window-hscroll)))))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (point))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 where))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (mouse (intern (if (eq type 3)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (concat "mouse-" (+ 1 last))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (setq last type)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (concat "down-mouse-" (+ 1 type))))))
13500
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
121 (setq xterm-mouse-x x
5de4c8a3f702 (global-map): Removed bindings of down events to ignore.
Richard M. Stallman <rms@gnu.org>
parents: 13163
diff changeset
122 xterm-mouse-y y)
13163
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (list mouse
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (list window pos point
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (/ (nth 2 (current-time)) 1000)))))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; Indicator for the xterm-mouse mode.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (defvar xterm-mouse-mode nil)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (or (assq 'xterm-mouse-mode minor-mode-alist)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (setq minor-mode-alist
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (cons '(xterm-mouse-mode (" Mouse")) minor-mode-alist)))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;;;###autoload
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (defun xterm-mouse-mode (arg)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 "Toggle XTerm mouse mode.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 With prefix arg, turn XTerm mouse mode on iff arg is positive.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 Turn it on to use emacs mouse commands, and off to use xterm mouse commands."
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (interactive "P")
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (if (or (and (null arg) xterm-mouse-mode)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (<= (prefix-numeric-value arg) 0))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; Turn it off
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (if xterm-mouse-mode
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (progn
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (turn-off-xterm-mouse-tracking)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (setq xterm-mouse-mode nil)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (set-buffer-modified-p (buffer-modified-p))))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;;Turn it on
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (if xterm-mouse-mode
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ()
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (setq xterm-mouse-mode t)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (turn-on-xterm-mouse-tracking)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (set-buffer-modified-p (buffer-modified-p)))))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (defun turn-on-xterm-mouse-tracking ()
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; Enable emacs mouse tracking in xterm.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (if xterm-mouse-mode
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (send-string-to-terminal "\e[?1000h")))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (defun turn-off-xterm-mouse-tracking ()
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; Disable disable emacs mouse tracking in xterm.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (if xterm-mouse-mode
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (send-string-to-terminal "\e[?1000l")))
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ;; Restore normal mouse behaviour outside Emacs.
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (add-hook 'suspend-hook 'turn-off-xterm-mouse-tracking)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (add-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (add-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (provide 'xt-mouse)
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
01f90e21a1db Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;;; xt-mouse.el ends here