Mercurial > emacs
annotate lisp/t-mouse.el @ 76823:13dc9d1d73e2
Move url-http.el entry to lisp/url/ChangeLog.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 31 Mar 2007 09:51:25 +0000 |
parents | 0073c48648d0 |
children | f6250d52a57e |
rev | line source |
---|---|
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
1 ;;; t-mouse.el --- mouse support within the text terminal |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
2 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
3 ;; Authors: Alessandro Rubini and Ian T Zimmerman |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
4 ;; Maintainer: Nick Roberts <nickrob@gnu.org> |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
5 ;; Keywords: mouse gpm linux |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
6 |
75298
c5e686c22f72
Update copyright following assignment by
Nick Roberts <nickrob@snap.net.nz>
parents:
73753
diff
changeset
|
7 ;; Copyright (C) 1994, 1995, 1998, 2006, 2007 Free Software Foundation, Inc. |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
8 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
10 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
14 ;; any later version. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
15 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
19 ;; GNU General Public License for more details. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
20 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
24 ;; Boston, MA 02110-1301, USA. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
25 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
26 ;;; Commentary: |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
27 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
28 ;; This package provides access to mouse event as reported by the |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
29 ;; gpm-Linux package. It uses the program "mev" to get mouse events. |
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
30 ;; It tries to reproduce the functionality offered by Emacs under X. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
31 ;; The "gpm" server runs under Linux, so this package is rather |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
32 ;; Linux-dependent. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
33 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
34 ;; Modified by Nick Roberts for Emacs 22. In particular, the mode-line is |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
35 ;; now position sensitive. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
36 |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
37 (defvar t-mouse-process nil |
73753
3480cc226de3
(t-mouse-process, t-mouse-mode): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
72199
diff
changeset
|
38 "Embeds the process which passes mouse events to Emacs. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
39 It is used by the program t-mouse.") |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
40 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
41 (defvar t-mouse-filter-accumulator "" |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
42 "Accumulates input from the mouse reporting process.") |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
43 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
44 (defvar t-mouse-debug-buffer nil |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
45 "Events normally posted to command queue are printed here in debug mode. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
46 See `t-mouse-start-debug'.") |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
47 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
48 (defvar t-mouse-current-xy '(0 . 0) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
49 "Stores the last mouse position t-mouse has been told about.") |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
50 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
51 (defvar t-mouse-drag-start nil |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
52 "Whenever a drag starts in a special part of a window |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
53 \(not the text), the `translated' starting coordinates including the |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
54 window and part involved are saved here. This is necessary lest they |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
55 get re-translated when the button goes up, at which time window |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
56 configuration may have changed.") |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
57 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
58 (defvar t-mouse-prev-set-selection-function 'x-set-selection) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
59 (defvar t-mouse-prev-get-selection-function 'x-get-selection) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
60 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
61 (defvar t-mouse-swap-alt-keys nil |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
62 "When set, Emacs will handle mouse events with the right Alt |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
63 \(a.k.a. Alt-Ger) modifier, not with the regular left Alt modifier. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
64 Useful for people who play strange games with their keyboard tables.") |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
65 |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
66 (defvar t-mouse-fix-21 nil |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
67 "Enable brain-dead chords for 2 button mice.") |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
68 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
69 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
70 ;;; Code: |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
71 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
72 ;; get the number of the current virtual console |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
73 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
74 (defun t-mouse-tty () |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
75 "Return number of virtual terminal Emacs is running on, as a string. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
76 For example, \"2\" for /dev/tty2." |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
77 (with-temp-buffer |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
78 (call-process "ps" nil t nil "h" (format "%s" (emacs-pid))) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
79 (goto-char (point-min)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
80 (if (or |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
81 ;; Many versions of "ps", all different.... |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
82 (re-search-forward " +tty\\(.?[0-9a-f]\\)" nil t) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
83 (re-search-forward "p \\([0-9a-f]\\)" nil t) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
84 (re-search-forward "v0\\([0-9a-f]\\)" nil t) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
85 (re-search-forward "[0-9]+ +\\([0-9]+\\)" nil t) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
86 (re-search-forward "[\\t ]*[0-9]+[\\t ]+\\([0-9]+\\)" nil t) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
87 (re-search-forward " +vc/\\(.?[0-9a-f]\\)" nil t) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
88 (re-search-forward " +pts/\\(.?[0-9a-f]\\)" nil t)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
89 (buffer-substring (match-beginning 1) (match-end 1))))) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
90 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
91 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
92 ;; due to a horrible kludge in Emacs' keymap handler |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
93 ;; (read_key_sequence) mouse clicks on funny parts of windows generate |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
94 ;; TWO events, the first being a dummy of the sort '(mode-line). |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
95 ;; That's why Per Abrahamsen's code in xt-mouse.el doesn't work for |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
96 ;; the modeline, for instance. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
97 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
98 ;; now get this: the Emacs C code that generates these fake events |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
99 ;; depends on certain things done by the very lowest level input |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
100 ;; handlers; namely the symbols for the events (for instance |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
101 ;; 'C-S-double-mouse-2) must have an 'event-kind property, set to |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
102 ;; 'mouse-click. Since events from unread-command-events do not pass |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
103 ;; through the low level handlers, they don't get this property unless |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
104 ;; I set it myself. I imagine this has caused innumerable attempts by |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
105 ;; hackers to do things similar to t-mouse to lose. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
106 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
107 ;; The next page of code is devoted to fixing this ugly problem. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
108 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
109 ;; WOW! a fully general powerset generator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
110 ;; (C) Ian Zimmerman Mon Mar 23 12:00:16 PST 1998 :-) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
111 (defun t-mouse-powerset (l) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
112 (if (null l) '(nil) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
113 (let ((l1 (t-mouse-powerset (cdr l))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
114 (first (nth 0 l))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
115 (append |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
116 (mapcar (function (lambda (l) (cons first l))) l1) l1)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
117 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
118 ;; and a slightly less general cartesian product |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
119 (defun t-mouse-cartesian (l1 l2) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
120 (if (null l1) l2 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
121 (append (mapcar (function (lambda (x) (append (nth 0 l1) x))) l2) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
122 (t-mouse-cartesian (cdr l1) l2)))) |
73753
3480cc226de3
(t-mouse-process, t-mouse-mode): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
72199
diff
changeset
|
123 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
124 (let* ((modifier-sets (t-mouse-powerset '(control meta shift))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
125 (typed-sets (t-mouse-cartesian '((down) (drag)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
126 '((mouse-1) (mouse-2) (mouse-3)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
127 (multipled-sets (t-mouse-cartesian '((double) (triple)) typed-sets)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
128 (all-sets (t-mouse-cartesian modifier-sets multipled-sets))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
129 (while all-sets |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
130 (let ((event-sym (event-convert-list (nth 0 all-sets)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
131 (if (not (get event-sym 'event-kind)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
132 (put event-sym 'event-kind 'mouse-click))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
133 (setq all-sets (cdr all-sets)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
134 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
135 (defun t-mouse-make-event-element (x-dot-y-avec-time) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
136 (let* ((x-dot-y (nth 0 x-dot-y-avec-time)) |
76590
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
137 (time (nth 1 x-dot-y-avec-time)) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
138 (x (car x-dot-y)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
139 (y (cdr x-dot-y)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
140 (w (window-at x y)) |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
141 (ltrb (window-edges w)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
142 (left (nth 0 ltrb)) |
76590
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
143 (top (nth 1 ltrb)) |
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
144 (event (if w |
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
145 (posn-at-x-y (- x left) (- y top) w t) |
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
146 (append (list nil 'menu-bar) |
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
147 (nthcdr 2 (posn-at-x-y x y w t)))))) |
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
148 (setcar (nthcdr 3 event) time) |
0073c48648d0
(t-mouse-make-event-element): Use timestamp output
Nick Roberts <nickrob@snap.net.nz>
parents:
75298
diff
changeset
|
149 event)) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
150 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
151 ;;; This fun is partly Copyright (C) 1994 Per Abrahamsen <abraham@iesd.auc.dk> |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
152 (defun t-mouse-make-event () |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
153 "Make a Lisp style event from the contents of mouse input accumulator. |
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
154 Also trim the accumulator by all the data used to build the event." |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
155 (let (ob (ob-pos (condition-case nil |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
156 (progn |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
157 ;; this test is just needed for Fedora Core 3 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
158 (if (string-match "STILL RUNNING_1\n" |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
159 t-mouse-filter-accumulator) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
160 (setq t-mouse-filter-accumulator |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
161 (substring |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
162 t-mouse-filter-accumulator (match-end 0)))) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
163 (read-from-string t-mouse-filter-accumulator)) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
164 (error nil)))) |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
165 ;; this test is just needed for Fedora Core 3 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
166 (if (or (eq (car ob-pos) 'STILL) (eq (car ob-pos) '***) (not ob-pos)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
167 nil |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
168 (setq ob (car ob-pos)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
169 (setq t-mouse-filter-accumulator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
170 (substring t-mouse-filter-accumulator (cdr ob-pos))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
171 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
172 ;;now the real work |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
173 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
174 (let ((event-type (nth 0 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
175 (current-xy-avec-time (nth 1 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
176 (type-switch (length ob))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
177 (if t-mouse-fix-21 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
178 (let |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
179 ;;Acquire the event's symbol's name. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
180 ((event-name-string (symbol-name event-type)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
181 end-of-root-event-name |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
182 new-event-name-string) |
73753
3480cc226de3
(t-mouse-process, t-mouse-mode): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
72199
diff
changeset
|
183 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
184 (if (string-match "-\\(21\\|\\12\\)$" event-name-string) |
73753
3480cc226de3
(t-mouse-process, t-mouse-mode): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
72199
diff
changeset
|
185 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
186 ;;Transform the name to what it should have been. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
187 (progn |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
188 (setq end-of-root-event-name (match-beginning 0)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
189 (setq new-event-name-string |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
190 (concat (substring |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
191 event-name-string 0 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
192 end-of-root-event-name) "-3")) |
73753
3480cc226de3
(t-mouse-process, t-mouse-mode): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
72199
diff
changeset
|
193 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
194 ;;Change the event to the symbol that corresponds to the |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
195 ;;name we made. The proper symbol already exists. |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
196 (setq event-type |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
197 (intern new-event-name-string)))))) |
73753
3480cc226de3
(t-mouse-process, t-mouse-mode): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
72199
diff
changeset
|
198 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
199 ;;store current position for mouse-position |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
200 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
201 (setq t-mouse-current-xy (nth 0 current-xy-avec-time)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
202 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
203 ;;events have many types but fortunately they differ in length |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
204 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
205 (cond |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
206 ((= type-switch 4) ;must be drag |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
207 (let ((count (nth 2 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
208 (start-element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
209 (or t-mouse-drag-start |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
210 (t-mouse-make-event-element (nth 3 ob)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
211 (end-element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
212 (t-mouse-make-event-element current-xy-avec-time))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
213 (setq t-mouse-drag-start nil) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
214 (list event-type start-element end-element count))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
215 ((= type-switch 3) ;down or up |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
216 (let ((count (nth 2 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
217 (element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
218 (t-mouse-make-event-element current-xy-avec-time))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
219 (if (and (not t-mouse-drag-start) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
220 (symbolp (nth 1 element))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
221 ;; OUCH! GOTCHA! emacs uses setc[ad]r on these! |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
222 (setq t-mouse-drag-start (copy-sequence element)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
223 (setq t-mouse-drag-start nil)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
224 (list event-type element count))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
225 ((= type-switch 2) ;movement |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
226 (list (if (eq 'vertical-scroll-bar |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
227 (nth 1 t-mouse-drag-start)) 'scroll-bar-movement |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
228 'mouse-movement) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
229 (t-mouse-make-event-element current-xy-avec-time)))))))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
230 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
231 (defun t-mouse-process-filter (proc string) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
232 (setq t-mouse-filter-accumulator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
233 (concat t-mouse-filter-accumulator string)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
234 (let ((event (t-mouse-make-event))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
235 (while event |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
236 (if (or track-mouse |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
237 (not (eq 'mouse-movement (event-basic-type event)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
238 (setq unread-command-events |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
239 (nconc unread-command-events (list event)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
240 (if t-mouse-debug-buffer |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
241 (print unread-command-events t-mouse-debug-buffer)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
242 (setq event (t-mouse-make-event))))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
243 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
244 (defun t-mouse-mouse-position-function (pos) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
245 "Return the t-mouse-position unless running with a window system. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
246 The (secret) scrollbar interface is not implemented yet." |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
247 (setcdr pos t-mouse-current-xy) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
248 pos) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
249 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
250 ;; It should be possible to just send SIGTSTP to the inferior with |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
251 ;; stop-process. That doesn't work; mev receives the signal fine but |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
252 ;; is not really stopped: instead it returns from |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
253 ;; kill(getpid(), SIGTSTP) immediately. I don't understand what's up |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
254 ;; itz Tue Mar 24 14:27:38 PST 1998. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
255 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
256 (add-hook 'suspend-hook |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
257 (function (lambda () |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
258 (and t-mouse-process |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
259 ;(stop-process t-mouse-process) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
260 (process-send-string |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
261 t-mouse-process "push -enone -dall -Mnone\n"))))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
262 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
263 (add-hook 'suspend-resume-hook |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
264 (function (lambda () |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
265 (and t-mouse-process |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
266 ;(continue-process t-mouse-process) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
267 (process-send-string t-mouse-process "pop\n"))))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
268 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
269 ;;;###autoload |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
270 (define-minor-mode t-mouse-mode |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
271 "Toggle t-mouse mode. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
272 With prefix arg, turn t-mouse mode on iff arg is positive. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
273 |
73753
3480cc226de3
(t-mouse-process, t-mouse-mode): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
72199
diff
changeset
|
274 Turn it on to use Emacs mouse commands, and off to use t-mouse commands." |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
275 nil " Mouse" nil :global t |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
276 (if t-mouse-mode |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
277 ;; Turn it on |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
278 (unless window-system |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
279 ;; Starts getting a stream of mouse events from an asynchronous process. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
280 ;; Only works if Emacs is running on a virtual terminal without a window system. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
281 (progn |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
282 (setq mouse-position-function #'t-mouse-mouse-position-function) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
283 (let ((tty (t-mouse-tty)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
284 (process-connection-type t)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
285 (if (not (stringp tty)) |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
286 (error "Cannot find a virtual terminal")) |
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
287 (setq t-mouse-process |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
288 (start-process "t-mouse" nil |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
289 "mev" "-i" "-E" "-C" tty |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
290 (if t-mouse-swap-alt-keys |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
291 "-M-leftAlt" "-M-rightAlt") |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
292 "-e-move" |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
293 "-dall" "-d-hard" |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
294 "-f"))) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
295 (setq t-mouse-filter-accumulator "") |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
296 (set-process-filter t-mouse-process 't-mouse-process-filter) |
72199
190ee6511573
(t-mouse-mode): Use set-process-query-on-exit-flag.
Nick Roberts <nickrob@snap.net.nz>
parents:
69274
diff
changeset
|
297 (set-process-query-on-exit-flag t-mouse-process nil))) |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
298 ;; Turn it off |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
299 (setq mouse-position-function nil) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
300 (delete-process t-mouse-process) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
301 (setq t-mouse-process nil))) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
302 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
303 (provide 't-mouse) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
304 |
69194 | 305 ;; arch-tag: a63163b3-bfbe-4eb2-ab4f-201cd164b05d |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
306 ;;; t-mouse.el ends here |