Mercurial > emacs
annotate lisp/sun-curs.el @ 29903:a8aa856c2826
Check for OSF 5+.
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 23 Jun 2000 15:39:06 +0000 |
parents | 88b4e08f3ac1 |
children | 853c3674f20a |
rev | line source |
---|---|
2531
fd182baaa0a3
Name changed from sun-cursors.el to protect the innocents.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
1 ;;; sun-curs.el --- cursor definitions for Sun windows |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
3 ;; Copyright (C) 1987 Free Software Foundation, Inc. |
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
5 ;; Author: Jeff Peck <peck@sun.com> |
17970 | 6 ;; Maintainer: none |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
923
diff
changeset
|
7 ;; Keywords: hardware |
35 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
35 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; 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. | |
35 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
26 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
27 |
35 | 28 ;;; |
29 ;;; Added some more cursors and moved the hot spots | |
30 ;;; Cursor defined by 16 pairs of 16-bit numbers | |
31 ;;; | |
32 ;;; 9-dec-86 Jeff Peck, Sun Microsystems Inc. <peck@sun.com> | |
33 | |
28301
88b4e08f3ac1
Require CL at compile-time only.
Gerd Moellmann <gerd@gnu.org>
parents:
25239
diff
changeset
|
34 (eval-when-compile (require 'cl)) |
25239 | 35 (require 'sun-fns) |
923 | 36 |
18088
be8a62ae8d21
(sc::cursors): Add an eval-and-compile.
Richard M. Stallman <rms@gnu.org>
parents:
17970
diff
changeset
|
37 (eval-and-compile |
be8a62ae8d21
(sc::cursors): Add an eval-and-compile.
Richard M. Stallman <rms@gnu.org>
parents:
17970
diff
changeset
|
38 (defvar sc::cursors nil "List of known cursors")) |
35 | 39 |
40 (defmacro defcursor (name x y string) | |
41 (if (not (memq name sc::cursors)) | |
42 (setq sc::cursors (cons name sc::cursors))) | |
43 (list 'defconst name (list 'vector x y string))) | |
44 | |
45 ;;; push should be defined in common lisp, but if not use this: | |
46 ;(defmacro push (v l) | |
47 ; "The ITEM is evaluated and consed onto LIST, a list-valued atom" | |
48 ; (list 'setq l (list 'cons v l))) | |
49 | |
50 ;;; | |
51 ;;; The standard default cursor | |
52 ;;; | |
53 (defcursor sc:right-arrow 15 0 | |
54 (concat '(0 1 0 3 0 7 0 15 0 31 0 63 0 127 0 15 | |
55 0 27 0 25 0 48 0 48 0 96 0 96 0 192 0 192))) | |
56 | |
57 ;;(sc:set-cursor sc:right-arrow) | |
58 | |
59 (defcursor sc:fat-left-arrow 0 8 | |
60 (concat '(1 0 3 0 7 0 15 0 31 0 63 255 127 255 255 255 | |
61 255 255 127 255 63 255 31 0 15 0 7 0 3 0 1 0))) | |
62 | |
63 (defcursor sc:box 8 8 | |
64 (concat '(15 252 8 4 8 4 8 4 8 4 8 4 8 4 8 4 | |
65 8 132 8 4 8 4 8 4 8 4 8 4 8 4 15 252))) | |
66 | |
67 (defcursor sc:hourglass 8 8 | |
68 (concat "\177\376\100\002\040\014\032\070" | |
69 "\017\360\007\340\003\300\001\200" | |
70 "\001\200\002\100\005\040\010\020" | |
71 "\021\210\043\304\107\342\177\376")) | |
72 | |
73 (defun sc:set-cursor (icon) | |
74 "Change the Sun mouse cursor to ICON. | |
75 If ICON is nil, switch to the system default cursor, | |
76 Otherwise, ICON should be a vector or the name of a vector of [x y 32-chars]" | |
77 (interactive "XIcon Name: ") | |
78 (if (symbolp icon) (setq icon (symbol-value icon))) | |
79 (sun-change-cursor-icon icon)) | |
80 | |
81 (make-local-variable '*edit-icon*) | |
82 (make-variable-buffer-local 'icon-edit) | |
83 (setq-default icon-edit nil) | |
84 (or (assq 'icon-edit minor-mode-alist) | |
85 (push '(icon-edit " IconEdit") minor-mode-alist)) | |
86 | |
87 (defun sc:edit-cursor (icon) | |
88 "convert icon to rectangle, edit, and repack" | |
89 (interactive "XIcon Name: ") | |
90 (if (not icon) (setq icon (sc::menu-choose-cursor (selected-window) 1 1))) | |
91 (if (symbolp icon) (setq icon (symbol-value icon))) | |
92 (if (get-buffer "icon-edit") (kill-buffer "icon-edit")) | |
93 (switch-to-buffer "icon-edit") | |
94 (local-set-mouse '(text right) 'sc::menu-function) | |
95 (local-set-mouse '(text left) '(sc::pic-ins-at-mouse 32)) | |
96 (local-set-mouse '(text middle) '(sc::pic-ins-at-mouse 64)) | |
97 (local-set-mouse '(text left middle) 'sc::hotspot) | |
98 (sc::display-icon icon) | |
99 (picture-mode) | |
100 (setq icon-edit t) ; for mode line display | |
101 ) | |
102 | |
103 (defun sc::pic-ins-at-mouse (char) | |
104 "Picture insert char at mouse location" | |
105 (mouse-move-point *mouse-window* (min 15 *mouse-x*) (min 15 *mouse-y*)) | |
923 | 106 (move-to-column (1+ (min 15 (current-column))) t) |
35 | 107 (delete-char -1) |
108 (insert char) | |
109 (sc::goto-hotspot)) | |
110 | |
111 (defun sc::menu-function (window x y) | |
112 (sun-menu-evaluate window (1+ x) y sc::menu)) | |
113 | |
114 (defmenu sc::menu | |
115 ("Cursor Menu") | |
116 ("Pack & Use" sc::pack-buffer-to-cursor) | |
117 ("Pack to Icon" sc::pack-buffer-to-icon | |
118 (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) | |
119 ("New Icon" call-interactively 'sc::make-cursor) | |
120 ("Edit Icon" sc:edit-cursor | |
121 (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) | |
122 ("Set Cursor" sc:set-cursor | |
123 (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) | |
124 ("Reset Cursor" sc:set-cursor nil) | |
15256 | 125 ("Help" sc::edit-icon-help-menu) |
35 | 126 ("Quit" sc::quit-edit) |
127 ) | |
128 | |
129 (defun sc::quit-edit () | |
130 (interactive) | |
131 (bury-buffer (current-buffer)) | |
132 (switch-to-buffer (other-buffer) 'no-record)) | |
133 | |
134 (defun sc::make-cursor (symbol) | |
135 (interactive "SIcon Name: ") | |
136 (eval (list 'defcursor symbol 0 0 "")) | |
137 (sc::pack-buffer-to-icon (symbol-value symbol))) | |
138 | |
139 (defmenu sc::edit-icon-help-menu | |
140 ("Simple Icon Editor") | |
141 ("Left => CLEAR") | |
142 ("Middle => SET") | |
143 ("L & M => HOTSPOT") | |
144 ("Right => MENU")) | |
145 | |
146 (defun sc::edit-icon-help () | |
147 (message "Left=> CLEAR Middle=> SET Left+Middle=> HOTSPOT Right=> MENU")) | |
148 | |
149 (defun sc::pack-buffer-to-cursor () | |
150 (sc::pack-buffer-to-icon *edit-icon*) | |
151 (sc:set-cursor *edit-icon*)) | |
152 | |
153 (defun sc::menu-choose-cursor (window x y) | |
154 "Presents a menu of cursor names, and returns one or nil" | |
155 (let ((curs sc::cursors) | |
156 (items)) | |
157 (while curs | |
158 (push (sc::menu-item-for-cursor (car curs)) items) | |
159 (setq curs (cdr curs))) | |
160 (push (list "Choose Cursor") items) | |
161 (setq menu (menu-create items)) | |
162 (sun-menu-evaluate window x y menu))) | |
163 | |
164 (defun sc::menu-item-for-cursor (cursor) | |
165 "apply function to selected cursor" | |
166 (list (symbol-name cursor) 'quote cursor)) | |
167 | |
168 (defun sc::hotspot (window x y) | |
169 (aset *edit-icon* 0 x) | |
170 (aset *edit-icon* 1 y) | |
171 (sc::goto-hotspot)) | |
172 | |
173 (defun sc::goto-hotspot () | |
174 (goto-line (1+ (aref *edit-icon* 1))) | |
175 (move-to-column (aref *edit-icon* 0))) | |
176 | |
177 (defun sc::display-icon (icon) | |
178 (setq *edit-icon* (copy-sequence icon)) | |
179 (let ((string (aref *edit-icon* 2)) | |
180 (index 0)) | |
181 (while (< index 32) | |
182 (let ((char (aref string index)) | |
183 (bit 128)) | |
184 (while (> bit 0) | |
185 (insert (sc::char-at-bit char bit)) | |
186 (setq bit (lsh bit -1)))) | |
187 (if (eq 1 (% index 2)) (newline)) | |
188 (setq index (1+ index)))) | |
189 (sc::goto-hotspot)) | |
190 | |
191 (defun sc::char-at-bit (char bit) | |
192 (if (> (logand char bit) 0) "@" " ")) | |
193 | |
194 (defun sc::pack-buffer-to-icon (icon) | |
195 "Pack 16 x 16 field into icon string" | |
196 (goto-char (point-min)) | |
197 (aset icon 0 (aref *edit-icon* 0)) | |
198 (aset icon 1 (aref *edit-icon* 1)) | |
199 (aset icon 2 (mapconcat 'sc::pack-one-line "1234567890123456" "")) | |
200 (sc::goto-hotspot) | |
201 ) | |
202 | |
203 (defun sc::pack-one-line (dummy) | |
204 (let* (char chr1 chr2) | |
205 (setq char 0 chr1 (mapconcat 'sc::pack-one-char "12345678" "") chr1 char) | |
206 (setq char 0 chr2 (mapconcat 'sc::pack-one-char "12345678" "") chr2 char) | |
207 (forward-line 1) | |
208 (concat (char-to-string chr1) (char-to-string chr2)) | |
209 )) | |
210 | |
211 (defun sc::pack-one-char (dummy) | |
212 "pack following char into char, unless eolp" | |
213 (if (or (eolp) (char-equal (following-char) 32)) | |
214 (setq char (lsh char 1)) | |
215 (setq char (1+ (lsh char 1)))) | |
216 (if (not (eolp))(forward-char))) | |
217 | |
25232
d8024d259129
(sun-curs): Provide `sun-curs', not `sm-cursors'.
Karl Heuer <kwzh@gnu.org>
parents:
18088
diff
changeset
|
218 (provide 'sun-curs) |
584 | 219 |
2531
fd182baaa0a3
Name changed from sun-cursors.el to protect the innocents.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
220 ;;; sun-curs.el ends here |