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