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