Mercurial > emacs
annotate lisp/strokes.el @ 100914:de45b6b07aa7
(mail-bury): Treat pmail-mode like rmail-mode.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 05 Jan 2009 15:53:05 +0000 |
parents | a9dc0e7c3f2b |
children | 2e0765155e47 |
rev | line source |
---|---|
19347 | 1 ;;; strokes.el --- control Emacs through mouse strokes |
19345 | 2 |
74442 | 3 ;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, |
100908 | 4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
19345 | 5 |
27975
ede0e764fc12
Change maintainer's mail address.
Gerd Moellmann <gerd@gnu.org>
parents:
19897
diff
changeset
|
6 ;; Author: David Bakhash <cadet@alum.mit.edu> |
45103 | 7 ;; Maintainer: FSF |
19345 | 8 ;; Keywords: lisp, mouse, extensions |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
19345 | 13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
19345 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
19345 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; This is the strokes package. It is intended to allow the user to | |
28 ;; control Emacs by means of mouse strokes. Once strokes is loaded, you | |
29 ;; can always get help be invoking `strokes-help': | |
30 | |
31 ;; > M-x strokes-help | |
32 | |
33 ;; and you can learn how to use the package. A mouse stroke, for now, | |
46116 | 34 ;; can be defined as holding the shift key and the middle button, for |
35 ;; instance, and then moving the mouse in whatever pattern you wish, | |
36 ;; which you have set Emacs to understand as mapping to a given | |
37 ;; command. For example, you may wish the have a mouse stroke that | |
38 ;; looks like a capital `C' which means `copy-region-as-kill'. Treat | |
39 ;; strokes just like you do key bindings. For example, Emacs sets key | |
40 ;; bindings globally with the `global-set-key' command. Likewise, you | |
41 ;; can do | |
19345 | 42 |
46116 | 43 ;; > M-x strokes-global-set-stroke |
19345 | 44 |
45 ;; to interactively program in a stroke. It would be wise to set the | |
46 ;; first one to this very command, so that from then on, you invoke | |
46116 | 47 ;; `strokes-global-set-stroke' with a stroke. Likewise, there may |
48 ;; eventually be a `strokes-local-set-stroke' command, also analogous | |
49 ;; to `local-set-key'. | |
19345 | 50 |
51 ;; You can always unset the last stroke definition with the command | |
52 | |
53 ;; > M-x strokes-unset-last-stroke | |
54 | |
55 ;; and the last stroke that was added to `strokes-global-map' will be | |
56 ;; removed. | |
57 | |
58 ;; Other analogies between strokes and key bindings are as follows: | |
59 | |
60 ;; 1) To describe a stroke binding, you can type | |
61 | |
46116 | 62 ;; > M-x strokes-describe-stroke |
19345 | 63 |
64 ;; analogous to `describe-key'. It's also wise to have a stroke, | |
65 ;; like an `h', for help, or a `?', mapped to `describe-stroke'. | |
66 | |
67 ;; 2) stroke bindings are set internally through the Lisp function | |
46116 | 68 ;; `strokes-define-stroke', similar to the `define-key' function. |
69 ;; some examples for a 3x3 stroke grid would be | |
19345 | 70 |
46116 | 71 ;; (strokes-define-stroke c-mode-stroke-map |
19345 | 72 ;; '((0 . 0) (1 . 1) (2 . 2)) |
73 ;; 'kill-region) | |
46116 | 74 ;; (strokes-define-stroke strokes-global-map |
19345 | 75 ;; '((0 . 0) (0 . 1) (0 . 2) (1 . 2) (2 . 2)) |
76 ;; 'list-buffers) | |
77 | |
78 ;; however, if you would probably just have the user enter in the | |
79 ;; stroke interactively and then set the stroke to whatever he/she | |
54598
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
80 ;; entered. The Lisp function to interactively read a stroke is |
19345 | 81 ;; `strokes-read-stroke'. This is especially helpful when you're |
82 ;; on a fast computer that can handle a 9x9 stroke grid. | |
83 | |
84 ;; NOTE: only global stroke bindings are currently implemented, | |
85 ;; however mode- and buffer-local stroke bindings may eventually | |
86 ;; be implemented in a future version. | |
87 | |
88 ;; The important variables to be aware of for this package are listed | |
89 ;; below. They can all be altered through the customizing package via | |
90 | |
91 ;; > M-x customize | |
92 | |
93 ;; and customizing the group named `strokes'. You can also read | |
94 ;; documentation on the variables there. | |
95 | |
96 ;; `strokes-minimum-match-score' (determines the threshold of error that | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
97 ;; makes a stroke acceptable or unacceptable. If your strokes aren't |
19345 | 98 ;; matching, then you should raise this variable. |
99 | |
100 ;; `strokes-grid-resolution' (determines the grid dimensions that you use | |
101 ;; when defining/reading strokes. The finer the grid your computer can | |
102 ;; handle, the more you can do, but even a 3x3 grid is pretty cool.) | |
43233
ae3e8c9e9b87
(strokes-do-stroke, strokes-do-complex-stroke): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents:
41603
diff
changeset
|
103 ;; The default value (9) should be fine for most decent computers. |
19345 | 104 ;; NOTE: This variable should not be set to a number less than 3. |
105 | |
106 ;; `strokes-display-strokes-buffer' will allow you to hide the strokes | |
107 ;; buffer when doing simple strokes. This is a speedup for slow | |
108 ;; computers as well as people who don't want to see their strokes. | |
109 | |
110 ;; If you find that your mouse is accelerating too fast, you can | |
46116 | 111 ;; execute an X command to slow it down. A good possibility is |
19345 | 112 |
113 ;; % xset m 5/4 8 | |
114 | |
115 ;; which seems, heuristically, to work okay, without much disruption. | |
116 | |
117 ;; Whenever you load in the strokes package, you will be able to save | |
118 ;; what you've done upon exiting Emacs. You can also do | |
119 | |
46116 | 120 ;; > M-x strokes-prompt-user-save-strokes |
19345 | 121 |
122 ;; and it will save your strokes in ~/.strokes, or you may wish to change | |
123 ;; this by setting the variable `strokes-file'. | |
124 | |
125 ;; Note that internally, all of the routines that are part of this | |
126 ;; package are able to deal with complex strokes, as they are a superset | |
127 ;; of simple strokes. However, the default of this package will map | |
46116 | 128 ;; S-mouse-2 to the command `strokes-do-stroke', and M-mouse-2 to |
129 ;; `strokes-do-complex-stroke'. Complex strokes are terminated | |
130 ;; with mouse button 3. | |
19345 | 131 |
46116 | 132 ;; You can also toggle between strokes mode by simple typing |
19345 | 133 |
134 ;; > M-x strokes-mode | |
135 | |
46116 | 136 ;; I hope that, with the help of others, this package will be useful |
137 ;; in entering in pictographic-like language text using the mouse | |
138 ;; (i.e. Korean). Japanese and Chinese are a bit trickier, but I'm | |
139 ;; sure that with help it can be done. The next version will allow | |
140 ;; the user to enter strokes which "remove the pencil from the paper" | |
141 ;; so to speak, so one character can have multiple strokes. | |
19345 | 142 |
73277
f878c9ca9676
(defgroup strokes): Remove invalid url-link.
Eli Zaretskii <eliz@gnu.org>
parents:
68651
diff
changeset
|
143 ;; NOTE (Oct 7, 2006): The URLs below seem to be invalid!!! |
f878c9ca9676
(defgroup strokes): Remove invalid url-link.
Eli Zaretskii <eliz@gnu.org>
parents:
68651
diff
changeset
|
144 |
19345 | 145 ;; You can read more about strokes at: |
146 | |
147 ;; http://www.mit.edu/people/cadet/strokes-help.html | |
148 | |
149 ;; If you're interested in using strokes for writing English into Emacs | |
150 ;; using strokes, then you'll want to read about it on the web page above | |
151 ;; or just download from http://www.mit.edu/people/cadet/strokes-abc.el, | |
152 ;; which is nothing but a file with some helper commands for inserting | |
153 ;; alphanumerics and punctuation. | |
154 | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
155 ;; Great thanks to Rob Ristroph for his generosity in letting me use |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
156 ;; his PC to develop this, Jason Johnson for his help in algorithms, |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
157 ;; Euna Kim for her help in Korean, and massive thanks to the helpful |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
158 ;; guys on the help instance on athena (zeno, jered, amu, gsstark, |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
159 ;; ghudson, etc) Special thanks to Steve Baur, Kyle Jones, and Hrvoje |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
160 ;; Niksic for all their help. And special thanks to Dave Gillespie |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
161 ;; for all the elisp help--he is responsible for helping me use the cl |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
162 ;; macros at (near) max speed. |
19345 | 163 |
164 ;; Tasks: (what I'm getting ready for future version)... | |
46116 | 165 ;; 2) use 'strokes-read-complex-stroke for Korean, etc. |
19345 | 166 ;; 4) buffer-local 'strokes-local-map, and mode-stroke-maps would be nice |
167 ;; 6) add some hooks, like `strokes-read-stroke-hook' | |
168 ;; 7) See what people think of the factory settings. Should I change | |
169 ;; them? They're all pretty arbitrary in a way. I guess they | |
170 ;; should be minimal, but computers are getting lots faster, and | |
171 ;; if I choose the defaults too conservatively, then strokes will | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
172 ;; surely disappoint some people on decent machines (until they |
19345 | 173 ;; figure out M-x customize). I need feedback. |
174 ;; Other: I always have the most beta version of strokes, so if you | |
175 ;; want it just let me know. | |
176 | |
52778 | 177 ;; Fixme: Use pbm instead of xpm for pixmaps to work generally. |
178 | |
19345 | 179 ;;; Code: |
180 | |
181 ;;; Requirements and provisions... | |
182 | |
183 (autoload 'mail-position-on-field "sendmail") | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
184 (eval-when-compile (require 'cl)) |
19345 | 185 |
186 ;;; Constants... | |
187 | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
188 (defconst strokes-lift :strokes-lift |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
189 "Symbol representing a stroke lift event for complex strokes. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
190 Complex strokes are those which contain two or more simple strokes.") |
19345 | 191 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
192 (defconst strokes-xpm-header "/* XPM */ |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
193 static char * stroke_xpm[] = { |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
194 /* width height ncolors cpp [x_hot y_hot] */ |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
195 \"33 33 9 1 26 23\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
196 /* colors */ |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
197 \" c none s none\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
198 \"* c #000000 s foreground\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
199 \"R c #FFFF00000000\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
200 \"O c #FFFF80000000\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
201 \"Y c #FFFFFFFF0000\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
202 \"G c #0000FFFF0000\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
203 \"B c #00000000FFFF\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
204 \"P c #FFFF0000FFFF\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
205 \". c #45458B8B0000\", |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
206 /* pixels */\n" |
46116 | 207 "The header to all xpm buffers created by strokes.") |
19345 | 208 |
209 ;;; user variables... | |
210 | |
211 (defgroup strokes nil | |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
212 "Control Emacs through mouse strokes." |
46116 | 213 :link '(emacs-commentary-link "strokes") |
19345 | 214 :group 'mouse) |
215 | |
216 (defcustom strokes-modeline-string " Strokes" | |
100171 | 217 "Modeline identification when Strokes mode is on \(default is \" Strokes\"\)." |
19345 | 218 :type 'string |
219 :group 'strokes) | |
220 | |
221 (defcustom strokes-character ?@ | |
100171 | 222 "Character used when drawing strokes in the strokes buffer. |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
223 \(The default is `@', which works well.\)" |
19345 | 224 :type 'character |
225 :group 'strokes) | |
226 | |
227 (defcustom strokes-minimum-match-score 1000 | |
100171 | 228 "Minimum score for a stroke to be considered a possible match. |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
229 Setting this variable to 0 would require a perfectly precise match. |
19345 | 230 The default value is 1000, but it's mostly dependent on how precisely |
231 you manage to replicate your user-defined strokes. It also depends on | |
232 the value of `strokes-grid-resolution', since a higher grid resolution | |
233 will correspond to more sample points, and thus more distance | |
234 measurements. Usually, this is not a problem since you first set | |
235 `strokes-grid-resolution' based on what your computer seems to be able | |
46116 | 236 to handle (though the defaults are usually more than sufficient), and |
19345 | 237 then you can set `strokes-minimum-match-score' to something that works |
238 for you. The only purpose of this variable is to insure that if you | |
239 do a bogus stroke that really doesn't match any of the predefined | |
240 ones, then strokes should NOT pick the one that came closest." | |
241 :type 'integer | |
242 :group 'strokes) | |
243 | |
244 (defcustom strokes-grid-resolution 9 | |
100171 | 245 "Integer defining dimensions of the stroke grid. |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
246 The grid is a square grid, where `strokes-grid-resolution' defaults to |
19345 | 247 `9', making a 9x9 grid whose coordinates go from (0 . 0) on the top |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
248 left to ((strokes-grid-resolution - 1) . (strokes-grid-resolution - 1)) |
19345 | 249 on the bottom right. The greater the resolution, the more intricate |
250 your strokes can be. | |
251 NOTE: This variable should be odd and MUST NOT be less than 3 and need | |
252 not be greater than 33, which is the resolution of the pixmaps. | |
253 WARNING: Changing the value of this variable will gravely affect the | |
254 strokes you have already programmed in. You should try to | |
255 figure out what it should be based on your needs and on how | |
256 quick the particular platform(s) you're operating on, and | |
257 only then start programming in your custom strokes." | |
258 :type 'integer | |
259 :group 'strokes) | |
260 | |
30540
ed5f60298be9
(strokes-file): Run the file name through
Eli Zaretskii <eliz@gnu.org>
parents:
27975
diff
changeset
|
261 (defcustom strokes-file (convert-standard-filename "~/.strokes") |
100171 | 262 "File containing saved strokes for Strokes mode (default is ~/.strokes)." |
19345 | 263 :type 'file |
264 :group 'strokes) | |
265 | |
46116 | 266 (defvar strokes-buffer-name " *strokes*" |
267 "The name of the buffer that the strokes take place in.") | |
19345 | 268 |
269 (defcustom strokes-use-strokes-buffer t | |
100171 | 270 "If non-nil, the strokes buffer is used and strokes are displayed. |
19345 | 271 If nil, strokes will be read the same, however the user will not be |
272 able to see the strokes. This be helpful for people who don't like | |
273 the delay in switching to the strokes buffer." | |
274 :type 'boolean | |
275 :group 'strokes) | |
276 | |
277 ;;; internal variables... | |
278 | |
279 (defvar strokes-window-configuration nil | |
280 "The special window configuration used when entering strokes. | |
281 This is set properly in the function `strokes-update-window-configuration'.") | |
282 | |
283 (defvar strokes-last-stroke nil | |
284 "Last stroke entered by the user. | |
285 Its value gets set every time the function | |
286 `strokes-fill-stroke' gets called, | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
287 since that is the best time to set the variable.") |
19345 | 288 |
289 (defvar strokes-global-map '() | |
290 "Association list of strokes and their definitions. | |
291 Each entry is (STROKE . COMMAND) where STROKE is itself a list of | |
292 coordinates (X . Y) where X and Y are lists of positions on the | |
293 normalized stroke grid, with the top left at (0 . 0). COMMAND is the | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
294 corresponding interactive function.") |
19345 | 295 |
296 (defvar strokes-load-hook nil | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
297 "Functions to be called when Strokes is loaded.") |
19345 | 298 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
299 ;;; ### NOT IMPLEMENTED YET ### |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
300 ;;(defvar edit-strokes-menu |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
301 ;; '("Edit-Strokes" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
302 ;; ["Add stroke..." strokes-global-set-stroke t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
303 ;; ["Delete stroke..." strokes-edit-delete-stroke t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
304 ;; ["Change stroke" strokes-smaller t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
305 ;; ["Change definition" strokes-larger t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
306 ;; ["[Re]List Strokes chronologically" strokes-list-strokes t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
307 ;; ["[Re]List Strokes alphabetically" strokes-list-strokes t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
308 ;; ["Quit" strokes-edit-quit t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
309 ;; )) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
310 |
19345 | 311 ;;; Macros... |
312 | |
46116 | 313 ;; unused |
314 ;; (defmacro strokes-while-inhibiting-garbage-collector (&rest forms) | |
315 ;; "Execute FORMS without interference from the garbage collector." | |
316 ;; `(let ((gc-cons-threshold 134217727)) | |
317 ;; ,@forms)) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
318 |
19345 | 319 (defsubst strokes-click-p (stroke) |
320 "Non-nil if STROKE is really click." | |
19347 | 321 (< (length stroke) 2)) |
19345 | 322 |
323 ;;; old, but worked pretty good (just in case)... | |
324 ;;(defmacro strokes-define-stroke (stroke-map stroke def) | |
325 ;; "Add STROKE to STROKE-MAP alist with given command DEF" | |
19347 | 326 ;; (list 'if (list '< (list 'length stroke) 2) |
19345 | 327 ;; (list 'error |
328 ;; "That's a click, not a stroke. See `strokes-click-command'") | |
329 ;; (list 'setq stroke-map (list 'cons (list 'cons stroke def) | |
330 ;; (list 'remassoc stroke stroke-map))))) | |
331 | |
332 (defsubst strokes-remassoc (key list) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
333 (let (elt) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
334 (while (setq elt (assoc key list)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
335 (setq list (delete elt list)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
336 list) |
19345 | 337 |
338 (defmacro strokes-define-stroke (stroke-map stroke def) | |
339 "Add STROKE to STROKE-MAP alist with given command DEF." | |
340 `(if (strokes-click-p ,stroke) | |
46116 | 341 (error "That's a click, not a stroke") |
19345 | 342 (setq ,stroke-map (cons (cons ,stroke ,def) |
343 (strokes-remassoc ,stroke ,stroke-map))))) | |
344 | |
345 (defsubst strokes-square (x) | |
46116 | 346 "Return the square of the number X." |
19345 | 347 (* x x)) |
348 | |
349 (defsubst strokes-distance-squared (p1 p2) | |
350 "Gets the distance (squared) between to points P1 and P2. | |
351 P1 and P2 are cons cells in the form (X . Y)." | |
352 (let ((x1 (car p1)) | |
353 (y1 (cdr p1)) | |
354 (x2 (car p2)) | |
355 (y2 (cdr p2))) | |
356 (+ (strokes-square (- x2 x1)) | |
357 (strokes-square (- y2 y1))))) | |
358 | |
359 ;;; Functions... | |
360 | |
361 (defsubst strokes-mouse-event-p (event) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
362 (and (consp event) (symbolp (car event)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
363 (or (eq (car event) 'mouse-movement) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
364 (memq 'click (get (car event) 'event-symbol-elements)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
365 (memq 'down (get (car event) 'event-symbol-elements)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
366 (memq 'drag (get (car event) 'event-symbol-elements))))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
367 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
368 (defsubst strokes-button-press-event-p (event) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
369 (and (consp event) (symbolp (car event)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
370 (memq 'down (get (car event) 'event-symbol-elements)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
371 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
372 (defsubst strokes-button-release-event-p (event) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
373 (and (consp event) (symbolp (car event)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
374 (or (memq 'click (get (car event) 'event-symbol-elements)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
375 (memq 'drag (get (car event) 'event-symbol-elements))))) |
19345 | 376 |
377 (defun strokes-event-closest-point-1 (window &optional line) | |
378 "Return position of start of line LINE in WINDOW. | |
379 If LINE is nil, return the last position visible in WINDOW." | |
380 (let* ((total (- (window-height window) | |
381 (if (window-minibuffer-p window) | |
382 0 1))) | |
383 (distance (or line total))) | |
384 (save-excursion | |
385 (goto-char (window-start window)) | |
386 (if (= (vertical-motion distance) distance) | |
387 (if (not line) | |
388 (forward-char -1))) | |
389 (point)))) | |
390 | |
391 (defun strokes-event-closest-point (event &optional start-window) | |
392 "Return the nearest position to where EVENT ended its motion. | |
393 This is computed for the window where EVENT's motion started, | |
46116 | 394 or for window START-WINDOW if that is specified." |
19345 | 395 (or start-window (setq start-window (posn-window (event-start event)))) |
396 (if (eq start-window (posn-window (event-end event))) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
397 (if (eq (posn-point (event-end event)) 'vertical-line) |
19345 | 398 (strokes-event-closest-point-1 start-window |
399 (cdr (posn-col-row (event-end event)))) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
400 (if (eq (posn-point (event-end event)) 'mode-line) |
19345 | 401 (strokes-event-closest-point-1 start-window) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
402 (posn-point (event-end event)))) |
19345 | 403 ;; EVENT ended in some other window. |
404 (let* ((end-w (posn-window (event-end event))) | |
405 (end-w-top) | |
406 (w-top (nth 1 (window-edges start-window)))) | |
407 (setq end-w-top | |
408 (if (windowp end-w) | |
409 (nth 1 (window-edges end-w)) | |
410 (/ (cdr (posn-x-y (event-end event))) | |
19347 | 411 (frame-char-height end-w)))) |
19345 | 412 (if (>= end-w-top w-top) |
413 (strokes-event-closest-point-1 start-window) | |
414 (window-start start-window))))) | |
415 | |
416 (defun strokes-lift-p (object) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
417 "Return non-nil if OBJECT is a stroke-lift." |
19345 | 418 (eq object strokes-lift)) |
419 | |
420 (defun strokes-unset-last-stroke () | |
421 "Undo the last stroke definition." | |
422 (interactive) | |
423 (let ((command (cdar strokes-global-map))) | |
19347 | 424 (if (y-or-n-p |
46116 | 425 (format "Really delete last stroke definition, defined to `%s'? " |
19345 | 426 command)) |
427 (progn | |
428 (setq strokes-global-map (cdr strokes-global-map)) | |
429 (message "That stroke has been deleted")) | |
430 (message "Nothing done")))) | |
431 | |
432 ;;;###autoload | |
433 (defun strokes-global-set-stroke (stroke command) | |
434 "Interactively give STROKE the global binding as COMMAND. | |
435 Operated just like `global-set-key', except for strokes. | |
436 COMMAND is a symbol naming an interactively-callable function. STROKE | |
437 is a list of sampled positions on the stroke grid as described in the | |
54598
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
438 documentation for the `strokes-define-stroke' function. |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
439 |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
440 See also `strokes-global-set-stroke-string'." |
19345 | 441 (interactive |
442 (list | |
443 (and (or strokes-mode (strokes-mode t)) | |
444 (strokes-read-complex-stroke | |
46116 | 445 "Draw with mouse button 1 (or 2). End with button 3...")) |
446 (read-command "Command to map stroke to: "))) | |
19345 | 447 (strokes-define-stroke strokes-global-map stroke command)) |
448 | |
54598
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
449 (defun strokes-global-set-stroke-string (stroke string) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
450 "Interactively give STROKE the global binding as STRING. |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
451 Operated just like `global-set-key', except for strokes. STRING |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
452 is a string to be inserted by the stroke. STROKE is a list of |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
453 sampled positions on the stroke grid as described in the |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
454 documentation for the `strokes-define-stroke' function. |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
455 |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
456 Compare `strokes-global-set-stroke'." |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
457 (interactive |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
458 (list |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
459 (and (or strokes-mode (strokes-mode t)) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
460 (strokes-read-complex-stroke |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
461 "Draw with mouse button 1 (or 2). End with button 3...")) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
462 (read-string "String to map stroke to: "))) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
463 (strokes-define-stroke strokes-global-map stroke string)) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
464 |
19345 | 465 ;;(defun global-unset-stroke (stroke); FINISH THIS DEFUN! |
466 ;; "delete all strokes matching STROKE from `strokes-global-map', | |
467 ;; letting the user input | |
468 ;; the stroke with the mouse" | |
469 ;; (interactive | |
470 ;; (list | |
471 ;; (strokes-read-stroke "Enter the stroke you want to delete..."))) | |
472 ;; (strokes-define-stroke 'strokes-global-map stroke command)) | |
473 | |
474 (defun strokes-get-grid-position (stroke-extent position &optional grid-resolution) | |
46116 | 475 "Map POSITION to a new grid position. |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
476 Do so based on its STROKE-EXTENT and GRID-RESOLUTION. |
19345 | 477 STROKE-EXTENT as a list \(\(XMIN . YMIN\) \(XMAX . YMAX\)\). |
478 If POSITION is a `strokes-lift', then it is itself returned. | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
479 Optional GRID-RESOLUTION may be used in place of `strokes-grid-resolution'. |
46116 | 480 The grid is a square whose dimension is [0,GRID-RESOLUTION)." |
19345 | 481 (cond ((consp position) ; actual pixel location |
482 (let ((grid-resolution (or grid-resolution strokes-grid-resolution)) | |
483 (x (car position)) | |
484 (y (cdr position)) | |
485 (xmin (caar stroke-extent)) | |
486 (ymin (cdar stroke-extent)) | |
487 ;; the `1+' is there to insure that the | |
488 ;; formula evaluates correctly at the boundaries | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
489 (xmax (1+ (car (cadr stroke-extent)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
490 (ymax (1+ (cdr (cadr stroke-extent))))) |
19345 | 491 (cons (floor (* grid-resolution |
492 (/ (float (- x xmin)) | |
493 (- xmax xmin)))) | |
494 (floor (* grid-resolution | |
495 (/ (float (- y ymin)) | |
496 (- ymax ymin))))))) | |
497 ((strokes-lift-p position) ; stroke lift | |
498 strokes-lift))) | |
499 | |
500 (defun strokes-get-stroke-extent (pixel-positions) | |
46116 | 501 "From a list of absolute PIXEL-POSITIONS, return absolute spatial extent. |
19345 | 502 The return value is a list ((XMIN . YMIN) (XMAX . YMAX))." |
503 (if pixel-positions | |
504 (let ((xmin (caar pixel-positions)) | |
505 (xmax (caar pixel-positions)) | |
506 (ymin (cdar pixel-positions)) | |
507 (ymax (cdar pixel-positions)) | |
508 (rest (cdr pixel-positions))) | |
509 (while rest | |
510 (if (consp (car rest)) | |
511 (let ((x (caar rest)) | |
512 (y (cdar rest))) | |
513 (if (< x xmin) | |
514 (setq xmin x)) | |
515 (if (> x xmax) | |
516 (setq xmax x)) | |
517 (if (< y ymin) | |
518 (setq ymin y)) | |
519 (if (> y ymax) | |
520 (setq ymax y)))) | |
521 (setq rest (cdr rest))) | |
522 (let ((delta-x (- xmax xmin)) | |
523 (delta-y (- ymax ymin))) | |
524 (if (> delta-x delta-y) | |
525 (setq ymin (- ymin | |
526 (/ (- delta-x delta-y) | |
527 2)) | |
528 ymax (+ ymax | |
529 (/ (- delta-x delta-y) | |
530 2))) | |
531 (setq xmin (- xmin | |
532 (/ (- delta-y delta-x) | |
533 2)) | |
534 xmax (+ xmax | |
535 (/ (- delta-y delta-x) | |
536 2)))) | |
537 (list (cons xmin ymin) | |
538 (cons xmax ymax)))) | |
539 nil)) | |
540 | |
541 (defun strokes-eliminate-consecutive-redundancies (entries) | |
46116 | 542 "Return a list with no consecutive redundant entries." |
19345 | 543 ;; defun a grande vitesse grace a Dave G. |
544 (loop for element on entries | |
545 if (not (equal (car element) (cadr element))) | |
546 collect (car element))) | |
547 ;; (loop for element on entries | |
548 ;; nconc (if (not (equal (car el) (cadr el))) | |
549 ;; (list (car el))))) | |
550 ;; yet another (orig) way of doing it... | |
551 ;; (if entries | |
552 ;; (let* ((current (car entries)) | |
553 ;; (rest (cdr entries)) | |
554 ;; (non-redundant-list (list current)) | |
555 ;; (next nil)) | |
556 ;; (while rest | |
557 ;; (setq next (car rest)) | |
558 ;; (if (equal current next) | |
559 ;; (setq rest (cdr rest)) | |
560 ;; (setq non-redundant-list (cons next non-redundant-list) | |
561 ;; current next | |
562 ;; rest (cdr rest)))) | |
563 ;; (nreverse non-redundant-list)) | |
564 ;; nil)) | |
565 | |
566 (defun strokes-renormalize-to-grid (positions &optional grid-resolution) | |
567 "Map POSITIONS to a new grid whose dimensions are based on GRID-RESOLUTION. | |
568 POSITIONS is a list of positions and stroke-lifts. | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
569 Optional GRID-RESOLUTION may be used in place of `strokes-grid-resolution'. |
46116 | 570 The grid is a square whose dimension is [0,GRID-RESOLUTION)." |
19345 | 571 (or grid-resolution (setq grid-resolution strokes-grid-resolution)) |
572 (let ((stroke-extent (strokes-get-stroke-extent positions))) | |
573 (mapcar (function | |
574 (lambda (pos) | |
575 (strokes-get-grid-position stroke-extent pos grid-resolution))) | |
576 positions))) | |
577 | |
578 (defun strokes-fill-stroke (unfilled-stroke &optional force) | |
579 "Fill in missing grid locations in the list of UNFILLED-STROKE. | |
580 If FORCE is non-nil, then fill the stroke even if it's `stroke-click'. | |
581 NOTE: This is where the global variable `strokes-last-stroke' is set." | |
582 (setq strokes-last-stroke ; this is global | |
583 (if (and (strokes-click-p unfilled-stroke) | |
584 (not force)) | |
585 unfilled-stroke | |
586 (loop for grid-locs on unfilled-stroke | |
587 nconc (let* ((current (car grid-locs)) | |
588 (current-is-a-point-p (consp current)) | |
589 (next (cadr grid-locs)) | |
590 (next-is-a-point-p (consp next)) | |
591 (both-are-points-p (and current-is-a-point-p | |
592 next-is-a-point-p)) | |
593 (x1 (and current-is-a-point-p | |
594 (car current))) | |
595 (y1 (and current-is-a-point-p | |
596 (cdr current))) | |
597 (x2 (and next-is-a-point-p | |
598 (car next))) | |
599 (y2 (and next-is-a-point-p | |
600 (cdr next))) | |
601 (delta-x (and both-are-points-p | |
602 (- x2 x1))) | |
603 (delta-y (and both-are-points-p | |
604 (- y2 y1))) | |
605 (slope (and both-are-points-p | |
606 (if (zerop delta-x) | |
607 nil ; undefined vertical slope | |
608 (/ (float delta-y) | |
609 delta-x))))) | |
610 (cond ((not both-are-points-p) | |
611 (list current)) | |
46116 | 612 ((null slope) ; undefined vertical slope |
19345 | 613 (if (>= delta-y 0) |
614 (loop for y from y1 below y2 | |
615 collect (cons x1 y)) | |
616 (loop for y from y1 above y2 | |
617 collect (cons x1 y)))) | |
618 ((zerop slope) ; (= y1 y2) | |
619 (if (>= delta-x 0) | |
620 (loop for x from x1 below x2 | |
621 collect (cons x y1)) | |
622 (loop for x from x1 above x2 | |
623 collect (cons x y1)))) | |
624 ((>= (abs delta-x) (abs delta-y)) | |
625 (if (> delta-x 0) | |
626 (loop for x from x1 below x2 | |
627 collect (cons x | |
628 (+ y1 | |
629 (round (* slope | |
630 (- x x1)))))) | |
631 (loop for x from x1 above x2 | |
632 collect (cons x | |
633 (+ y1 | |
634 (round (* slope | |
635 (- x x1)))))))) | |
636 (t ; (< (abs delta-x) (abs delta-y)) | |
637 (if (> delta-y 0) | |
638 (loop for y from y1 below y2 | |
639 collect (cons (+ x1 | |
640 (round (/ (- y y1) | |
641 slope))) | |
642 y)) | |
643 (loop for y from y1 above y2 | |
644 collect (cons (+ x1 | |
645 (round (/ (- y y1) | |
646 slope))) | |
647 y)))))))))) | |
648 | |
649 (defun strokes-rate-stroke (stroke1 stroke2) | |
46116 | 650 "Rates STROKE1 with STROKE2 and return a score based on a distance metric. |
19345 | 651 Note: the rating is an error rating, and therefore, a return of 0 |
652 represents a perfect match. Also note that the order of stroke | |
653 arguments is order-independent for the algorithm used here." | |
654 (if (and stroke1 stroke2) | |
655 (let ((rest1 (cdr stroke1)) | |
656 (rest2 (cdr stroke2)) | |
657 (err (strokes-distance-squared (car stroke1) | |
658 (car stroke2)))) | |
659 (while (and rest1 rest2) | |
660 (while (and (consp (car rest1)) | |
661 (consp (car rest2))) | |
662 (setq err (+ err | |
663 (strokes-distance-squared (car rest1) | |
664 (car rest2))) | |
665 stroke1 rest1 | |
666 stroke2 rest2 | |
667 rest1 (cdr stroke1) | |
668 rest2 (cdr stroke2))) | |
669 (cond ((and (strokes-lift-p (car rest1)) | |
670 (strokes-lift-p (car rest2))) | |
671 (setq rest1 (cdr rest1) | |
672 rest2 (cdr rest2))) | |
673 ((strokes-lift-p (car rest2)) | |
674 (while (consp (car rest1)) | |
675 (setq err (+ err | |
676 (strokes-distance-squared (car rest1) | |
677 (car stroke2))) | |
678 rest1 (cdr rest1)))) | |
679 ((strokes-lift-p (car rest1)) | |
680 (while (consp (car rest2)) | |
681 (setq err (+ err | |
682 (strokes-distance-squared (car stroke1) | |
683 (car rest2))) | |
684 rest2 (cdr rest2)))))) | |
685 (if (null rest2) | |
686 (while (consp (car rest1)) | |
687 (setq err (+ err | |
688 (strokes-distance-squared (car rest1) | |
689 (car stroke2))) | |
690 rest1 (cdr rest1)))) | |
691 (if (null rest1) | |
692 (while (consp (car rest2)) | |
693 (setq err (+ err | |
694 (strokes-distance-squared (car stroke1) | |
695 (car rest2))) | |
696 rest2 (cdr rest2)))) | |
697 (if (or (strokes-lift-p (car rest1)) | |
698 (strokes-lift-p (car rest2))) | |
699 (setq err nil) | |
700 err)) | |
701 nil)) | |
702 | |
703 (defun strokes-match-stroke (stroke stroke-map) | |
46116 | 704 "Find the best matching command of STROKE in STROKE-MAP. |
19345 | 705 Returns the corresponding match as (COMMAND . SCORE)." |
706 (if (and stroke stroke-map) | |
707 (let ((score (strokes-rate-stroke stroke (caar stroke-map))) | |
708 (command (cdar stroke-map)) | |
709 (map (cdr stroke-map))) | |
710 (while map | |
711 (let ((newscore (strokes-rate-stroke stroke (caar map)))) | |
712 (if (or (and newscore score (< newscore score)) | |
713 (and newscore (null score))) | |
714 (setq score newscore | |
715 command (cdar map))) | |
716 (setq map (cdr map)))) | |
717 (if score | |
718 (cons command score) | |
719 nil)) | |
720 nil)) | |
721 | |
722 ;;;###autoload | |
723 (defun strokes-read-stroke (&optional prompt event) | |
724 "Read a simple stroke (interactively) and return the stroke. | |
725 Optional PROMPT in minibuffer displays before and during stroke reading. | |
726 This function will display the stroke interactively as it is being | |
727 entered in the strokes buffer if the variable | |
728 `strokes-use-strokes-buffer' is non-nil. | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
729 Optional EVENT is acceptable as the starting event of the stroke." |
19345 | 730 (save-excursion |
19347 | 731 (let ((pix-locs nil) |
732 (grid-locs nil) | |
733 (safe-to-draw-p nil)) | |
734 (if strokes-use-strokes-buffer | |
735 ;; switch to the strokes buffer and | |
736 ;; display the stroke as it's being read | |
737 (save-window-excursion | |
738 (set-window-configuration strokes-window-configuration) | |
739 (when prompt | |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64993
diff
changeset
|
740 (message "%s" prompt) |
19347 | 741 (setq event (read-event)) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
742 (or (strokes-button-press-event-p event) |
19347 | 743 (error "You must draw with the mouse"))) |
744 (unwind-protect | |
745 (track-mouse | |
746 (or event (setq event (read-event) | |
747 safe-to-draw-p t)) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
748 (while (not (strokes-button-release-event-p event)) |
19347 | 749 (if (strokes-mouse-event-p event) |
750 (let ((point (strokes-event-closest-point event))) | |
751 (if (and point safe-to-draw-p) | |
752 ;; we can draw that point | |
753 (progn | |
754 (goto-char point) | |
46116 | 755 (subst-char-in-region point (1+ point) |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
756 ?\s strokes-character)) |
19347 | 757 ;; otherwise, we can start drawing the next time... |
758 (setq safe-to-draw-p t)) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
759 (push (cdr (mouse-pixel-position)) |
19347 | 760 pix-locs))) |
761 (setq event (read-event))))) | |
762 ;; protected | |
763 ;; clean up strokes buffer and then bury it. | |
764 (when (equal (buffer-name) strokes-buffer-name) | |
46116 | 765 (subst-char-in-region (point-min) (point-max) |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
766 strokes-character ?\s) |
19347 | 767 (goto-char (point-min)) |
768 (bury-buffer)))) | |
769 ;; Otherwise, don't use strokes buffer and read stroke silently | |
770 (when prompt | |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64993
diff
changeset
|
771 (message "%s" prompt) |
19347 | 772 (setq event (read-event)) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
773 (or (strokes-button-press-event-p event) |
19347 | 774 (error "You must draw with the mouse"))) |
775 (track-mouse | |
776 (or event (setq event (read-event))) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
777 (while (not (strokes-button-release-event-p event)) |
19347 | 778 (if (strokes-mouse-event-p event) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
779 (push (cdr (mouse-pixel-position)) |
19347 | 780 pix-locs)) |
781 (setq event (read-event)))) | |
782 (setq grid-locs (strokes-renormalize-to-grid (nreverse pix-locs))) | |
46116 | 783 (strokes-fill-stroke |
784 (strokes-eliminate-consecutive-redundancies grid-locs))))) | |
19345 | 785 |
786 ;;;###autoload | |
787 (defun strokes-read-complex-stroke (&optional prompt event) | |
788 "Read a complex stroke (interactively) and return the stroke. | |
789 Optional PROMPT in minibuffer displays before and during stroke reading. | |
790 Note that a complex stroke allows the user to pen-up and pen-down. This | |
46116 | 791 is implemented by allowing the user to paint with button 1 or button 2 and |
792 then complete the stroke with button 3. | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
793 Optional EVENT is acceptable as the starting event of the stroke." |
19345 | 794 (save-excursion |
795 (save-window-excursion | |
19347 | 796 (set-window-configuration strokes-window-configuration) |
797 (let ((pix-locs nil) | |
798 (grid-locs nil)) | |
799 (if prompt | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
800 (while (not (strokes-button-press-event-p event)) |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64993
diff
changeset
|
801 (message "%s" prompt) |
19347 | 802 (setq event (read-event)))) |
803 (unwind-protect | |
804 (track-mouse | |
805 (or event (setq event (read-event))) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
806 (while (not (and (strokes-button-press-event-p event) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
807 (eq 'mouse-3 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
808 (car (get (car event) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
809 'event-symbol-elements))))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
810 (while (not (strokes-button-release-event-p event)) |
19347 | 811 (if (strokes-mouse-event-p event) |
812 (let ((point (strokes-event-closest-point event))) | |
813 (when point | |
814 (goto-char point) | |
46116 | 815 (subst-char-in-region point (1+ point) |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
816 ?\s strokes-character)) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
817 (push (cdr (mouse-pixel-position)) |
19347 | 818 pix-locs))) |
819 (setq event (read-event))) | |
820 (push strokes-lift pix-locs) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
821 (while (not (strokes-button-press-event-p event)) |
19347 | 822 (setq event (read-event)))) |
823 ;; ### KLUDGE! ### sit and wait | |
824 ;; for some useless event to | |
825 ;; happen to fix the minibuffer bug. | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
826 (while (not (strokes-button-release-event-p (read-event)))) |
19347 | 827 (setq pix-locs (nreverse (cdr pix-locs)) |
828 grid-locs (strokes-renormalize-to-grid pix-locs)) | |
829 (strokes-fill-stroke | |
830 (strokes-eliminate-consecutive-redundancies grid-locs))) | |
831 ;; protected | |
832 (when (equal (buffer-name) strokes-buffer-name) | |
46116 | 833 (subst-char-in-region (point-min) (point-max) |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
834 strokes-character ?\s) |
19347 | 835 (goto-char (point-min)) |
836 (bury-buffer))))))) | |
19345 | 837 |
838 (defun strokes-execute-stroke (stroke) | |
839 "Given STROKE, execute the command which corresponds to it. | |
840 The command will be executed provided one exists for that stroke, | |
841 based on the variable `strokes-minimum-match-score'. | |
842 If no stroke matches, nothing is done and return value is nil." | |
843 (let* ((match (strokes-match-stroke stroke strokes-global-map)) | |
844 (command (car match)) | |
845 (score (cdr match))) | |
46116 | 846 (cond ((and match (<= score strokes-minimum-match-score)) |
19345 | 847 (message "%s" command) |
848 (command-execute command)) | |
849 ((null strokes-global-map) | |
850 (if (file-exists-p strokes-file) | |
19347 | 851 (and (y-or-n-p |
19345 | 852 (format "No strokes loaded. Load `%s'? " |
853 strokes-file)) | |
854 (strokes-load-user-strokes)) | |
46116 | 855 (error "No strokes defined; use `strokes-global-set-stroke'"))) |
19345 | 856 (t |
857 (error | |
858 "No stroke matches; see variable `strokes-minimum-match-score'") | |
859 nil)))) | |
860 | |
861 ;;;###autoload | |
862 (defun strokes-do-stroke (event) | |
43233
ae3e8c9e9b87
(strokes-do-stroke, strokes-do-complex-stroke): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents:
41603
diff
changeset
|
863 "Read a simple stroke from the user and then execute its command. |
19345 | 864 This must be bound to a mouse event." |
865 (interactive "e") | |
866 (or strokes-mode (strokes-mode t)) | |
867 (strokes-execute-stroke (strokes-read-stroke nil event))) | |
868 | |
869 ;;;###autoload | |
870 (defun strokes-do-complex-stroke (event) | |
43233
ae3e8c9e9b87
(strokes-do-stroke, strokes-do-complex-stroke): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents:
41603
diff
changeset
|
871 "Read a complex stroke from the user and then execute its command. |
19345 | 872 This must be bound to a mouse event." |
873 (interactive "e") | |
874 (or strokes-mode (strokes-mode t)) | |
875 (strokes-execute-stroke (strokes-read-complex-stroke nil event))) | |
876 | |
877 ;;;###autoload | |
878 (defun strokes-describe-stroke (stroke) | |
879 "Displays the command which STROKE maps to, reading STROKE interactively." | |
880 (interactive | |
881 (list | |
882 (strokes-read-complex-stroke | |
46116 | 883 "Enter stroke to describe; end with button 3..."))) |
19345 | 884 (let* ((match (strokes-match-stroke stroke strokes-global-map)) |
46116 | 885 (command (car match)) |
19345 | 886 (score (cdr match))) |
46116 | 887 (if (and match |
888 (<= score strokes-minimum-match-score)) | |
19345 | 889 (message "That stroke maps to `%s'" command) |
890 (message "That stroke is undefined")) | |
891 (sleep-for 1))) ; helpful for recursive edits | |
892 | |
893 ;;;###autoload | |
19347 | 894 (defun strokes-help () |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
895 "Get instruction on using the Strokes package." |
19347 | 896 (interactive) |
46116 | 897 (with-output-to-temp-buffer "*Help with Strokes*" |
898 (princ | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
899 (substitute-command-keys |
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
900 "This is help for the strokes package. |
19345 | 901 |
19347 | 902 ------------------------------------------------------------ |
19345 | 903 |
19347 | 904 ** Strokes... |
19345 | 905 |
19347 | 906 The strokes package allows you to define strokes, made with |
907 the mouse or other pointer device, that Emacs can interpret as | |
908 corresponding to commands, and then executes the commands. It does | |
909 character recognition, so you don't have to worry about getting it | |
910 right every time. | |
19345 | 911 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
912 Strokes also allows you to compose documents graphically. You can |
43233
ae3e8c9e9b87
(strokes-do-stroke, strokes-do-complex-stroke): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents:
41603
diff
changeset
|
913 fully edit documents in Chinese, Japanese, etc. based on Emacs |
46116 | 914 strokes. Once you've done so, you can ASCII compress-and-encode them |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
915 and then safely save them for later use, send letters to friends |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
916 \(using Emacs, of course). Strokes will later decode these documents, |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
917 extracting the strokes for editing use once again, so the editing |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
918 cycle can continue. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
919 |
19347 | 920 Strokes are easy to program and fun to use. To start strokes going, |
921 you'll want to put the following line in your .emacs file as mentioned | |
922 in the commentary to strokes.el. | |
923 | |
924 This will load strokes when and only when you start Emacs on a window | |
925 system, with a mouse or other pointer device defined. | |
19345 | 926 |
19347 | 927 To toggle strokes-mode, you just do |
928 | |
929 > M-x strokes-mode | |
19345 | 930 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
931 ** Strokes for controlling the behavior of Emacs... |
19345 | 932 |
19347 | 933 When you're ready to start defining strokes, just use the command |
19345 | 934 |
46116 | 935 > M-x strokes-global-set-stroke |
19345 | 936 |
19347 | 937 You will see a ` *strokes*' buffer which is waiting for you to enter in |
46116 | 938 your stroke. When you enter in the stroke, you draw with button 1 or |
939 button 2, and then end with button 3. Next, you enter in the command | |
19347 | 940 which will be executed when that stroke is invoked. Simple as that. |
941 For now, try to define a stroke to copy a region. This is a popular | |
942 edit command, so type | |
19345 | 943 |
46116 | 944 > M-x strokes-global-set-stroke |
19345 | 945 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
946 Then, in the ` *strokes*' buffer, draw the letter `C' (for `copy') |
19347 | 947 and then, when it asks you to enter the command to map that to, type |
948 | |
949 > copy-region-as-kill | |
19345 | 950 |
19347 | 951 That's about as hard as it gets. |
46116 | 952 Remember: paint with button 1 or button 2 and then end with button 3. |
19345 | 953 |
19347 | 954 If ever you want to know what a certain strokes maps to, then do |
19345 | 955 |
46116 | 956 > M-x strokes-describe-stroke |
19345 | 957 |
19347 | 958 and you can enter in any arbitrary stroke. Remember: The strokes |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
959 package lets you program in simple and complex (multi-lift) strokes. |
19347 | 960 The only difference is how you *invoke* the two. You will most likely |
961 use simple strokes, as complex strokes were developed for | |
46116 | 962 Chinese/Japanese/Korean. So the shifted middle mouse button (S-mouse-2) will |
963 invoke the command `strokes-do-stroke'. | |
19345 | 964 |
19347 | 965 If ever you define a stroke which you don't like, then you can unset |
966 it with the command | |
19345 | 967 |
19347 | 968 > M-x strokes-unset-last-stroke |
19345 | 969 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
970 You can always get an idea of what your current strokes look like with |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
971 the command |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
972 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
973 > M-x strokes-list-strokes |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
974 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
975 Your strokes will be displayed in alphabetical order (based on command |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
976 names) and the beginning of each simple stroke will be marked by a |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
977 color dot. Since you may have several simple strokes in a complex |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
978 stroke, the dot colors are arranged in the rainbow color sequence, |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
979 `ROYGBIV'. If you want a listing of your strokes from most recent |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
980 down, then use a prefix argument: |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
981 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
982 > C-u M-x strokes-list-strokes |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
983 |
19347 | 984 Your strokes are stored as you enter them. They get saved in a file |
985 called ~/.strokes, along with other strokes configuration variables. | |
986 You can change this location by setting the variable `strokes-file'. | |
987 You will be prompted to save them when you exit Emacs, or you can save | |
988 them with | |
19345 | 989 |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
990 > M-x strokes-prompt-user-save-strokes |
19345 | 991 |
19347 | 992 Your strokes get loaded automatically when you enable `strokes-mode'. |
993 You can also load in your user-defined strokes with | |
19345 | 994 |
46116 | 995 > M-x strokes-load-user-strokes |
19345 | 996 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
997 ** Strokes for pictographic editing... |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
998 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
999 If you'd like to create graphical files with strokes, you'll have to |
46116 | 1000 be running a version of Emacs with XPM support. You use the binding |
1001 to `strokes-compose-complex-stroke' to start drawing your strokes. | |
1002 These are just complex strokes, and thus continue drawing with mouse-1 | |
1003 or mouse-2 and end with mouse-3. Then the stroke image gets inserted | |
1004 into the buffer. You treat it somewhat like any other character, | |
1005 which you can copy, paste, delete, move, etc. When all is done, you | |
1006 may want to send the file, or save it. This is done with | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1007 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1008 > M-x strokes-encode-buffer |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1009 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1010 Likewise, to decode the strokes from a strokes-encoded buffer you do |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1011 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1012 > M-x strokes-decode-buffer |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1013 |
19347 | 1014 ** A few more important things... |
19345 | 1015 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1016 o The command `strokes-do-complex-stroke' is invoked with M-mouse-2, |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1017 so that you can execute complex strokes (i.e. with more than one lift) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1018 if preferred. |
19345 | 1019 |
19347 | 1020 o Strokes are a bit computer-dependent in that they depend somewhat on |
1021 the speed of the computer you're working on. This means that you | |
1022 may have to tweak some variables. You can read about them in the | |
46116 | 1023 commentary of `strokes.el'. Better to just use \\[apropos] and read their |
19347 | 1024 docstrings. All variables/functions start with `strokes'. The one |
1025 variable which many people wanted to see was | |
1026 `strokes-use-strokes-buffer' which allows the user to use strokes | |
1027 silently--without displaying the strokes. All variables can be set | |
64551
dc55ec2be671
(strokes-load-hook): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
1028 by customizing the group `strokes' via \\[customize-group].")) |
46116 | 1029 (set-buffer standard-output) |
46327
4d662e939eab
(strokes-help): Call print-help-return-message
Richard M. Stallman <rms@gnu.org>
parents:
46116
diff
changeset
|
1030 (help-mode) |
4d662e939eab
(strokes-help): Call print-help-return-message
Richard M. Stallman <rms@gnu.org>
parents:
46116
diff
changeset
|
1031 (print-help-return-message))) |
19345 | 1032 |
46116 | 1033 (defalias 'strokes-report-bug 'report-emacs-bug) |
19345 | 1034 |
1035 (defsubst strokes-fill-current-buffer-with-whitespace () | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1036 "Erase the contents of the current buffer and fill it with whitespace." |
19345 | 1037 (erase-buffer) |
1038 (loop repeat (frame-height) do | |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
1039 (insert-char ?\s (1- (frame-width))) |
19345 | 1040 (newline)) |
1041 (goto-char (point-min))) | |
1042 | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1043 (defun strokes-window-configuration-changed-p () |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1044 "Non-nil if the `strokes-window-configuration' frame properties changed. |
46116 | 1045 This is based on the last time `strokes-window-configuration' was updated." |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1046 (compare-window-configurations (current-window-configuration) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1047 strokes-window-configuration)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1048 |
19345 | 1049 (defun strokes-update-window-configuration () |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1050 "Ensure that `strokes-window-configuration' is up-to-date." |
19345 | 1051 (interactive) |
1052 (let ((current-window (selected-window))) | |
1053 (cond ((or (window-minibuffer-p current-window) | |
1054 (window-dedicated-p current-window)) | |
1055 ;; don't try to update strokes window configuration | |
1056 ;; if window is dedicated or a minibuffer | |
1057 nil) | |
1058 ((or (interactive-p) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1059 (not (buffer-live-p (get-buffer strokes-buffer-name))) |
19345 | 1060 (null strokes-window-configuration)) |
1061 ;; create `strokes-window-configuration' from scratch... | |
1062 (save-excursion | |
1063 (save-window-excursion | |
1064 (get-buffer-create strokes-buffer-name) | |
1065 (set-window-buffer current-window strokes-buffer-name) | |
1066 (delete-other-windows) | |
1067 (fundamental-mode) | |
1068 (auto-save-mode 0) | |
1069 (if (featurep 'font-lock) | |
1070 (font-lock-mode 0)) | |
1071 (abbrev-mode 0) | |
1072 (buffer-disable-undo (current-buffer)) | |
1073 (setq truncate-lines nil) | |
1074 (strokes-fill-current-buffer-with-whitespace) | |
1075 (setq strokes-window-configuration (current-window-configuration)) | |
1076 (bury-buffer)))) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1077 ((strokes-window-configuration-changed-p) ; simple update |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1078 ;; update the strokes-window-configuration for this |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1079 ;; specific frame... |
19345 | 1080 (save-excursion |
1081 (save-window-excursion | |
1082 (set-window-buffer current-window strokes-buffer-name) | |
1083 (delete-other-windows) | |
1084 (strokes-fill-current-buffer-with-whitespace) | |
1085 (setq strokes-window-configuration (current-window-configuration)) | |
1086 (bury-buffer))))))) | |
1087 | |
1088 ;;;###autoload | |
1089 (defun strokes-load-user-strokes () | |
1090 "Load user-defined strokes from file named by `strokes-file'." | |
1091 (interactive) | |
1092 (cond ((and (file-exists-p strokes-file) | |
1093 (file-readable-p strokes-file)) | |
1094 (load-file strokes-file)) | |
1095 ((interactive-p) | |
1096 (error "Trouble loading user-defined strokes; nothing done")) | |
1097 (t | |
1098 (message "No user-defined strokes, sorry")))) | |
1099 | |
1100 (defun strokes-prompt-user-save-strokes () | |
1101 "Save user-defined strokes to file named by `strokes-file'." | |
1102 (interactive) | |
1103 (save-excursion | |
1104 (let ((current strokes-global-map)) | |
1105 (unwind-protect | |
1106 (progn | |
1107 (setq strokes-global-map nil) | |
1108 (strokes-load-user-strokes) | |
1109 (if (and (not (equal current strokes-global-map)) | |
1110 (or (interactive-p) | |
43233
ae3e8c9e9b87
(strokes-do-stroke, strokes-do-complex-stroke): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents:
41603
diff
changeset
|
1111 (yes-or-no-p "Save your strokes? "))) |
19345 | 1112 (progn |
1113 (require 'pp) ; pretty-print variables | |
1114 (message "Saving strokes in %s..." strokes-file) | |
1115 (get-buffer-create "*saved-strokes*") | |
1116 (set-buffer "*saved-strokes*") | |
1117 (erase-buffer) | |
1118 (emacs-lisp-mode) | |
1119 (goto-char (point-min)) | |
41570
7456b3a795c4
(strokes-prompt-user-save-strokes): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents:
31640
diff
changeset
|
1120 (insert |
46116 | 1121 ";; -*- emacs-lisp -*-\n") |
41570
7456b3a795c4
(strokes-prompt-user-save-strokes): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents:
31640
diff
changeset
|
1122 (insert (format ";;; saved strokes for %s, as of %s\n\n" |
41603
4c61a8ae179d
Fix indentation of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
41570
diff
changeset
|
1123 (user-full-name) |
4c61a8ae179d
Fix indentation of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
41570
diff
changeset
|
1124 (format-time-string "%B %e, %Y" nil))) |
19345 | 1125 (message "Saving strokes in %s..." strokes-file) |
46116 | 1126 (insert (format "(setq strokes-global-map\n'%s)" |
41603
4c61a8ae179d
Fix indentation of previous change.
Richard M. Stallman <rms@gnu.org>
parents:
41570
diff
changeset
|
1127 (pp current))) |
19345 | 1128 (message "Saving strokes in %s..." strokes-file) |
1129 (indent-region (point-min) (point-max) nil) | |
1130 (write-region (point-min) | |
1131 (point-max) | |
1132 strokes-file)) | |
1133 (message "(no changes need to be saved)"))) | |
1134 ;; protected | |
1135 (if (get-buffer "*saved-strokes*") | |
1136 (kill-buffer (get-buffer "*saved-strokes*"))) | |
1137 (setq strokes-global-map current))))) | |
1138 | |
1139 (defun strokes-toggle-strokes-buffer (&optional arg) | |
1140 "Toggle the use of the strokes buffer. | |
46116 | 1141 In other words, toggle the variable `strokes-use-strokes-buffer'. |
19345 | 1142 With ARG, use strokes buffer if and only if ARG is positive or true. |
1143 Returns value of `strokes-use-strokes-buffer'." | |
1144 (interactive "P") | |
1145 (setq strokes-use-strokes-buffer | |
1146 (if arg (> (prefix-numeric-value arg) 0) | |
1147 (not strokes-use-strokes-buffer)))) | |
1148 | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1149 (defun strokes-xpm-for-stroke (&optional stroke bufname b/w-only) |
46116 | 1150 "Create an XPM pixmap for the given STROKE in buffer ` *strokes-xpm*'. |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1151 If STROKE is not supplied, then `strokes-last-stroke' will be used. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1152 Optional BUFNAME to name something else. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1153 The pixmap will contain time information via rainbow dot colors |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1154 where each individual strokes begins. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1155 Optional B/W-ONLY non-nil will create a mono pixmap, not intended |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1156 for trying to figure out the order of strokes, but rather for reading |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1157 the stroke as a character in some language." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1158 (interactive) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1159 (save-excursion |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1160 (let ((buf (get-buffer-create (or bufname " *strokes-xpm*"))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1161 (stroke (strokes-eliminate-consecutive-redundancies |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1162 (strokes-fill-stroke |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1163 (strokes-renormalize-to-grid (or stroke |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1164 strokes-last-stroke) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1165 31)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1166 (lift-flag t) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1167 (rainbow-chars (list ?R ?O ?Y ?G ?B ?P))) ; ROYGBIV w/o indigo |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1168 (set-buffer buf) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1169 (erase-buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1170 (insert strokes-xpm-header) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1171 (loop repeat 33 do |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1172 (insert ?\") |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
1173 (insert-char ?\s 33) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1174 (insert "\",") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1175 (newline) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1176 finally |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1177 (forward-line -1) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1178 (end-of-line) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1179 (insert "}\n")) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1180 (loop for point in stroke |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1181 for x = (car-safe point) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1182 for y = (cdr-safe point) do |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1183 (cond ((consp point) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1184 ;; draw a point, and possibly a starting-point |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1185 (if (and lift-flag (not b/w-only)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1186 ;; mark starting point with the appropriate color |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1187 (let ((char (or (car rainbow-chars) ?\.))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1188 (loop for i from 0 to 2 do |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1189 (loop for j from 0 to 2 do |
46116 | 1190 (goto-line (+ 16 i y)) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1191 (forward-char (+ 1 j x)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1192 (delete-char 1) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1193 (insert char))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1194 (setq rainbow-chars (cdr rainbow-chars) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1195 lift-flag nil)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1196 ;; Otherwise, just plot the point... |
46116 | 1197 (goto-line (+ 17 y)) |
1198 (forward-char (+ 2 x)) | |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
1199 (subst-char-in-region (point) (1+ (point)) ?\s ?\*))) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1200 ((strokes-lift-p point) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1201 ;; a lift--tell the loop to X out the next point... |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1202 (setq lift-flag t)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1203 (when (interactive-p) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1204 (pop-to-buffer " *strokes-xpm*") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1205 ;; (xpm-mode 1) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1206 (goto-char (point-min)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1207 (put-image (create-image (buffer-string) 'xpm t :ascent 100) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1208 (line-end-position)))))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1209 |
46116 | 1210 ;;; Strokes Edit stuff... ### NOT IMPLEMENTED YET ### |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1211 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1212 ;;(defun strokes-edit-quit () |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1213 ;; (interactive) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1214 ;; (or (one-window-p t 0) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1215 ;; (delete-window)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1216 ;; (kill-buffer "*Strokes List*")) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1217 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1218 ;;(define-derived-mode edit-strokes-mode list-mode |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1219 ;; "Edit-Strokes" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1220 ;; "Major mode for `edit-strokes' and `list-strokes' buffers. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1221 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1222 ;;Editing commands: |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1223 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1224 ;;\\{edit-strokes-mode-map}" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1225 ;; (setq truncate-lines nil |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1226 ;; auto-show-mode nil ; don't want problems here either |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1227 ;; mode-popup-menu edit-strokes-menu) ; what about extent-specific stuff? |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1228 ;; (and (featurep 'menubar) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1229 ;; current-menubar |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1230 ;; (set (make-local-variable 'current-menubar) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1231 ;; (copy-sequence current-menubar)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1232 ;; (add-submenu nil edit-strokes-menu))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1233 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1234 ;;(let ((map edit-strokes-mode-map)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1235 ;; (define-key map "<" 'beginning-of-buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1236 ;; (define-key map ">" 'end-of-buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1237 ;; ;; (define-key map "c" 'strokes-copy-other-face) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1238 ;; ;; (define-key map "C" 'strokes-copy-this-face) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1239 ;; ;; (define-key map "s" 'strokes-smaller) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1240 ;; ;; (define-key map "l" 'strokes-larger) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1241 ;; ;; (define-key map "b" 'strokes-bold) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1242 ;; ;; (define-key map "i" 'strokes-italic) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1243 ;; (define-key map "e" 'strokes-list-edit) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1244 ;; ;; (define-key map "f" 'strokes-font) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1245 ;; ;; (define-key map "u" 'strokes-underline) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1246 ;; ;; (define-key map "t" 'strokes-truefont) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1247 ;; ;; (define-key map "F" 'strokes-foreground) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1248 ;; ;; (define-key map "B" 'strokes-background) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1249 ;; ;; (define-key map "D" 'strokes-doc-string) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1250 ;; (define-key map "a" 'strokes-global-set-stroke) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1251 ;; (define-key map "d" 'strokes-list-delete-stroke) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1252 ;; ;; (define-key map "n" 'strokes-list-next) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1253 ;; ;; (define-key map "p" 'strokes-list-prev) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1254 ;; ;; (define-key map " " 'strokes-list-next) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1255 ;; ;; (define-key map "\C-?" 'strokes-list-prev) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1256 ;; (define-key map "g" 'strokes-list-strokes) ; refresh display |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1257 ;; (define-key map "q" 'strokes-edit-quit) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1258 ;; (define-key map [(control c) (control c)] 'bury-buffer)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1259 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1260 ;;;;;###autoload |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1261 ;;(defun strokes-edit-strokes (&optional chronological strokes-map) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1262 ;; ;; ### DEAL WITH THE 2nd ARGUMENT ISSUE! ### |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1263 ;; "Edit strokes in a pop-up buffer containing strokes and their definitions. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1264 ;;If STROKES-MAP is not given, `strokes-global-map' will be used instead. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1265 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1266 ;;Editing commands: |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1267 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1268 ;;\\{edit-faces-mode-map}" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1269 ;; (interactive "P") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1270 ;; (pop-to-buffer (get-buffer-create "*Strokes List*")) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1271 ;; (reset-buffer (current-buffer)) ; handy function from minibuf.el |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1272 ;; (setq strokes-map (or strokes-map |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1273 ;; strokes-global-map |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1274 ;; (progn |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1275 ;; (strokes-load-user-strokes) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1276 ;; strokes-global-map))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1277 ;; (or chronological |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1278 ;; (setq strokes-map (sort (copy-sequence strokes-map) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1279 ;; 'strokes-alphabetic-lessp))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1280 ;; ;; (push-window-configuration) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1281 ;; (insert |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1282 ;; "Command Stroke\n" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1283 ;; "------- ------") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1284 ;; (loop for def in strokes-map |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1285 ;; for i from 0 to (1- (length strokes-map)) do |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1286 ;; (let ((stroke (car def)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1287 ;; (command-name (symbol-name (cdr def)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1288 ;; (strokes-xpm-for-stroke stroke " *strokes-xpm*") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1289 ;; (newline 2) |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
1290 ;; (insert-char ?\s 45) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1291 ;; (beginning-of-line) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1292 ;; (insert command-name) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1293 ;; (beginning-of-line) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1294 ;; (forward-char 45) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1295 ;; (set (intern (format "strokes-list-annotation-%d" i)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1296 ;; (make-annotation (make-glyph |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1297 ;; (list |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1298 ;; (vector 'xpm |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1299 ;; :data (buffer-substring |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1300 ;; (point-min " *strokes-xpm*") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1301 ;; (point-max " *strokes-xpm*") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1302 ;; " *strokes-xpm*")) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1303 ;; [string :data "[Stroke]"])) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1304 ;; (point) 'text)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1305 ;; (set-annotation-data (symbol-value (intern (format "strokes-list-annotation-%d" i))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1306 ;; def)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1307 ;; finally do (kill-region (1+ (point)) (point-max))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1308 ;; (edit-strokes-mode) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1309 ;; (goto-char (point-min))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1310 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1311 ;;;;;###autoload |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1312 ;;(defalias 'edit-strokes 'strokes-edit-strokes) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1313 |
95630
eebbd7f32937
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
94678
diff
changeset
|
1314 (defvar view-mode-map) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1315 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1316 ;;;###autoload |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1317 (defun strokes-list-strokes (&optional chronological strokes-map) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1318 "Pop up a buffer containing an alphabetical listing of strokes in STROKES-MAP. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1319 With CHRONOLOGICAL prefix arg \(\\[universal-argument]\) list strokes |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1320 chronologically by command name. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1321 If STROKES-MAP is not given, `strokes-global-map' will be used instead." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1322 (interactive "P") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1323 (setq strokes-map (or strokes-map |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1324 strokes-global-map |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1325 (progn |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1326 (strokes-load-user-strokes) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1327 strokes-global-map))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1328 (if (not chronological) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1329 ;; then alphabetize the strokes based on command names... |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1330 (setq strokes-map (sort (copy-sequence strokes-map) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1331 (function strokes-alphabetic-lessp)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1332 (let ((config (current-window-configuration))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1333 (set-buffer (get-buffer-create "*Strokes List*")) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1334 (setq buffer-read-only nil) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1335 (erase-buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1336 (insert |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1337 "Command Stroke\n" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1338 "------- ------") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1339 (loop for def in strokes-map do |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1340 (let ((stroke (car def)) |
54598
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1341 (command-name (if (symbolp (cdr def)) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1342 (symbol-name (cdr def)) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1343 (prin1-to-string (cdr def))))) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1344 (strokes-xpm-for-stroke stroke " *strokes-xpm*") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1345 (newline 2) |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
1346 (insert-char ?\s 45) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1347 (beginning-of-line) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1348 (insert command-name) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1349 (beginning-of-line) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1350 (forward-char 45) |
54598
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1351 (insert-image |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1352 (create-image (with-current-buffer " *strokes-xpm*" |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1353 (buffer-string)) |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1354 'xpm t |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1355 :color-symbols |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1356 `(("foreground" |
4ca4b1218e81
(strokes-global-set-stroke-string): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
52778
diff
changeset
|
1357 . ,(frame-parameter nil 'foreground-color)))))) |
57546
84c10e765f2b
(strokes-list-strokes): Don't try to delete char at eob.
Richard M. Stallman <rms@gnu.org>
parents:
54598
diff
changeset
|
1358 finally do (unless (eobp) |
84c10e765f2b
(strokes-list-strokes): Don't try to delete char at eob.
Richard M. Stallman <rms@gnu.org>
parents:
54598
diff
changeset
|
1359 (kill-region (1+ (point)) (point-max)))) |
43233
ae3e8c9e9b87
(strokes-do-stroke, strokes-do-complex-stroke): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents:
41603
diff
changeset
|
1360 (view-buffer "*Strokes List*" nil) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1361 (set (make-local-variable 'view-mode-map) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1362 (let ((map (copy-keymap view-mode-map))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1363 (define-key map "q" `(lambda () |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1364 (interactive) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1365 (View-quit) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1366 (set-window-configuration ,config))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1367 map)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1368 (goto-char (point-min)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1369 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1370 (defun strokes-alphabetic-lessp (stroke1 stroke2) |
79290
38be7cabc3fb
(strokes-alphabetic-lessp): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78492
diff
changeset
|
1371 "Return t if STROKE1's command name precedes STROKE2's in lexicographic order." |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1372 (let ((command-name-1 (symbol-name (cdr stroke1))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1373 (command-name-2 (symbol-name (cdr stroke2)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1374 (string-lessp command-name-1 command-name-2))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1375 |
46116 | 1376 (defvar strokes-mode-map |
1377 (let ((map (make-sparse-keymap))) | |
1378 (define-key map [(shift down-mouse-2)] 'strokes-do-stroke) | |
1379 (define-key map [(meta down-mouse-2)] 'strokes-do-complex-stroke) | |
1380 map)) | |
1381 | |
19345 | 1382 ;;;###autoload |
46116 | 1383 (define-minor-mode strokes-mode |
1384 "Toggle Strokes global minor mode.\\<strokes-mode-map> | |
1385 With ARG, turn strokes on if and only if ARG is positive. | |
1386 Strokes are pictographic mouse gestures which invoke commands. | |
1387 Strokes are invoked with \\[strokes-do-stroke]. You can define | |
1388 new strokes with \\[strokes-global-set-stroke]. See also | |
1389 \\[strokes-do-complex-stroke] for `complex' strokes. | |
19345 | 1390 |
1391 To use strokes for pictographic editing, such as Chinese/Japanese, use | |
46116 | 1392 \\[strokes-compose-complex-stroke], which draws strokes and inserts them. |
1393 Encode/decode your strokes with \\[strokes-encode-buffer], | |
1394 \\[strokes-decode-buffer]. | |
19345 | 1395 |
46116 | 1396 \\{strokes-mode-map}" |
1397 nil strokes-modeline-string strokes-mode-map | |
1398 :group 'strokes :global t | |
1399 (cond ((not (display-mouse-p)) | |
1400 (error "Can't use Strokes without a mouse")) | |
1401 (strokes-mode ; turn on strokes | |
1402 (and (file-exists-p strokes-file) | |
1403 (null strokes-global-map) | |
1404 (strokes-load-user-strokes)) | |
1405 (add-hook 'kill-emacs-query-functions | |
1406 'strokes-prompt-user-save-strokes) | |
1407 (add-hook 'select-frame-hook | |
1408 'strokes-update-window-configuration) | |
1409 (strokes-update-window-configuration)) | |
1410 (t ; turn off strokes | |
1411 (if (get-buffer strokes-buffer-name) | |
1412 (kill-buffer (get-buffer strokes-buffer-name))) | |
1413 (remove-hook 'select-frame-hook | |
1414 'strokes-update-window-configuration)))) | |
1415 | |
19345 | 1416 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1417 ;;;; strokes-xpm stuff (later may be separate)... |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1418 |
46116 | 1419 ;; This is the stuff that will eventually be used for composing letters in |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1420 ;; any language, compression, decompression, graphics, editing, etc. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1421 |
63219
cf36e45beb9c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-383
Miles Bader <miles@gnu.org>
parents:
57743
diff
changeset
|
1422 (defface strokes-char '((t (:background "lightgray"))) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1423 "Face for strokes characters." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1424 :version "21.1" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1425 :group 'strokes) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1426 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1427 (put 'strokes 'char-table-extra-slots 0) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1428 (defconst strokes-char-table (make-char-table 'strokes) ; |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1429 "The table which stores values for the character keys.") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1430 (aset strokes-char-table ?0 0) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1431 (aset strokes-char-table ?1 1) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1432 (aset strokes-char-table ?2 2) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1433 (aset strokes-char-table ?3 3) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1434 (aset strokes-char-table ?4 4) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1435 (aset strokes-char-table ?5 5) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1436 (aset strokes-char-table ?6 6) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1437 (aset strokes-char-table ?7 7) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1438 (aset strokes-char-table ?8 8) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1439 (aset strokes-char-table ?9 9) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1440 (aset strokes-char-table ?a 10) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1441 (aset strokes-char-table ?b 11) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1442 (aset strokes-char-table ?c 12) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1443 (aset strokes-char-table ?d 13) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1444 (aset strokes-char-table ?e 14) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1445 (aset strokes-char-table ?f 15) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1446 (aset strokes-char-table ?g 16) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1447 (aset strokes-char-table ?h 17) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1448 (aset strokes-char-table ?i 18) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1449 (aset strokes-char-table ?j 19) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1450 (aset strokes-char-table ?k 20) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1451 (aset strokes-char-table ?l 21) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1452 (aset strokes-char-table ?m 22) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1453 (aset strokes-char-table ?n 23) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1454 (aset strokes-char-table ?o 24) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1455 (aset strokes-char-table ?p 25) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1456 (aset strokes-char-table ?q 26) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1457 (aset strokes-char-table ?r 27) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1458 (aset strokes-char-table ?s 28) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1459 (aset strokes-char-table ?t 29) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1460 (aset strokes-char-table ?u 30) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1461 (aset strokes-char-table ?v 31) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1462 (aset strokes-char-table ?w 32) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1463 (aset strokes-char-table ?x 33) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1464 (aset strokes-char-table ?y 34) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1465 (aset strokes-char-table ?z 35) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1466 (aset strokes-char-table ?A 36) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1467 (aset strokes-char-table ?B 37) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1468 (aset strokes-char-table ?C 38) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1469 (aset strokes-char-table ?D 39) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1470 (aset strokes-char-table ?E 40) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1471 (aset strokes-char-table ?F 41) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1472 (aset strokes-char-table ?G 42) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1473 (aset strokes-char-table ?H 43) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1474 (aset strokes-char-table ?I 44) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1475 (aset strokes-char-table ?J 45) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1476 (aset strokes-char-table ?K 46) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1477 (aset strokes-char-table ?L 47) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1478 (aset strokes-char-table ?M 48) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1479 (aset strokes-char-table ?N 49) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1480 (aset strokes-char-table ?O 50) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1481 (aset strokes-char-table ?P 51) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1482 (aset strokes-char-table ?Q 52) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1483 (aset strokes-char-table ?R 53) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1484 (aset strokes-char-table ?S 54) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1485 (aset strokes-char-table ?T 55) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1486 (aset strokes-char-table ?U 56) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1487 (aset strokes-char-table ?V 57) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1488 (aset strokes-char-table ?W 58) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1489 (aset strokes-char-table ?X 59) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1490 (aset strokes-char-table ?Y 60) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1491 (aset strokes-char-table ?Z 61) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1492 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1493 (defconst strokes-base64-chars |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1494 ;; I wanted to make this a vector of individual like (vector ?0 |
46116 | 1495 ;; ?1 ?2 ...), but `concat' refuses to accept single |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1496 ;; characters. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1497 (vector "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1498 "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1499 "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1500 "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1501 "T" "U" "V" "W" "X" "Y" "Z") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1502 ;; (vector [?0] [?1] [?2] [?3] [?4] [?5] [?6] [?7] [?8] [?9] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1503 ;; [?a] [?b] [?c] [?d] [?e] [?f] [?g] [?h] [?i] [?j] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1504 ;; [?k] [?l] [?m] [?n] [?o] [?p] [?q] [?r] [?s] [?t] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1505 ;; [?u] [?v] [?w] [?x] [?y] [?z] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1506 ;; [?A] [?B] [?C] [?D] [?E] [?F] [?G] [?H] [?I] [?J] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1507 ;; [?K] [?L] [?M] [?N] [?O] [?P] [?Q] [?R] [?S] [?T] |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1508 ;; [?U] [?V] [?W] [?X] [?Y] [?Z]) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1509 "Character vector for fast lookup of base-64 encoding of numbers in [0,61].") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1510 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1511 (defsubst strokes-xpm-char-on-p (char) |
46116 | 1512 "Non-nil if CHAR represents an `on' bit in the XPM." |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1513 (eq char ?*)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1514 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1515 (defsubst strokes-xpm-char-bit-p (char) |
46116 | 1516 "Non-nil if CHAR represents an `on' or `off' bit in the XPM." |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
1517 (or (eq char ?\s) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1518 (eq char ?*))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1519 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1520 ;;(defsubst strokes-xor (a b) ### Should I make this an inline function? ### |
78492
7c8949dbfa0d
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78236
diff
changeset
|
1521 ;; "T if one and only one of A and B is non-nil; otherwise, returns nil. |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1522 ;;NOTE: Don't use this as a numeric xor since it treats all non-nil |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1523 ;; values as t including `0' (zero)." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1524 ;; (eq (null a) (not (null b)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1525 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1526 (defsubst strokes-xpm-encode-length-as-string (length) |
46116 | 1527 "Given some LENGTH in [0,62) do a fast lookup of its encoding." |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1528 (aref strokes-base64-chars length)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46327
diff
changeset
|
1529 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1530 (defsubst strokes-xpm-decode-char (character) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1531 "Given a CHARACTER, do a fast lookup to find its corresponding integer value." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1532 (aref strokes-char-table character)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46327
diff
changeset
|
1533 |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1534 (defun strokes-xpm-to-compressed-string (&optional xpm-buffer) |
46116 | 1535 "Convert XPM in XPM-BUFFER to compressed string representing the stroke. |
1536 XPM-BUFFER defaults to ` *strokes-xpm*'." | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1537 (save-excursion |
46116 | 1538 (set-buffer (setq xpm-buffer (or xpm-buffer " *strokes-xpm*"))) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1539 (goto-char (point-min)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1540 (search-forward "/* pixels */") ; skip past header junk |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1541 (forward-char 2) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1542 ;; a note for below: |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1543 ;; the `current-char' is the char being counted -- NOT the char at (point) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1544 ;; which happens to be called `char-at-point' |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1545 (let ((compressed-string "+/") ; initialize the output |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1546 (count 0) ; keep a current count of |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1547 ; `current-char' |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1548 (last-char-was-on-p t) ; last entered stream |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1549 ; represented `on' bits |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1550 (current-char-is-on-p nil) ; current stream represents `on' bits |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1551 (char-at-point (char-after))) ; read the first char |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1552 (while (not (eq char-at-point ?})) ; a `}' denotes the |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1553 ; end of the pixmap |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1554 (cond ((zerop count) ; must restart counting |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1555 ;; check to see if the `char-at-point' is an actual pixmap bit |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1556 (when (strokes-xpm-char-bit-p char-at-point) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1557 (setq count 1 |
46116 | 1558 current-char-is-on-p (strokes-xpm-char-on-p char-at-point))) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1559 (forward-char 1)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1560 ((= count 61) ; maximum single char's |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1561 ; encoding length |
46116 | 1562 (setq compressed-string |
1563 (concat compressed-string | |
1564 ;; add a zero-length encoding when | |
1565 ;; necessary | |
1566 (when (eq last-char-was-on-p | |
1567 current-char-is-on-p) | |
1568 ;; "0" | |
1569 (strokes-xpm-encode-length-as-string 0)) | |
1570 (strokes-xpm-encode-length-as-string 61)) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1571 last-char-was-on-p current-char-is-on-p |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1572 count 0)) ; note that we just set |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1573 ; count=0 and *don't* advance |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1574 ; (point) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1575 ((strokes-xpm-char-bit-p char-at-point) ; an actual xpm bit |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1576 (if (eq current-char-is-on-p |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1577 (strokes-xpm-char-on-p char-at-point)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1578 ;; yet another of the same bit-type, so we continue |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1579 ;; counting... |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1580 (progn |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1581 (incf count) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1582 (forward-char 1)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1583 ;; otherwise, it's the opposite bit-type, so we do a |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1584 ;; write and then restart count ### NOTE (for myself |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1585 ;; to be aware of) ### I really should advance |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1586 ;; (point) in this case instead of letting another |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1587 ;; iteration go through and letting the case: count=0 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1588 ;; take care of this stuff for me. That's why |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1589 ;; there's no (forward-char 1) below. |
46116 | 1590 (setq compressed-string |
1591 (concat compressed-string | |
1592 ;; add a zero-length encoding when | |
1593 ;; necessary | |
1594 (when (eq last-char-was-on-p | |
1595 current-char-is-on-p) | |
1596 ;; "0" | |
1597 (strokes-xpm-encode-length-as-string 0)) | |
1598 (strokes-xpm-encode-length-as-string count)) | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1599 count 0 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1600 last-char-was-on-p current-char-is-on-p))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1601 (t ; ELSE it's some other useless |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1602 ; char, like `"' or `,' |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1603 (forward-char 1))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1604 (setq char-at-point (char-after))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1605 (concat compressed-string |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1606 (when (> count 0) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1607 (concat (when (eq last-char-was-on-p |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1608 current-char-is-on-p) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1609 ;; "0" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1610 (strokes-xpm-encode-length-as-string 0)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1611 (strokes-xpm-encode-length-as-string count))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1612 "/")))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1613 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1614 ;;;###autoload |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1615 (defun strokes-decode-buffer (&optional buffer force) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1616 "Decode stroke strings in BUFFER and display their corresponding glyphs. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1617 Optional BUFFER defaults to the current buffer. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1618 Optional FORCE non-nil will ignore the buffer's read-only status." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1619 (interactive) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1620 ;; (interactive "*bStrokify buffer: ") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1621 (save-excursion |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1622 (set-buffer (setq buffer (get-buffer (or buffer (current-buffer))))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1623 (when (or (not buffer-read-only) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1624 force |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1625 inhibit-read-only |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1626 (y-or-n-p |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1627 (format "Buffer %s is read-only. Strokify anyway? " buffer))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1628 (let ((inhibit-read-only t)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1629 (message "Strokifying %s..." buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1630 (goto-char (point-min)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1631 (let (ext string image) |
46116 | 1632 ;; The comment below is what I'd have to do if I wanted to |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1633 ;; deal with random newlines in the midst of the compressed |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1634 ;; strings. If I do this, I'll also have to change |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1635 ;; `strokes-xpm-to-compress-string' to deal with the newline, |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1636 ;; and possibly other whitespace stuff. YUCK! |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1637 ;; (while (re-search-forward "\\+/\\(\\w\\|\\)+/" nil t nil (get-buffer buffer)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1638 (while (with-current-buffer buffer |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1639 (when (re-search-forward "\\+/\\(\\w+\\)/" nil t nil) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1640 (setq string (match-string 1)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1641 (goto-char (match-end 0)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1642 (replace-match " ") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1643 t)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1644 (strokes-xpm-for-compressed-string string " *strokes-xpm*") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1645 (setq image (create-image (with-current-buffer " *strokes-xpm*" |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1646 (buffer-string)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1647 'xpm t)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1648 (insert-image image |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1649 (propertize " " |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1650 'type 'stroke-glyph |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1651 'stroke-glyph image |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1652 'data string)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1653 (message "Strokifying %s...done" buffer))))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1654 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1655 (defun strokes-encode-buffer (&optional buffer force) |
46116 | 1656 "Convert the glyphs in BUFFER to their base-64 ASCII representations. |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1657 Optional BUFFER defaults to the current buffer. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1658 Optional FORCE non-nil will ignore the buffer's read-only status." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1659 ;; ### NOTE !!! ### (for me) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1660 ;; For later on, you can/should make the inserted strings atomic |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1661 ;; extents, so that the users have a clue that they shouldn't be |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1662 ;; editing inside them. Plus, if you make them extents, you can |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1663 ;; very easily just hide the glyphs, so if you unstrokify, and the |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1664 ;; restrokify, then those that already are glyphed don't need to be |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1665 ;; re-calculated, etc. It's just nicer that way. The only things |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1666 ;; to worry about is cleanup (i.e. do the glyphs get gc'd when the |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1667 ;; buffer is killed? |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1668 ;; (interactive "*bUnstrokify buffer: ") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1669 (interactive) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1670 (save-excursion |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1671 (set-buffer (setq buffer (or buffer (current-buffer)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1672 (when (or (not buffer-read-only) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1673 force |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1674 inhibit-read-only |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1675 (y-or-n-p |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1676 (format "Buffer %s is read-only. Encode anyway? " buffer))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1677 (message "Encoding strokes in %s..." buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1678 ;; (map-extents |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1679 ;; (lambda (ext buf) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1680 ;; (when (eq (extent-property ext 'type) 'stroke-glyph) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1681 ;; (goto-char (extent-start-position ext)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1682 ;; (delete-char 1) ; ### What the hell do I do here? ### |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1683 ;; (insert "+/" (extent-property ext 'data) "/") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1684 ;; (delete-extent ext)))))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1685 (let ((inhibit-read-only t) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1686 (start nil) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1687 glyph) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1688 (while (or (and (bobp) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1689 (get-text-property (point) 'type)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1690 (setq start (next-single-property-change (point) 'type))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1691 (when (eq 'stroke-glyph (get-text-property (point) 'type)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1692 (goto-char start) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1693 (setq start (point-marker) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1694 glyph (get-text-property start 'display)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1695 (insert "+/" (get-text-property (point) 'data) ?/) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1696 (delete-char 1) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1697 (add-text-properties start (point) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1698 (list 'type 'stroke-string |
63219
cf36e45beb9c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-383
Miles Bader <miles@gnu.org>
parents:
57743
diff
changeset
|
1699 'face 'strokes-char |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1700 'stroke-glyph glyph |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1701 'display nil)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1702 (message "Encoding strokes in %s...done" buffer))))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1703 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1704 (defun strokes-xpm-for-compressed-string (compressed-string &optional bufname) |
46116 | 1705 "Convert the stroke represented by COMPRESSED-STRING into an XPM. |
1706 Store XPM in buffer BUFNAME if supplied \(default is ` *strokes-xpm*'\)" | |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1707 (save-excursion |
46116 | 1708 (or bufname (setq bufname " *strokes-xpm*")) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1709 (set-buffer (get-buffer-create bufname)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1710 (erase-buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1711 (insert compressed-string) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1712 (goto-char (point-min)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1713 (let ((current-char-is-on-p nil)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1714 (while (not (eobp)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1715 (insert-char |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1716 (if current-char-is-on-p |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1717 ?* |
64023
22c5a8628828
(strokes): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63219
diff
changeset
|
1718 ?\s) |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1719 (strokes-xpm-decode-char (char-after))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1720 (delete-char 1) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1721 (setq current-char-is-on-p (not current-char-is-on-p))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1722 (goto-char (point-min)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1723 (loop repeat 33 do |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1724 (insert ?\") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1725 (forward-char 33) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1726 (insert "\",\n")) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1727 (goto-char (point-min)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1728 (insert strokes-xpm-header)))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1729 |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1730 ;;;###autoload |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1731 (defun strokes-compose-complex-stroke () |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1732 ;; ### NOTE !!! ### |
46116 | 1733 ;; Even though we don't have lexical scoping, it's somewhat ugly how I |
31640
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1734 ;; pass around variables in the global name space. I can/should |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1735 ;; change this. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1736 "Read a complex stroke and insert its glyph into the current buffer." |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1737 (interactive "*") |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1738 (let ((strokes-grid-resolution 33)) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1739 (strokes-read-complex-stroke) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1740 (strokes-xpm-for-stroke nil " *strokes-xpm*" t) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1741 (insert (strokes-xpm-to-compressed-string " *strokes-xpm*")) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1742 (strokes-decode-buffer) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1743 ;; strokes-decode-buffer does a save-excursion. |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1744 (forward-char))) |
27d41d6ec45d
Sync with maintainer's current version with changes
Dave Love <fx@gnu.org>
parents:
30540
diff
changeset
|
1745 |
85835
f3bfe76fe370
(strokes-alphabetic-lessp): Simplify. Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78492
diff
changeset
|
1746 (defun strokes-unload-function () |
f3bfe76fe370
(strokes-alphabetic-lessp): Simplify. Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78492
diff
changeset
|
1747 "Unload the Strokes library." |
46116 | 1748 (strokes-mode -1) |
85835
f3bfe76fe370
(strokes-alphabetic-lessp): Simplify. Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78492
diff
changeset
|
1749 ;; continue standard unloading |
f3bfe76fe370
(strokes-alphabetic-lessp): Simplify. Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78492
diff
changeset
|
1750 nil) |
57546
84c10e765f2b
(strokes-list-strokes): Don't try to delete char at eob.
Richard M. Stallman <rms@gnu.org>
parents:
54598
diff
changeset
|
1751 |
46116 | 1752 (run-hooks 'strokes-load-hook) |
19345 | 1753 (provide 'strokes) |
1754 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
1755 ;; arch-tag: 8377f60e-43fb-467a-bbcd-2774f91f833e |
19345 | 1756 ;;; strokes.el ends here |