annotate lisp/mouse.el @ 758:f8688580137c

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