annotate lisp/x-mouse.el @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children 576fb035e263
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; x-mouse.el --- Mouse support for X window system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1992-4, 1997 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: mouse, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Synched up with: Not synched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs (when X support is compiled in).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;;(define-key global-map 'button2 'x-set-point-and-insert-selection)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; This is reserved for use by Hyperbole.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;;(define-key global-map '(shift button2) 'x-mouse-kill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 (define-key global-map '(control button2) 'x-set-point-and-move-selection)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 (define-obsolete-function-alias 'x-insert-selection 'insert-selection)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 (defun x-mouse-kill (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 "Kill the text between the point and mouse and copy it to the clipboard and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 to the cut buffer"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 (interactive "@e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (let ((old-point (point)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (mouse-set-point event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 (let ((s (buffer-substring old-point (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 (own-clipboard s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (x-store-cutbuffer s))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (kill-region old-point (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (make-obsolete 'x-set-point-and-insert-selection 'mouse-yank)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 (defun x-set-point-and-insert-selection (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 "Set point where clicked and insert the primary selection or the cut buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (let ((mouse-yank-at-point nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (mouse-yank event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (defun x-set-point-and-move-selection (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 "Set point where clicked and move the selected text to that location."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 ;; Don't try to move the selection if x-kill-primary-selection if going
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 ;; to fail; just let the appropriate error message get issued. (We need
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 ;; to insert the selection and set point first, or the selection may
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 ;; get inserted at the wrong place.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (and (selection-owner-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 primary-selection-extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 (insert-selection t event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (kill-primary-selection))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (defun mouse-track-and-copy-to-cutbuffer (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 "Make a selection like `mouse-track', but also copy it to the cutbuffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (mouse-track event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (cond
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 ((null primary-selection-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 ((consp primary-selection-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 (set-buffer (extent-object (car primary-selection-extent)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (x-store-cutbuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (mapconcat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #'identity
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (extract-rectangle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (extent-start-position (car primary-selection-extent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (extent-end-position (car (reverse primary-selection-extent))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 "\n"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (set-buffer (extent-object primary-selection-extent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 (x-store-cutbuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (buffer-substring (extent-start-position primary-selection-extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (extent-end-position primary-selection-extent)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (defvar x-pointers-initialized nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (defun x-init-pointer-shape (device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 "Initialize the mouse-pointers of DEVICE from the X resource database."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 (if x-pointers-initialized ; only do it when the first device is created
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (set-glyph-image text-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
103 (or (x-get-resource "textPointer" "Cursor" 'string device nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 "xterm"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (set-glyph-image selection-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
106 (or (x-get-resource "selectionPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
107 nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 "top_left_arrow"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 (set-glyph-image nontext-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
110 (or (x-get-resource "spacePointer" "Cursor" 'string device nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 "xterm")) ; was "crosshair"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (set-glyph-image modeline-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
113 (or (x-get-resource "modeLinePointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
114 nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 ;; "fleur"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 "sb_v_double_arrow"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 (set-glyph-image gc-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
118 (or (x-get-resource "gcPointer" "Cursor" 'string device nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 "watch"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 (when (featurep 'scrollbar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (set-glyph-image
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 scrollbar-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
123 (or (x-get-resource "scrollbarPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
124 nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 "top_left_arrow")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (set-glyph-image busy-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
127 (or (x-get-resource "busyPointer" "Cursor" 'string device nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 "watch"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (set-glyph-image toolbar-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
130 (or (x-get-resource "toolBarPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
131 nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 "left_ptr"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (set-glyph-image divider-pointer-glyph
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
134 (or (x-get-resource "dividerPointer" "Cursor" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
135 nil 'warn)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 "sb_h_double_arrow"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 (let ((fg
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
138 (x-get-resource "pointerColor" "Foreground" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
139 nil 'warn)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (and fg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (set-face-foreground 'pointer fg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (let ((bg
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
143 (x-get-resource "pointerBackground" "Background" 'string device
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
144 nil 'warn)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 (and bg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (set-face-background 'pointer bg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (setq x-pointers-initialized t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 ;;; x-mouse.el ends here