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