annotate lisp/mouse.el @ 873:0abaf590e0ca

entered into RCS
author Richard M. Stallman <rms@gnu.org>
date Sun, 26 Jul 1992 19:36:03 +0000
parents 113281b361ec
children 8ab465f7a7ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; mouse.el --- window system-independent mouse support.
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
2
840
113281b361ec *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 791
diff changeset
3 ;;; Copyright (C) 1988, 1992 Free Software Foundation, Inc.
113281b361ec *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 791
diff changeset
4
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
5 ;; Maintainer: FSF
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
6 ;; Keywords: hardware
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
7
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
8 ;;; This file is part of GNU Emacs.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
11 ;;; it under the terms of the GNU General Public License as published by
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
12 ;;; the Free Software Foundation; either version 2, or (at your option)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
13 ;;; any later version.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
18 ;;; GNU General Public License for more details.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
20 ;;; You should have received a copy of the GNU General Public License
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
22 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
25 ;;; Utility functions.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
26
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
27 (defun mouse-movement-p (event)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
28 (and (consp event)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
29 (eq (car event) 'mouse-movement)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
30
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
31 (defun event-window (event) (nth 1 event))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
32 (defun event-point (event) (nth 2 event))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
33 (defun mouse-coords (event) (nth 3 event))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
34 (defun mouse-timestamp (event) (nth 4 event))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
36 ;;; Indent track-mouse like progn.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
37 (put 'track-mouse 'lisp-indent-function 0)
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
39
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
40 (defun mouse-delete-window (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
41 "Delete the window clicked on.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
42 This must be bound to a mouse click."
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
43 (interactive "K")
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
44 (delete-window (event-window click)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
45
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
46 (defun mouse-delete-other-windows (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
47 "Select Emacs window clicked on, then kill all other Emacs windows.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
48 This must be bound to a mouse click."
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
49 (interactive "K")
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
50 (select-window (event-window click))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (delete-other-windows))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
53 (defun mouse-split-window-vertically (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
54 "Select Emacs window mouse is on, then split it vertically in half.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
55 The window is split at the line clicked on.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
56 This command must be bound to a mouse click."
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
57 (interactive "K")
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
58 (select-window (event-window click))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
59 (split-window-vertically (1+ (cdr (mouse-coords click)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
61 (defun mouse-set-point (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
62 "Move point to the position clicked on with the mouse.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
63 This must be bound to a mouse click."
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
64 (interactive "K")
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
65 (select-window (event-window click))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
66 (goto-char (event-point click)))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
68 (defun mouse-set-mark (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
69 "Set mark at the position clicked on with the mouse.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
70 Display cursor at that position for a second.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
71 This must be bound to a mouse click."
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
72 (interactive "K")
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (let ((point-save (point)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (unwind-protect
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
75 (progn (mouse-set-point click)
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (push-mark nil t)
191
b6358b876c71 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 93
diff changeset
77 (sit-for 1))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (goto-char point-save))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
80 (defun mouse-kill (click)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
81 "Kill the region between point and the mouse click.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
82 The text is saved in the kill ring, as with \\[kill-region]."
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
83 (interactive "K")
758
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
84 (let ((click-posn (event-point click)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
85 (kill-region (min (point) click-posn)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
86 (max (point) click-posn))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
88 (defun mouse-yank-at-click (click arg)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
89 "Insert the last stretch of killed text at the position clicked on.
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
90 Prefix arguments are interpreted as with \\[yank]."
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
91 (interactive "K\nP")
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
92 (mouse-set-point click)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
93 (yank arg))
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
94
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
95 (defun mouse-kill-ring-save (click)
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
96 "Copy the region between point and the mouse click in the kill ring.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
97 This does not delete the region; it acts like \\[kill-ring-save]."
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
98 (interactive "K")
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
99 (mouse-set-mark click)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
100 (call-interactively 'kill-ring-save))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; Commands for the scroll bar.
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (defun mouse-scroll-down (nlines)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (interactive "@p")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (scroll-down nlines))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (defun mouse-scroll-up (nlines)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (interactive "@p")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (scroll-up nlines))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (defun mouse-scroll-down-full ()
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (interactive "@")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (scroll-down nil))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (defun mouse-scroll-up-full ()
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (interactive "@")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (scroll-up nil))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (defun mouse-scroll-move-cursor (nlines)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (interactive "@p")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (move-to-window-line nlines))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (defun mouse-scroll-absolute (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (let* ((pos (car event))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (position (car pos))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (length (car (cdr pos))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (if (<= length 0) (setq length 1))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (let* ((scale-factor (max 1 (/ length (/ 8000000 (buffer-size)))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (newpos (* (/ (* (/ (buffer-size) scale-factor)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 position)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 length)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 scale-factor)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (goto-char newpos)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (recenter '(4)))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (defun mouse-scroll-left (ncolumns)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (interactive "@p")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (scroll-left ncolumns))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (defun mouse-scroll-right (ncolumns)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (interactive "@p")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (scroll-right ncolumns))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (defun mouse-scroll-left-full ()
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (interactive "@")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (scroll-left nil))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (defun mouse-scroll-right-full ()
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (interactive "@")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (scroll-right nil))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (defun mouse-scroll-move-cursor-horizontally (ncolumns)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (interactive "@p")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (move-to-column ncolumns))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (defun mouse-scroll-absolute-horizontally (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (let* ((pos (car event))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (position (car pos))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (length (car (cdr pos))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (set-window-hscroll (selected-window) 33)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 ;; Set up these commands, including the prefix keys for the scroll bar.
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
169 ;;; (fset 'mouse-vertical-scroll-bar-prefix (make-sparse-keymap))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
170 ;;; (define-key global-mouse-map mouse-vertical-scroll-bar-prefix
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
171 ;;; 'mouse-vertical-scroll-bar-prefix)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
172 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
173 ;;; (defun mouse-scroll-motion (event)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
174 ;;; (interactive "e")
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
175 ;;; (let ((pos (car (car event)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
176 ;;; (length (car (cdr (car event)))))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
177 ;;; (message "[%d %d]" pos length)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
178 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
179 ;;; (let ((map (function mouse-vertical-scroll-bar-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
180 ;;; (define-key map mouse-button-right 'mouse-scroll-down)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
181 ;;; (define-key map mouse-button-left 'mouse-scroll-up)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
182 ;;; (define-key map mouse-button-middle 'mouse-scroll-absolute)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
183 ;;; (define-key map mouse-motion 'x-horizontal-line))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
184 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
185 ;;; ;(fset 'mouse-vertical-slider-prefix (make-sparse-keymap))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
186 ;;; ;(define-key global-mouse-map mouse-vertical-slider-prefix
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
187 ;;; ; 'mouse-vertical-slider-prefix)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
188 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
189 ;;; ;(let ((map (function mouse-vertical-slider-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
190 ;;; ; (define-key map mouse-button-right 'mouse-scroll-move-cursor)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
191 ;;; ; (define-key map mouse-button-left 'mouse-scroll-move-cursor)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
192 ;;; ; (define-key map mouse-button-middle 'mouse-scroll-move-cursor))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
193 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
194 ;;; (fset 'mouse-vertical-thumbup-prefix (make-sparse-keymap))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
195 ;;; (define-key global-mouse-map mouse-vertical-thumbup-prefix
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
196 ;;; 'mouse-vertical-thumbup-prefix)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
197 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
198 ;;; (let ((map (function mouse-vertical-thumbup-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
199 ;;; (define-key map mouse-button-right 'mouse-scroll-down-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
200 ;;; (define-key map mouse-button-left 'mouse-scroll-down-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
201 ;;; (define-key map mouse-button-middle 'mouse-scroll-down-full))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
202 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
203 ;;; (fset 'mouse-vertical-thumbdown-prefix (make-sparse-keymap))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
204 ;;; (define-key global-mouse-map mouse-vertical-thumbdown-prefix
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
205 ;;; 'mouse-vertical-thumbdown-prefix)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
206 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
207 ;;; (let ((map (function mouse-vertical-thumbdown-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
208 ;;; (define-key map mouse-button-right 'mouse-scroll-up-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
209 ;;; (define-key map mouse-button-left 'mouse-scroll-up-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
210 ;;; (define-key map mouse-button-middle 'mouse-scroll-up-full))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
211 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
212 ;;; ;; Horizontal bar
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
213 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
214 ;;; (fset 'mouse-horizontal-scroll-bar-prefix (make-sparse-keymap))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
215 ;;; (define-key global-mouse-map mouse-horizontal-scroll-bar-prefix
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
216 ;;; 'mouse-horizontal-scroll-bar-prefix)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
217 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
218 ;;; (let ((map (function mouse-horizontal-scroll-bar-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
219 ;;; (define-key map mouse-button-right 'mouse-scroll-right)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
220 ;;; (define-key map mouse-button-left 'mouse-scroll-left)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
221 ;;; (define-key map mouse-button-middle 'mouse-scroll-absolute-horizontally))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
222 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
223 ;;; (fset 'mouse-horizontal-thumbleft-prefix (make-sparse-keymap))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
224 ;;; (define-key global-mouse-map mouse-horizontal-thumbleft-prefix
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
225 ;;; 'mouse-horizontal-thumbleft-prefix)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
226 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
227 ;;; (let ((map (function mouse-horizontal-thumbleft-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
228 ;;; (define-key map mouse-button-right 'mouse-scroll-left-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
229 ;;; (define-key map mouse-button-left 'mouse-scroll-left-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
230 ;;; (define-key map mouse-button-middle 'mouse-scroll-left-full))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
231 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
232 ;;; (fset 'mouse-horizontal-thumbright-prefix (make-sparse-keymap))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
233 ;;; (define-key global-mouse-map mouse-horizontal-thumbright-prefix
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
234 ;;; 'mouse-horizontal-thumbright-prefix)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
235 ;;;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
236 ;;; (let ((map (function mouse-horizontal-thumbright-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
237 ;;; (define-key map mouse-button-right 'mouse-scroll-right-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
238 ;;; (define-key map mouse-button-left 'mouse-scroll-right-full)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
239 ;;; (define-key map mouse-button-middle 'mouse-scroll-right-full))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
303
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
242 ;;;;
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
243 ;;;; Here are experimental things being tested. Mouse events
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
244 ;;;; are of the form:
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
245 ;;;; ((x y) window screen-part key-sequence timestamp)
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 ;;
303
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
247 ;;;;
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
248 ;;;; Dynamically track mouse coordinates
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
249 ;;;;
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 ;;
303
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
251 ;;(defun track-mouse (event)
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
252 ;; "Track the coordinates, absolute and relative, of the mouse."
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
253 ;; (interactive "@e")
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
254 ;; (while mouse-grabbed
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
255 ;; (let* ((pos (read-mouse-position (selected-screen)))
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
256 ;; (abs-x (car pos))
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
257 ;; (abs-y (cdr pos))
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
258 ;; (relative-coordinate (coordinates-in-window-p
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
259 ;; (list (car pos) (cdr pos))
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
260 ;; (selected-window))))
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
261 ;; (if (consp relative-coordinate)
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
262 ;; (message "mouse: [%d %d], (%d %d)" abs-x abs-y
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
263 ;; (car relative-coordinate)
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
264 ;; (car (cdr relative-coordinate)))
f7330c156716 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
265 ;; (message "mouse: [%d %d]" abs-x abs-y)))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 ;;
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 ;; Dynamically put a box around the line indicated by point
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 ;;
758
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
270 ;;
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
271 ;;(require 'backquote)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
272 ;;
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
273 ;;(defun mouse-select-buffer-line (event)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
274 ;; (interactive "@e")
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
275 ;; (let ((relative-coordinate
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
276 ;; (coordinates-in-window-p (car event) (selected-window)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
277 ;; (abs-y (car (cdr (car event)))))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
278 ;; (if (consp relative-coordinate)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
279 ;; (progn
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
280 ;; (save-excursion
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
281 ;; (move-to-window-line (car (cdr relative-coordinate)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
282 ;; (x-draw-rectangle
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
283 ;; (selected-screen)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
284 ;; abs-y 0
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
285 ;; (save-excursion
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
286 ;; (move-to-window-line (car (cdr relative-coordinate)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
287 ;; (end-of-line)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
288 ;; (push-mark nil t)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
289 ;; (beginning-of-line)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
290 ;; (- (region-end) (region-beginning))) 1))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
291 ;; (sit-for 1)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
292 ;; (x-erase-rectangle (selected-screen))))))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
293 ;;
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
294 ;;(defvar last-line-drawn nil)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
295 ;;(defvar begin-delim "[^ \t]")
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
296 ;;(defvar end-delim "[^ \t]")
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
297 ;;
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
298 ;;(defun mouse-boxing (event)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
299 ;; (interactive "@e")
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
300 ;; (save-excursion
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
301 ;; (let ((screen (selected-screen)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
302 ;; (while (= (x-mouse-events) 0)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
303 ;; (let* ((pos (read-mouse-position screen))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
304 ;; (abs-x (car pos))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
305 ;; (abs-y (cdr pos))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
306 ;; (relative-coordinate
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
307 ;; (coordinates-in-window-p (` ((, abs-x) (, abs-y)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
308 ;; (selected-window)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
309 ;; (begin-reg nil)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
310 ;; (end-reg nil)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
311 ;; (end-column nil)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
312 ;; (begin-column nil))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
313 ;; (if (and (consp relative-coordinate)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
314 ;; (or (not last-line-drawn)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
315 ;; (not (= last-line-drawn abs-y))))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
316 ;; (progn
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
317 ;; (move-to-window-line (car (cdr relative-coordinate)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
318 ;; (if (= (following-char) 10)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
319 ;; ()
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
320 ;; (progn
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
321 ;; (setq begin-reg (1- (re-search-forward end-delim)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
322 ;; (setq begin-column (1- (current-column)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
323 ;; (end-of-line)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
324 ;; (setq end-reg (1+ (re-search-backward begin-delim)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
325 ;; (setq end-column (1+ (current-column)))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
326 ;; (message "%s" (buffer-substring begin-reg end-reg))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
327 ;; (x-draw-rectangle screen
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
328 ;; (setq last-line-drawn abs-y)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
329 ;; begin-column
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
330 ;; (- end-column begin-column) 1))))))))))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
331 ;;
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
332 ;;(defun mouse-erase-box ()
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
333 ;; (interactive)
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
334 ;; (if last-line-drawn
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
335 ;; (progn
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
336 ;; (x-erase-rectangle (selected-screen))
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 705
diff changeset
337 ;; (setq last-line-drawn nil))))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
339 ;;; (defun test-x-rectangle ()
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
340 ;;; (use-local-mouse-map (setq rectangle-test-map (make-sparse-keymap)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
341 ;;; (define-key rectangle-test-map mouse-motion-button-left 'mouse-boxing)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
342 ;;; (define-key rectangle-test-map mouse-button-left-up 'mouse-erase-box))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 ;;
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 ;; Here is how to do double clicking in lisp. About to change.
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 ;;
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (defvar double-start nil)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (defconst double-click-interval 300
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 "Max ticks between clicks")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (defun double-down (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (if double-start
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (let ((interval (- (nth 4 event) double-start)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (if (< interval double-click-interval)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (progn
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (backward-up-list 1)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 ;; (message "Interval %d" interval)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (sleep-for 1)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (setq double-start nil))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (setq double-start (nth 4 event))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (defun double-up (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (and double-start
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (> (- (nth 4 event ) double-start) double-click-interval)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (setq double-start nil)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
370 ;;; (defun x-test-doubleclick ()
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
371 ;;; (use-local-mouse-map (setq doubleclick-test-map (make-sparse-keymap)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
372 ;;; (define-key doubleclick-test-map mouse-button-left 'double-down)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
373 ;;; (define-key doubleclick-test-map mouse-button-left-up 'double-up))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 ;;
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 ;; This scrolls while button is depressed. Use preferable in scrollbar.
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ;;
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (defvar scrolled-lines 0)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (defconst scroll-speed 1)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (defun incr-scroll-down (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (setq scrolled-lines 0)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (incremental-scroll scroll-speed))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (defun incr-scroll-up (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (setq scrolled-lines 0)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (incremental-scroll (- scroll-speed)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (defun incremental-scroll (n)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (while (= (x-mouse-events) 0)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (setq scrolled-lines (1+ (* scroll-speed scrolled-lines)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (scroll-down n)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (sit-for 300 t)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (defun incr-scroll-stop (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (message "Scrolled %d lines" scrolled-lines)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (setq scrolled-lines 0)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (sleep-for 1))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
404 ;;; (defun x-testing-scroll ()
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
405 ;;; (let ((scrolling-map (function mouse-vertical-scroll-bar-prefix)))
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
406 ;;; (define-key scrolling-map mouse-button-left 'incr-scroll-down)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
407 ;;; (define-key scrolling-map mouse-button-right 'incr-scroll-up)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
408 ;;; (define-key scrolling-map mouse-button-left-up 'incr-scroll-stop)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
409 ;;; (define-key scrolling-map mouse-button-right-up 'incr-scroll-stop)))
66
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ;;
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ;; Some playthings suitable for picture mode? They need work.
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 ;;
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (defun mouse-kill-rectangle (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 "Kill the rectangle between point and the mouse cursor."
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (let ((point-save (point)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (save-excursion
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (mouse-set-point event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (push-mark nil t)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (if (> point-save (point))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (kill-rectangle (point) point-save)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (kill-rectangle point-save (point))))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (defun mouse-open-rectangle (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 "Kill the rectangle between point and the mouse cursor."
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (let ((point-save (point)))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (save-excursion
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (mouse-set-point event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (push-mark nil t)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (if (> point-save (point))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (open-rectangle (point) point-save)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (open-rectangle point-save (point))))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 ;; Must be a better way to do this.
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (defun mouse-multiple-insert (n char)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (while (> n 0)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (insert char)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (setq n (1- n))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;; What this could do is not finalize until button was released.
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (defun mouse-move-text (event)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 "Move text from point to cursor position, inserting spaces."
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (interactive "@e")
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (let* ((relative-coordinate
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (coordinates-in-window-p (car event) (selected-window))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (if (consp relative-coordinate)
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (cond ((> (current-column) (car relative-coordinate))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (delete-char
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (- (car relative-coordinate) (current-column))))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 ((< (current-column) (car relative-coordinate))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (mouse-multiple-insert
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (- (car relative-coordinate) (current-column)) " "))
5793fbcb9ac1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 ((= (current-column) (car relative-coordinate)) (ding))))))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
459
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
460
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
461 ;;; Bindings for mouse commands.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
462
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
463 (global-set-key [mouse-1] 'mouse-set-point)
705
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
464 (global-set-key [mouse-2] 'mouse-yank-at-click)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
465 (global-set-key [mouse-3] 'mouse-kill-ring-save)
c7d478752305 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 659
diff changeset
466
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 303
diff changeset
467 (global-set-key [S-mouse-1] 'mouse-set-mark)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
468
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
469 (provide 'mouse)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
470
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
471 ;;; mouse.el ends here