Mercurial > emacs
annotate lisp/obsolete/sun-curs.el @ 55860:c1864c2911cf
(Named Features): Clarify return value and meaning of NOERROR.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 30 May 2004 14:20:58 +0000 |
parents | 695cf19ef79e |
children | 18a818a2ee7c 375f2633d815 |
rev | line source |
---|---|
39022 | 1 ;;; sun-curs.el --- cursor definitions for Sun windows |
2 | |
3 ;; Copyright (C) 1987 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Jeff Peck <peck@sun.com> | |
6 ;; Keywords: hardware | |
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 | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
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 the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
29 ;;; | |
30 ;;; Added some more cursors and moved the hot spots | |
31 ;;; Cursor defined by 16 pairs of 16-bit numbers | |
32 ;;; | |
33 ;;; 9-dec-86 Jeff Peck, Sun Microsystems Inc. <peck@sun.com> | |
34 | |
35 (eval-when-compile (require 'cl)) | |
36 (require 'sun-fns) | |
37 | |
38 (eval-and-compile | |
39 (defvar sc::cursors nil "List of known cursors")) | |
40 | |
41 (defmacro defcursor (name x y string) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
42 (if (not (memq name sc::cursors)) |
39022 | 43 (setq sc::cursors (cons name sc::cursors))) |
44 (list 'defconst name (list 'vector x y string))) | |
45 | |
46 ;;; push should be defined in common lisp, but if not use this: | |
47 ;(defmacro push (v l) | |
48 ; "The ITEM is evaluated and consed onto LIST, a list-valued atom" | |
49 ; (list 'setq l (list 'cons v l))) | |
50 | |
51 ;;; | |
52 ;;; The standard default cursor | |
53 ;;; | |
54 (defcursor sc:right-arrow 15 0 | |
55 (concat '(0 1 0 3 0 7 0 15 0 31 0 63 0 127 0 15 | |
56 0 27 0 25 0 48 0 48 0 96 0 96 0 192 0 192))) | |
57 | |
58 ;;(sc:set-cursor sc:right-arrow) | |
59 | |
60 (defcursor sc:fat-left-arrow 0 8 | |
61 (concat '(1 0 3 0 7 0 15 0 31 0 63 255 127 255 255 255 | |
62 255 255 127 255 63 255 31 0 15 0 7 0 3 0 1 0))) | |
63 | |
64 (defcursor sc:box 8 8 | |
65 (concat '(15 252 8 4 8 4 8 4 8 4 8 4 8 4 8 4 | |
66 8 132 8 4 8 4 8 4 8 4 8 4 8 4 15 252))) | |
67 | |
68 (defcursor sc:hourglass 8 8 | |
69 (concat "\177\376\100\002\040\014\032\070" | |
70 "\017\360\007\340\003\300\001\200" | |
71 "\001\200\002\100\005\040\010\020" | |
72 "\021\210\043\304\107\342\177\376")) | |
73 | |
74 (defun sc:set-cursor (icon) | |
75 "Change the Sun mouse cursor to ICON. | |
76 If ICON is nil, switch to the system default cursor, | |
77 Otherwise, ICON should be a vector or the name of a vector of [x y 32-chars]" | |
78 (interactive "XIcon Name: ") | |
79 (if (symbolp icon) (setq icon (symbol-value icon))) | |
80 (sun-change-cursor-icon icon)) | |
81 | |
82 (make-local-variable '*edit-icon*) | |
83 (make-variable-buffer-local 'icon-edit) | |
84 (setq-default icon-edit nil) | |
85 (or (assq 'icon-edit minor-mode-alist) | |
86 (push '(icon-edit " IconEdit") minor-mode-alist)) | |
87 | |
88 (defun sc:edit-cursor (icon) | |
89 "convert icon to rectangle, edit, and repack" | |
90 (interactive "XIcon Name: ") | |
91 (if (not icon) (setq icon (sc::menu-choose-cursor (selected-window) 1 1))) | |
92 (if (symbolp icon) (setq icon (symbol-value icon))) | |
93 (if (get-buffer "icon-edit") (kill-buffer "icon-edit")) | |
94 (switch-to-buffer "icon-edit") | |
95 (local-set-mouse '(text right) 'sc::menu-function) | |
96 (local-set-mouse '(text left) '(sc::pic-ins-at-mouse 32)) | |
97 (local-set-mouse '(text middle) '(sc::pic-ins-at-mouse 64)) | |
98 (local-set-mouse '(text left middle) 'sc::hotspot) | |
99 (sc::display-icon icon) | |
100 (picture-mode) | |
101 (setq icon-edit t) ; for mode line display | |
102 ) | |
103 | |
104 (defun sc::pic-ins-at-mouse (char) | |
105 "Picture insert char at mouse location" | |
106 (mouse-move-point *mouse-window* (min 15 *mouse-x*) (min 15 *mouse-y*)) | |
107 (move-to-column (1+ (min 15 (current-column))) t) | |
108 (delete-char -1) | |
109 (insert char) | |
110 (sc::goto-hotspot)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
111 |
39022 | 112 (defun sc::menu-function (window x y) |
113 (sun-menu-evaluate window (1+ x) y sc::menu)) | |
114 | |
115 (defmenu sc::menu | |
116 ("Cursor Menu") | |
117 ("Pack & Use" sc::pack-buffer-to-cursor) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
118 ("Pack to Icon" sc::pack-buffer-to-icon |
39022 | 119 (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) |
120 ("New Icon" call-interactively 'sc::make-cursor) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
121 ("Edit Icon" sc:edit-cursor |
39022 | 122 (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) |
123 ("Set Cursor" sc:set-cursor | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
124 (sc::menu-choose-cursor *menu-window* *menu-x* *menu-y*)) |
39022 | 125 ("Reset Cursor" sc:set-cursor nil) |
126 ("Help" sc::edit-icon-help-menu) | |
127 ("Quit" sc::quit-edit) | |
128 ) | |
129 | |
130 (defun sc::quit-edit () | |
131 (interactive) | |
132 (bury-buffer (current-buffer)) | |
133 (switch-to-buffer (other-buffer) 'no-record)) | |
134 | |
135 (defun sc::make-cursor (symbol) | |
136 (interactive "SIcon Name: ") | |
137 (eval (list 'defcursor symbol 0 0 "")) | |
138 (sc::pack-buffer-to-icon (symbol-value symbol))) | |
139 | |
140 (defmenu sc::edit-icon-help-menu | |
141 ("Simple Icon Editor") | |
142 ("Left => CLEAR") | |
143 ("Middle => SET") | |
144 ("L & M => HOTSPOT") | |
145 ("Right => MENU")) | |
146 | |
147 (defun sc::edit-icon-help () | |
148 (message "Left=> CLEAR Middle=> SET Left+Middle=> HOTSPOT Right=> MENU")) | |
149 | |
150 (defun sc::pack-buffer-to-cursor () | |
151 (sc::pack-buffer-to-icon *edit-icon*) | |
152 (sc:set-cursor *edit-icon*)) | |
153 | |
154 (defun sc::menu-choose-cursor (window x y) | |
155 "Presents a menu of cursor names, and returns one or nil" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
156 (let ((curs sc::cursors) |
39022 | 157 (items)) |
158 (while curs | |
159 (push (sc::menu-item-for-cursor (car curs)) items) | |
160 (setq curs (cdr curs))) | |
161 (push (list "Choose Cursor") items) | |
162 (setq menu (menu-create items)) | |
163 (sun-menu-evaluate window x y menu))) | |
164 | |
165 (defun sc::menu-item-for-cursor (cursor) | |
166 "apply function to selected cursor" | |
167 (list (symbol-name cursor) 'quote cursor)) | |
168 | |
169 (defun sc::hotspot (window x y) | |
170 (aset *edit-icon* 0 x) | |
171 (aset *edit-icon* 1 y) | |
172 (sc::goto-hotspot)) | |
173 | |
174 (defun sc::goto-hotspot () | |
175 (goto-line (1+ (aref *edit-icon* 1))) | |
176 (move-to-column (aref *edit-icon* 0))) | |
177 | |
178 (defun sc::display-icon (icon) | |
179 (setq *edit-icon* (copy-sequence icon)) | |
180 (let ((string (aref *edit-icon* 2)) | |
181 (index 0)) | |
182 (while (< index 32) | |
183 (let ((char (aref string index)) | |
184 (bit 128)) | |
185 (while (> bit 0) | |
186 (insert (sc::char-at-bit char bit)) | |
187 (setq bit (lsh bit -1)))) | |
188 (if (eq 1 (% index 2)) (newline)) | |
189 (setq index (1+ index)))) | |
190 (sc::goto-hotspot)) | |
191 | |
192 (defun sc::char-at-bit (char bit) | |
193 (if (> (logand char bit) 0) "@" " ")) | |
194 | |
195 (defun sc::pack-buffer-to-icon (icon) | |
196 "Pack 16 x 16 field into icon string" | |
197 (goto-char (point-min)) | |
198 (aset icon 0 (aref *edit-icon* 0)) | |
199 (aset icon 1 (aref *edit-icon* 1)) | |
200 (aset icon 2 (mapconcat 'sc::pack-one-line "1234567890123456" "")) | |
201 (sc::goto-hotspot) | |
202 ) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
203 |
39022 | 204 (defun sc::pack-one-line (dummy) |
205 (let* (char chr1 chr2) | |
206 (setq char 0 chr1 (mapconcat 'sc::pack-one-char "12345678" "") chr1 char) | |
207 (setq char 0 chr2 (mapconcat 'sc::pack-one-char "12345678" "") chr2 char) | |
208 (forward-line 1) | |
209 (concat (char-to-string chr1) (char-to-string chr2)) | |
210 )) | |
211 | |
212 (defun sc::pack-one-char (dummy) | |
213 "pack following char into char, unless eolp" | |
214 (if (or (eolp) (char-equal (following-char) 32)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
39022
diff
changeset
|
215 (setq char (lsh char 1)) |
39022 | 216 (setq char (1+ (lsh char 1)))) |
217 (if (not (eolp))(forward-char))) | |
218 | |
219 (provide 'sun-curs) | |
220 | |
52401 | 221 ;;; arch-tag: 7cc861e5-e2d9-4191-b211-2baaaab54e78 |
39022 | 222 ;;; sun-curs.el ends here |