Mercurial > emacs
annotate lisp/t-mouse.el @ 80241:158cdf102893
*** empty log message ***
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Thu, 28 Feb 2008 22:56:02 +0000 |
parents | 73661ddc7ac7 |
children | 107ccd98fa12 |
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 |
79721 | 7 ;; Copyright (C) 1994, 1995, 1998, 2006, 2007, 2008 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 |
78236
9355f9b7bbff
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77756
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
69189
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) |
76925
f6250d52a57e
(t-mouse-make-event-element): Don't use the left edge
Nick Roberts <nickrob@snap.net.nz>
parents:
76590
diff
changeset
|
147 (nthcdr 2 (posn-at-x-y x y)))))) |
76590
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)) |
77398
8172a170a5d7
(t-mouse-make-event): Pass on mev's more informative
Nick Roberts <nickrob@snap.net.nz>
parents:
76925
diff
changeset
|
169 (if (string-match "mev:$" (prin1-to-string ob)) |
8172a170a5d7
(t-mouse-make-event): Pass on mev's more informative
Nick Roberts <nickrob@snap.net.nz>
parents:
76925
diff
changeset
|
170 (error "Can't open mouse connection")) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
171 (setq t-mouse-filter-accumulator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
172 (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
|
173 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
174 ;;now the real work |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
175 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
176 (let ((event-type (nth 0 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
177 (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
|
178 (type-switch (length ob))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
179 (if t-mouse-fix-21 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
180 (let |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
181 ;;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
|
182 ((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
|
183 end-of-root-event-name |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
184 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
|
185 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
186 (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
|
187 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
188 ;;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
|
189 (progn |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
190 (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
|
191 (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
|
192 (concat (substring |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
193 event-name-string 0 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
194 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
|
195 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
196 ;;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
|
197 ;;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
|
198 (setq event-type |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
199 (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
|
200 |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
201 ;;store current position for mouse-position |
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 (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
|
204 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
205 ;;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
|
206 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
207 (cond |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
208 ((= type-switch 4) ;must be drag |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
209 (let ((count (nth 2 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
210 (start-element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
211 (or t-mouse-drag-start |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
212 (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
|
213 (end-element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
214 (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
|
215 (setq t-mouse-drag-start nil) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
216 (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
|
217 ((= type-switch 3) ;down or up |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
218 (let ((count (nth 2 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
219 (element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
220 (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
|
221 (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
|
222 (symbolp (nth 1 element))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
223 ;; 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
|
224 (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
|
225 (setq t-mouse-drag-start nil)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
226 (list event-type element count))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
227 ((= type-switch 2) ;movement |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
228 (list (if (eq 'vertical-scroll-bar |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
229 (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
|
230 'mouse-movement) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
231 (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
|
232 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
233 (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
|
234 (setq t-mouse-filter-accumulator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
235 (concat t-mouse-filter-accumulator string)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
236 (let ((event (t-mouse-make-event))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
237 (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
|
238 (if (or track-mouse |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
239 (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
|
240 (setq unread-command-events |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
241 (nconc unread-command-events (list event)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
242 (if t-mouse-debug-buffer |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
243 (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
|
244 (setq event (t-mouse-make-event))))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
245 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
246 (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
|
247 "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
|
248 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
|
249 (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
|
250 pos) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
251 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
252 ;; 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
|
253 ;; 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
|
254 ;; 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
|
255 ;; 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
|
256 ;; 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
|
257 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
258 (add-hook 'suspend-hook |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
259 (function (lambda () |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
260 (and t-mouse-process |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
261 ;(stop-process t-mouse-process) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
262 (process-send-string |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
263 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
|
264 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
265 (add-hook 'suspend-resume-hook |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
266 (function (lambda () |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
267 (and t-mouse-process |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
268 ;(continue-process t-mouse-process) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
269 (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
|
270 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
271 ;;;###autoload |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
272 (define-minor-mode t-mouse-mode |
77756
7d0f49cdc5da
(t-mouse-mode): Improve docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
77398
diff
changeset
|
273 "Toggle t-mouse mode to use the mouse in Linux consoles. |
78492
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
274 With prefix arg, turn t-mouse mode on if arg is positive, otherwise turn it |
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
275 off. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
276 |
77756
7d0f49cdc5da
(t-mouse-mode): Improve docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
77398
diff
changeset
|
277 This allows the use of the mouse when operating on a Linux console, in the |
7d0f49cdc5da
(t-mouse-mode): Improve docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
77398
diff
changeset
|
278 same way as you can use the mouse under X11. |
7d0f49cdc5da
(t-mouse-mode): Improve docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
77398
diff
changeset
|
279 It requires the `mev' program, part of the `gpm' utilities." |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
280 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
|
281 (if t-mouse-mode |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
282 ;; Turn it on |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
283 (unless window-system |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
284 ;; 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
|
285 ;; 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
|
286 (progn |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
287 (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
|
288 (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
|
289 (process-connection-type t)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
290 (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
|
291 (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
|
292 (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
|
293 (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
|
294 "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
|
295 (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
|
296 "-M-leftAlt" "-M-rightAlt") |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
297 "-e-move" |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
298 "-dall" "-d-hard" |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
299 "-f"))) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
300 (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
|
301 (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
|
302 (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
|
303 ;; Turn it off |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
304 (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
|
305 (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
|
306 (setq t-mouse-process nil))) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
307 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
308 (provide 't-mouse) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
309 |
69194 | 310 ;; 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
|
311 ;;; t-mouse.el ends here |