Mercurial > emacs
annotate lisp/t-mouse.el @ 71846:3c725926a775
*** empty log message ***
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Wed, 12 Jul 2006 13:22:36 +0000 |
parents | ecf5c4f0cb3a |
children | 190ee6511573 |
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 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
7 ;; Copyright (C) 1994,1995 Alessandro Rubini <rubini@linux.it> |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
8 ;; parts are by Ian T Zimmermann <itz@rahul.net>, 1995,1998 |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
9 ;; Copyright (C) 2006 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
10 ;; Free Software Foundation, Inc. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
11 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
12 ;; 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
|
13 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
14 ;; 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
|
15 ;; 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
|
16 ;; 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
|
17 ;; any later version. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
18 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 ;; 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
|
23 |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
24 ;; 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
|
25 ;; 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
|
26 ;; 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
|
27 ;; Boston, MA 02110-1301, USA. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
28 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
29 ;;; Commentary: |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
30 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
31 ;; 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
|
32 ;; 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
|
33 ;; 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
|
34 ;; 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
|
35 ;; Linux-dependent. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
36 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
37 ;; 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
|
38 ;; now position sensitive. |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
39 |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
40 (defvar t-mouse-process nil |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
41 "Embeds the process which passes mouse events to emacs. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
42 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
|
43 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
44 (defvar t-mouse-filter-accumulator "" |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
45 "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
|
46 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
47 (defvar t-mouse-debug-buffer nil |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
48 "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
|
49 See `t-mouse-start-debug'.") |
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-current-xy '(0 . 0) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
52 "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
|
53 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
54 (defvar t-mouse-drag-start nil |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
55 "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
|
56 \(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
|
57 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
|
58 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
|
59 configuration may have changed.") |
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-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
|
62 (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
|
63 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
64 (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
|
65 "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
|
66 \(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
|
67 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
|
68 |
69274
ecf5c4f0cb3a
(t-mouse-drag-start, t-mouse-swap-alt-keys): Doc fix; escape
John Paul Wallington <jpw@pobox.com>
parents:
69194
diff
changeset
|
69 (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
|
70 "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
|
71 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
72 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
73 ;;; Code: |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
74 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
75 ;; 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
|
76 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
77 (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
|
78 "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
|
79 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
|
80 (with-temp-buffer |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
81 (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
|
82 (goto-char (point-min)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
83 (if (or |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
84 ;; 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
|
85 (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
|
86 (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
|
87 (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
|
88 (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
|
89 (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
|
90 (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
|
91 (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
|
92 (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
|
93 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
94 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
95 ;; 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
|
96 ;; (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
|
97 ;; 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
|
98 ;; 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
|
99 ;; the modeline, for instance. |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
100 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
101 ;; 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
|
102 ;; 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
|
103 ;; 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
|
104 ;; '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
|
105 ;; '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
|
106 ;; 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
|
107 ;; 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
|
108 ;; 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
|
109 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
110 ;; 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
|
111 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
112 ;; WOW! a fully general powerset generator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
113 ;; (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
|
114 (defun t-mouse-powerset (l) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
115 (if (null l) '(nil) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
116 (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
|
117 (first (nth 0 l))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
118 (append |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
119 (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
|
120 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
121 ;; 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
|
122 (defun t-mouse-cartesian (l1 l2) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
123 (if (null l1) l2 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
124 (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
|
125 (t-mouse-cartesian (cdr l1) l2)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
126 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
127 (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
|
128 (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
|
129 '((mouse-1) (mouse-2) (mouse-3)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
130 (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
|
131 (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
|
132 (while all-sets |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
133 (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
|
134 (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
|
135 (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
|
136 (setq all-sets (cdr all-sets)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
137 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
138 (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
|
139 (let* ((x-dot-y (nth 0 x-dot-y-avec-time)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
140 (x (car x-dot-y)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
141 (y (cdr x-dot-y)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
142 (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
|
143 (ltrb (window-edges w)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
144 (left (nth 0 ltrb)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
145 (top (nth 1 ltrb))) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
146 (if w (posn-at-x-y (- x left) (- y top) w t) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
147 (append (list nil 'menu-bar) (nthcdr 2 (posn-at-x-y x y w t)))))) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
148 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
149 ;;; 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
|
150 (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
|
151 "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
|
152 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
|
153 (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
|
154 (progn |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
155 ;; 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
|
156 (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
|
157 t-mouse-filter-accumulator) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
158 (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
|
159 (substring |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
160 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
|
161 (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
|
162 (error nil)))) |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
163 ;; 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
|
164 (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
|
165 nil |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
166 (setq ob (car ob-pos)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
167 (setq t-mouse-filter-accumulator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
168 (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
|
169 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
170 ;;now the real work |
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 (let ((event-type (nth 0 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
173 (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
|
174 (type-switch (length ob))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
175 (if t-mouse-fix-21 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
176 (let |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
177 ;;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
|
178 ((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
|
179 end-of-root-event-name |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
180 new-event-name-string) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
181 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
182 (if (string-match "-\\(21\\|\\12\\)$" event-name-string) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
183 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
184 ;;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
|
185 (progn |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
186 (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
|
187 (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
|
188 (concat (substring |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
189 event-name-string 0 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
190 end-of-root-event-name) "-3")) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
191 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
192 ;;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
|
193 ;;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
|
194 (setq event-type |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
195 (intern new-event-name-string)))))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
196 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
197 ;;store current position for mouse-position |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
198 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
199 (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
|
200 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
201 ;;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
|
202 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
203 (cond |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
204 ((= type-switch 4) ;must be drag |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
205 (let ((count (nth 2 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
206 (start-element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
207 (or t-mouse-drag-start |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
208 (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
|
209 (end-element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
210 (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
|
211 (setq t-mouse-drag-start nil) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
212 (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
|
213 ((= type-switch 3) ;down or up |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
214 (let ((count (nth 2 ob)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
215 (element |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
216 (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
|
217 (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
|
218 (symbolp (nth 1 element))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
219 ;; 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
|
220 (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
|
221 (setq t-mouse-drag-start nil)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
222 (list event-type element count))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
223 ((= type-switch 2) ;movement |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
224 (list (if (eq 'vertical-scroll-bar |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
225 (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
|
226 'mouse-movement) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
227 (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
|
228 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
229 (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
|
230 (setq t-mouse-filter-accumulator |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
231 (concat t-mouse-filter-accumulator string)) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
232 (let ((event (t-mouse-make-event))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
233 (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
|
234 (if (or track-mouse |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
235 (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
|
236 (setq unread-command-events |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
237 (nconc unread-command-events (list event)))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
238 (if t-mouse-debug-buffer |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
239 (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
|
240 (setq event (t-mouse-make-event))))) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
241 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
242 (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
|
243 "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
|
244 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
|
245 (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
|
246 pos) |
69185
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
247 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
248 ;; 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
|
249 ;; 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
|
250 ;; 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
|
251 ;; 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
|
252 ;; 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
|
253 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
254 (add-hook 'suspend-hook |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
255 (function (lambda () |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
256 (and t-mouse-process |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
257 ;(stop-process t-mouse-process) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
258 (process-send-string |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
259 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
|
260 |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
261 (add-hook 'suspend-resume-hook |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
262 (function (lambda () |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
263 (and t-mouse-process |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
264 ;(continue-process t-mouse-process) |
ee54b3a792ff
This version does *not* work with Emacs 22.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff
changeset
|
265 (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
|
266 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
267 ;;;###autoload |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
268 (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
|
269 "Toggle t-mouse mode. |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
270 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
|
271 |
69189
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
272 Turn it on to use emacs mouse commands, and off to use t-mouse commands." |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
273 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
|
274 (if t-mouse-mode |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
275 ;; Turn it on |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
276 (unless window-system |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
277 ;; 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
|
278 ;; 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
|
279 (progn |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
280 (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
|
281 (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
|
282 (process-connection-type t)) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
283 (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
|
284 (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
|
285 (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
|
286 (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
|
287 "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
|
288 (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
|
289 "-M-leftAlt" "-M-rightAlt") |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
290 "-e-move" |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
291 "-dall" "-d-hard" |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
292 "-f"))) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
293 (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
|
294 (set-process-filter t-mouse-process 't-mouse-process-filter) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
295 ; use commented line instead for emacs 21.4 onwards |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
296 (process-kill-without-query t-mouse-process))) |
ec62f416bd30
(t-mouse-tty): Use with-temp-buffer. Add more
Nick Roberts <nickrob@snap.net.nz>
parents:
69185
diff
changeset
|
297 ; (set-process-query-on-exit-flag t-mouse-process nil))) |
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 |