annotate lisp/modes/strokes.el @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 6075d714658b
children b405438285a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1 ;;; strokes.el -- Control XEmacs through mouse strokes --
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2 ;; Mon Jul 25 12:40:41 EDT 1997
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
3
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
4 ;; Copyright (C) 1997 Free Software Foundation, Inc.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
5
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
6 ;; Author: David Bakhash <cadet@mit.edu>
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
7 ;; Maintainer: David Bakhash <cadet@mit.edu>
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
8 ;; Version: 2.4-beta
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
9 ;; Created: 12 April 1997
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
10 ;; Keywords: lisp, mouse, extensions
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
11
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
12 ;; This file is part of XEmacs.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
13
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
14 ;; XEmacs is free software; you can redistribute it and/or modify it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
15 ;; under the terms of the GNU General Public License as published by
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2 of the License, or
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
17 ;; (at your option) any later version.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
18
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
19 ;; XEmacs program is distributed in the hope that it will be useful,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
22 ;; General Public License for more details.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
23
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
25 ;; along with XEmacs; see the file COPYING. If not, write to the Free
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
26 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
27 ;; 02111-1307, USA.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
28
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
29 ;;; Synched up with: Not in FSF.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
30
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
31 ;;; Commentary:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
32
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
33 ;; This package is written for for XEmacs v19.15 and up. This is the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
34 ;; strokes package. It is intended to allow the user to control
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
35 ;; XEmacs by means of mouse strokes. Once strokes is loaded, you can
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
36 ;; always get help be invoking `strokes-help':
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
37
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
38 ;; > M-x strokes-help
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
39
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
40 ;; and you can learn how to use the package. A mouse stroke, for now,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
41 ;; can be defined as holding the middle button, for instance, and then
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
42 ;; moving the mouse in whatever pattern you wish, which you have set
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
43 ;; XEmacs to understand as mapping to a given command. For example,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
44 ;; you may wish the have a mouse stroke that looks like a capital `C'
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
45 ;; which means `copy-region-as-kill'. Treat strokes just like you do
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
46 ;; key bindings. For example, XEmacs sets key bindings globally with
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
47 ;; the `global-set-key' command. Likewise, you can do
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
48
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
49 ;; > M-x global-set-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
50
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
51 ;; to interactively program in a stroke. It would be wise to set the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
52 ;; first one to this very command, so that from then on, you invoke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
53 ;; `global-set-stroke' with a stroke. likewise, there may eventually
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
54 ;; be a `local-set-stroke' command, also analogous to `local-set-key'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
55
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
56 ;; You can always unset the last stroke definition with the command
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
57
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
58 ;; > M-x strokes-unset-last-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
59
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
60 ;; and the last stroke that was added to `strokes-global-map' will be
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
61 ;; removed.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
62
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
63 ;; Other analogies between strokes and key bindings are as follows:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
64
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
65 ;; 1) To describe a stroke binding, you can type
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
66
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
67 ;; > M-x describe-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
68
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
69 ;; analogous to `describe-key'. It's also wise to have a
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
70 ;; stroke, like an `h', for help, or a `?', mapped to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
71 ;; `describe-stroke'.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
72
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
73 ;; 2) stroke bindings are set internally through the Lisp function
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
74 ;; `define-stroke', similar to the `define-key' function. some
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
75 ;; examples for a 3x3 stroke grid would be
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
76
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
77 ;; (define-stroke c-mode-stroke-map
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
78 ;; '((0 . 0) (1 . 1) (2 . 2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
79 ;; 'kill-region)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
80 ;; (define-stroke strokes-global-map
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
81 ;; '((0 . 0) (0 . 1) (0 . 2) (1 . 2) (2 . 2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
82 ;; 'list-buffers)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
83
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
84 ;; however, if you would probably just have the user enter in
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
85 ;; the stroke interactively and then set the stroke to whatever
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
86 ;; he/she entered. The Lisp function to interactively read a
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
87 ;; stroke is `strokes-read-stroke'. This is especially helpful
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
88 ;; when you're on a fast computer that can handle a 9x9 stroke
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
89 ;; grid.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
90
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
91 ;; NOTE: only global stroke bindings are currently implemented,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
92 ;; however mode- and buffer-local stroke bindings may eventually
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
93 ;; be implemented in a future version.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
94
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
95 ;; The important variables to be aware of for this package are listed
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
96 ;; below. They can all be altered through the customizing package via
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
97
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
98 ;; > M-x customize
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
99
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
100 ;; and customizing the group named `strokes'. You can also read
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
101 ;; documentation on the variables there.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
102
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
103 ;; `strokes-minimum-match-score' (determines the threshold of error
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
104 ;; that makes a stroke acceptable or unacceptable. If your strokes
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
105 ;; aren't matching, then you should raise this variable.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
106
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
107 ;; `strokes-grid-resolution' (determines the grid dimensions that you
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
108 ;; use when defining/reading strokes. The finer the grid your
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
109 ;; computer can handle, the more you can do, but even a 3x3 grid is
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
110 ;; pretty cool.) The default value (7) should be fine for most decent
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
111 ;; computers. NOTE: This variable should not be set to a number less
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
112 ;; than 3.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
113
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
114 ;; `strokes-display-strokes-buffer' will allow you to hide the strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
115 ;; buffer when doing simple strokes. This is a speedup for slow
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
116 ;; computers as well as people who don't want to see their strokes.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
117
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
118 ;; If you find that your mouse is accelerating too fast, you can
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
119 ;; execute the UNIX X command to slow it down. A good possibility is
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
120
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
121 ;; % xset m 5/4 8
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
122
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
123 ;; which seems, heuristically, to work okay, without much disruption.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
124
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
125 ;; Whenever you load in the strokes package, you will be able to save
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
126 ;; what you've done upon exiting XEmacs. You can also do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
127
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
128 ;; > M-x save-strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
129
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
130 ;; and it will save your strokes in ~/.strokes, or you may wish to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
131 ;; change this by setting the variable `strokes-file'.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
132
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
133 ;; Note that internally, all of the routines that are part of this
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
134 ;; package are able to deal with complex strokes, as they are a
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
135 ;; superset of simple strokes. However, the default of this package
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
136 ;; will map mouse button2 to the command `strokes-do-stroke', and NOT
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
137 ;; `strokes-do-complex-stroke'. If you wish to use complex strokes,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
138 ;; you will have to override this key mapping. Complex strokes are
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
139 ;; terminated with mouse button3. The strokes package will not
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
140 ;; interfere with `mouse-yank', but you may want to examine how this
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
141 ;; is done (see the variable `strokes-click-command')
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
142
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
143 ;; To get strokes to work as part of your your setup, then you'll have
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
144 ;; put the strokes package in your load-path (preferably
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
145 ;; byte-compiled) and then add the following to your .emacs file (or
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
146 ;; wherever you put XEmacs-specific startup preferences):
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
147
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
148 ;; (if window-system (require 'strokes))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
149
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
150 ;; Once loaded, you can start stroking. You can also toggle between
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
151 ;; strokes mode by simple typing
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
152
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
153 ;; > M-x strokes-mode
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
154
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
155 ;; I am now in the process of porting this package to Emacs. I also
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
156 ;; hope that, with the help of others, this package will be useful in
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
157 ;; entering in pictographic-like language text using the mouse
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
158 ;; (i.e. Korean). Japanese and Chinese are a bit trickier, but I'm
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
159 ;; sure that with help it can be done. The next version will allow
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
160 ;; the user to enter strokes which "remove the pencil from the paper"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
161 ;; so to speak, so one character can have multiple strokes.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
162
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
163 ;; You can read more about strokes at:
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
164
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
165 ;; http://www.mit.edu/people/cadet/strokes-help.html
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
166
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
167 ;; If you're interested in using strokes for writing English into
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
168 ;; XEmacs using strokes, then you'll want to read about it on the web
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
169 ;; page above or just download from
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
170 ;; http://www.mit.edu/people/cadet/strokes-abc.el, which is nothing
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
171 ;; but a file with some helper commands for inserting alphanumerics
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
172 ;; and punctuation.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
173
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
174 ;; Great thanks to Rob Ristroph for his generosity in letting me use
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
175 ;; his PC to develop this, Jason Johnson for his help in algorithms,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
176 ;; Euna Kim for her help in Korean, and massive thanks to the helpful
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
177 ;; guys on the help instance on athena (zeno, jered, amu, gsstark,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
178 ;; ghudson, etc) Special thanks to Steve Baur, Kyle Jones, and Hrvoje
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
179 ;; Niksic for all their help. And special thanks to Dave Gillespie
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
180 ;; for all the elisp help--he is responsible for helping me use the cl
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
181 ;; macros at (near) max speed.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
182
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
183 ;; Tasks: (what I'm getting ready for future version)...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
184 ;; 2) use 'strokes-read-complex-stroke for korean, etc.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
185 ;; 4) buffer-local 'strokes-local-map, and mode-stroke-maps would be nice
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
186 ;; 6) add some hooks, like `strokes-read-stroke-hook'
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
187 ;; 7) See what people think of the factory settings. Should I change
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
188 ;; them? They're all pretty arbitrary in a way. I guess they
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
189 ;; should be minimal, but computers are getting lots faster, and
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
190 ;; if I choose the defaults too conservatively, then strokes will
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
191 ;; surely disappoint some people on decent machines (until they
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
192 ;; figure out M-x customize). I need feedback.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
193 ;; Other: I always have the most beta version of strokes, so if you
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
194 ;; want it just let me know.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
195
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
196 ;;; Change Log:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
197
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
198 ;; 1.3: provided user variable `strokes-use-strokes-buffer' to let
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
199 ;; users hide the strokes and strokes buffer when entering simple
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
200 ;; strokes.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
201 ;; 1.3: cleaned up most leaks.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
202 ;; 1.3: with Jari Aalto's help, cleaned up overall program.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
203 ;; 1.3: added `strokes-help' for help on strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
204 ;; 1.3: fixed 'strokes-load-hook bug
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
205 ;; 1.3: email address change: now <cadet@mit.edu>
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
206 ;; 1.3: added `strokes-report-bug' based on efs/dired's
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
207 ;; `dired-report-bug'
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
208 ;; 1.3: added more dialog-box queries for mouse-event stuff.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
209 ;; 1.4: allowed strokes to invoke kbd macros as well (thanks gsstark!)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
210 ;; 2.0: fixed up ordering of certain functions.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
211 ;; 2.0: fixed bug applying to strokes in dedicated and minibuffer
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
212 ;; windows.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
213 ;; 2.0: punted the C-h way of invoking strokes help routines.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
214 ;; 2.0: fixed `strokes-define-stroke' so it would error check against
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
215 ;; defining strokes that were too short (really clicks) 2.0:
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
216 ;; added `strokes-toggle-strokes-buffer' interactive function
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
217 ;; 2.0: added `customize' support, thanks to patch from Hrvoje
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
218 ;; (thanks)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
219 ;; 2.1: strokes no longer forces `mouse-yank-at-point' to t on
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
220 ;; mouse-yank (i.e. `mouse-yank-at-point' is up to you again)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
221 ;; 2.1: toggling strokes-mode off and then back on no longer deletes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
222 ;; the strokes that you programmed in but didn't save before
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
223 ;; toggling off strokes-mode.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
224 ;; 2.1: advised may functions for modes like VM and w3 so that they
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
225 ;; too can use strokes, while still maintaining old button2
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
226 ;; functionality.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
227 ;; 2.1: with Steve's help, got the autoload for `strokes-mode' and
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
228 ;; fixed up the package so loading it does not enable strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
229 ;; until user calls `strokes-mode'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
230 ;; 2.2: made sure that abbrev-mode was off in the ` *strokes*' buffer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
231 ;; 2.2: added more dired advice for mouse permissions commands
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
232 ;; 2.2: added some checks to see if saving strokes is really necessary
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
233 ;; so the user doesn't get prompted aimlessly.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
234 ;; 2.2: change the `strokes-lift' symbol to a keyword of value
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
235 ;; `:strokes-lift' for legibility. IF YOUR OLD STROKES DON'T
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
236 ;; WORK, THIS IS PROBABLY WHY.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
237 ;; 2.2: I might have to change this back to `'strokes-lift' because
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
238 ;; the keyword fails in emacs, though I don't know why.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
239 ;; 2.2: `strokes-describe-stroke' is nicer during recursive edits
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
240 ;; 2.2: provided `strokes-fill-stroke' to fill in empty spaces of strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
241 ;; as an important step towards platform (speed) independence.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
242 ;; Because of this, I moved the global setting of
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
243 ;; `strokes-last-stroke' from
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
244 ;; `strokes-eliminate-consecutive-redundancies' to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
245 ;; `strokes-fill-stroke' since the latter comes later in
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
246 ;; processing a user stroke.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
247 ;; 2.2: Finally changed the defaults, so now `strokes-grid-resolution' is 9
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
248 ;; and `strokes-minimum-match-score' is 1000 by default. This
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
249 ;; will surely mess some people up, but if so, just set it back
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
250 ;; w/ M-x customize.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
251 ;; 2.2: Fixed up the mechanism for updating the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
252 ;; `strokes-window-configuration'. Now it only uses one function
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
253 ;; (`strokes-update-window-configuration') which does it all, and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
254 ;; much more efficiently (thanks RMS!).
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
255 ;; 2.2 Fixed up the appearance of the *strokes* buffer so that there
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
256 ;; are no ugly line truncations, and I got rid of the bug which
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
257 ;; would draw the stroke on the wrong line. I still wish that
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
258 ;; `event-closest-point' was smarter. In fact,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
259 ;; `event-closest-point' does *not* do what its name suggests.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
260 ;; 2.3 Added more to `strokes-update-window-configuration' so it goes
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
261 ;; to hell less often
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
262 ;; 2.3 `strokes-mode' no longer will undefined keys unless it's sure
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
263 ;; that the user had had them mapped to a strokes command.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
264 ;; 2.3 Added more magic autoload statements so strokes work more
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
265 ;; smoothly. similarly, I made strokes-mode turn itself on when
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
266 ;; the user defines a stroke (thanks Hrvoje).
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
267 ;; 2.3 Added "Strokes" to the modeline when strokes is on, and allow
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
268 ;; toggling strokes with mouse button2.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
269 ;; 2.3 Added `list-strokes', which is a really nice function which
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
270 ;; graphically lists all the strokes that the user has defined
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
271 ;; and their corresponding commands. `list-strokes' will
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
272 ;; appropriately colorize the pixmaps to display some time info.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
273 ;; 2.4 Added all new functionality to strokes by allowing the user to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
274 ;; enter strokes in graphically into XEmacs, allowing true graphic
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
275 ;; editing, Chinese/Japanese, etc. User simply uses C-button2 to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
276 ;; draw strokes (function: `strokes-compose-complex-stroke'). Then
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
277 ;; after the glyph gets inserted into the current buffer at (point),
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
278 ;; the use can treat that glyph as any other character, and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
279 ;; copy/paste/delete/undo, etc. Also, when the user would like to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
280 ;; save/send the glyphs (to other XEmacs users, of course), he/she
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
281 ;; can use the helper functions:
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
282 ;;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
283 ;; i. M-x strokes-encode-buffer -- Ascii-encodes and compresses
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
284 ;; strokes to base-64.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
285 ;; ii. M-x strokes-decode-buffer -- Decodes ascii-encoded strokes
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
286 ;; back into glyphs.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
287 ;; 2.4 With help from Kyle fixed the itimer (timeout event) bug, where I
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
288 ;; forgot to check for timeouts.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
289 ;; 2.4 Around this time, made a successful port of strokes.el for emacs.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
290 ;; 2.4 Made added `strokes-xpm-header' as a variable.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
291 ;; 2.4 Changed the default value of `strokes-character' from `o' to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
292 ;; `@' since it looks nicer when drawn.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
293 ;; 2.4 Changed `strokes-click-p' so that it considers only a stroke
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
294 ;; of length <= 1 a click, as opposed to a length 2 being a
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
295 ;; click.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
296 ;; 2.4 Totally made the the function `strokes-read-stroke' (and a bit
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
297 ;; on `strokes-read-complex-stroke') more efficient and robust,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
298 ;; making the former use the optional event passed to it, and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
299 ;; thus not losing the first mouse event position when reading a
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
300 ;; stroke on the fly.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
301 ;; 2.4 Finally fixed the mouse-yank / mouse-yank-at-point bug (after
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
302 ;; months of struggling with it). I simply inserted a (sit-for 0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
303 ;; before the (command-execute strokes-click-command) and that
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
304 ;; patched it up. I'd thought that it was a kludge, but I later
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
305 ;; found out that it wasn't, as redisplay has several states, and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
306 ;; command-execute often must decide which of two states must be
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
307 ;; considered when executing a command. The (sit-for 0) merely
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
308 ;; allowed redisplay to be sure to wait for the ` *strokes*'
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
309 ;; buffer to vanish before executing the command (thanks for the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
310 ;; explanation of why my frobbing worked Kyle). Fixing this bug
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
311 ;; also (magically) fixed the bug which prevented strokes from
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
312 ;; executing a stroke in a mode which had it's own binding for
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
313 ;; button-2, such as w3 when the variable
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
314 ;; `strokes-use-strokes-buffer' is non-nil. It used to be that
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
315 ;; if you chose to view your strokes, then you couldn't use
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
316 ;; strokes properly in modes like VM or w3. Now you can!
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
317 ;; 2.4 Replaced `kill-emacs-hook' with `kill-emacs-query-functions'
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
318 ;; for prompting the user to save his/her strokes, since
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
319 ;; `kill-emacs-hook' was not the right hook to use.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
320 ;; 2.4 Having `strokes-update-window-configuration' bound to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
321 ;; `select-frame-hook' was a heavy function for such a commonly
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
322 ;; run hook -- especially since event-Xt.c (?) will add the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
323 ;; eval-event to the event queue. So the effect was that if XEmacs
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
324 ;; was doing an interpreter-intensive task while the user (re)selected
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
325 ;; the frame n times, then the intensive window config updating
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
326 ;; took place n times. So to deal, I put in some extra checks to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
327 ;; see if the frame parameters really changed, making an update
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
328 ;; worthwhile. See `strokes-update-window-configuration-plist'.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
329
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
330 ;;; Code:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
331
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
332 ;;; Requirements and provisions...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
333
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
334 (autoload 'reporter-submit-bug-report "reporter")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
335 (autoload 'mail-position-on-field "sendmail")
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
336 (eval-when-compile
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
337 (mapc 'require '(xpm-mode pp annotations reporter advice view-less)))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
338
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
339 ;;; Constants...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
340
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
341 (defconst strokes-version "2.4-beta")
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
342
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
343 (defconst strokes-bug-address "cadet@mit.edu")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
344
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
345 (defconst strokes-lift :strokes-lift
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
346 "Symbol representing a stroke lift event for complex strokes.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
347 Complex strokes are those which contain two or more simple strokes.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
348 This will be useful for when XEmacs understands Chinese.")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
349
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
350 (defconst strokes-xpm-header "/* XPM */
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
351 static char * stroke_xpm[] = {
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
352 /* width height ncolors cpp [x_hot y_hot] */
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
353 \"33 33 9 1 26 23\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
354 /* colors */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
355 \" c none s none\",
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
356 \"* c #000000 s foreground\",
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
357 \"R c #FFFF00000000\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
358 \"O c #FFFF80000000\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
359 \"Y c #FFFFFFFF0000\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
360 \"G c #0000FFFF0000\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
361 \"B c #00000000FFFF\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
362 \"P c #FFFF0000FFFF\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
363 \". c #45458B8B0000\",
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
364 /* pixels */\n"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
365 "The header to all xpm buffers created by strokes")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
366
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
367 ;;; user variables...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
368
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
369 (defgroup strokes nil
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
370 "Control Emacs through mouse strokes."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
371 :group 'mouse)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
372
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
373 (defcustom strokes-modeline-string " Strokes"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
374 "*Modeline identification when strokes are on \(default is \" Strokes\"\)."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
375 :type 'string
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
376 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
377
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
378 (defcustom strokes-character ?@
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
379 "*Character used when drawing strokes in the strokes buffer.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
380 \(The default is lower-case `@', which works okay\)."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
381 :type 'character
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
382 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
383
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
384 (defcustom strokes-minimum-match-score 1000
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
385 "*Minimum score for a stroke to be considered a possible match.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
386 Requiring a perfect match would set this variable to 0.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
387 The default value is 1000, but it's mostly dependent on how precisely
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
388 you manage to replicate your user-defined strokes. It also depends on
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
389 the value of `strokes-grid-resolution', since a higher grid resolution
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
390 will correspond to more sample points, and thus more distance
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
391 measurements. Usually, this is not a problem since you first set
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
392 `strokes-grid-resolution' based on what your computer seems to be able
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
393 to handle (though the defaults are usually more than sufficent), and
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
394 then you can set `strokes-minimum-match-score' to something that works
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
395 for you. The only purpose of this variable is to insure that if you
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
396 do a bogus stroke that really doesn't match any of the predefined
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
397 ones, then strokes should NOT pick the one that came closest."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
398 :type 'integer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
399 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
400
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
401 (defcustom strokes-grid-resolution 9
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
402 "*Integer defining dimensions of the stroke grid.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
403 The grid is a square grid, where STROKES-GRID-RESOLUTION defaults to
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
404 `9', making a 9x9 grid whose coordinates go from (0 . 0) on the top
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
405 left to ((STROKES-GRID-RESOLUTION - 1) . (STROKES-GRID-RESOLUTION - 1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
406 on the bottom right. The greater the resolution, the more intricate
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
407 your strokes can be.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
408 NOTE: This variable should be odd and MUST NOT be less than 3 and need
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
409 not be greater than 33, which is the resolution of the pixmaps.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
410 WARNING: Changing the value of this variable will gravely affect the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
411 strokes you have already programmed in. You should try to
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
412 figure out what it should be based on your needs and on how
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
413 quick the particular platform(s) you're operating on, and
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
414 only then start programming in your custom strokes."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
415 :type 'integer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
416 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
417
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
418 (defcustom strokes-file "~/.strokes"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
419 "*File containing saved strokes for stroke-mode (default is ~/.strokes)."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
420 :type 'file
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
421 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
422
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
423 (defcustom strokes-buffer-name " *strokes*"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
424 "The buffer that the strokes take place in (default is ` *strokes*')."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
425 :type 'string
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
426 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
427
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
428 (defcustom strokes-use-strokes-buffer t
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
429 "*If non-nil, the strokes buffer is used and strokes are displayed.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
430 If nil, strokes will be read the same, however the user will not be
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
431 able to see the strokes. This be helpful for people who don't like
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
432 the delay in switching to the strokes buffer."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
433 :type 'boolean
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
434 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
435
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
436 (defcustom strokes-click-command 'mouse-yank
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
437 "*Command to execute when stroke is actually a `click' event.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
438 This is set to `mouse-yank' by default."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
439 :type 'function
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
440 :group 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
441
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
442 ;;; internal variables...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
443
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
444 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
445 (defvar strokes-mode nil
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
446 "Non-nil when `strokes' is globally enabled")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
447
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
448 (defvar strokes-window-configuration nil
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
449 "The special window configuration used when entering strokes.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
450 This is set properly in the function `strokes-update-window-configuration'.")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
451
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
452 (defvar strokes-window-configuration-plist
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
453 (list 'frame nil 'frame-height nil 'frame-width nil)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
454 "Plist describing the state of the current strokes-window-configuration.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
455 The plist consists of the following keys:
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
456
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
457 'frame Frame to draw strokes in.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
458 'frame-height Height of the frame.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
459 'frame-width Width of the frame.")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
460
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
461 (defvar strokes-last-stroke nil
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
462 "Last stroke entered by the user.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
463 Its value gets set every time the function
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
464 `strokes-fill-stroke' gets called,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
465 since that is the best time to set the variable")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
466
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
467 (defvar strokes-global-map '()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
468 "Association list of strokes and their definitions.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
469 Each entry is (STROKE . COMMAND) where STROKE is itself a list of
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
470 coordinates (X . Y) where X and Y are lists of positions on the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
471 normalized stroke grid, with the top left at (0 . 0). COMMAND is the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
472 corresponding interactive function")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
473
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
474 (defvar strokes-load-hook nil
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
475 "Function or functions to be called when `strokes' is loaded.")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
476
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
477 ;;; ### NOT IMPLEMENTED YET ###
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
478 ;;(defvar edit-strokes-menu
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
479 ;; '("Edit-Strokes"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
480 ;; ["Add stroke..." strokes-global-set-stroke t]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
481 ;; ["Delete stroke..." strokes-edit-delete-stroke t]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
482 ;; ["Change stroke" strokes-smaller t]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
483 ;; ["Change definition" strokes-larger t]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
484 ;; ["[Re]List Strokes chronologically" strokes-list-strokes t]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
485 ;; ["[Re]List Strokes alphabetically" strokes-list-strokes t]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
486 ;; ["Quit" strokes-edit-quit t]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
487 ;; ))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
488
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
489 ;;; Macros...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
490
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
491 (defmacro strokes-while-inhibiting-garbage-collector (&rest forms)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
492 "Execute FORMS without interference from the garbage collector."
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
493 `(let ((gc-cons-threshold 134217727))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
494 ,@forms))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
495
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
496 (defsubst strokes-click-p (stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
497 "Non-nil if STROKE is really click."
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
498 (< (length stroke) 2))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
499
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
500 ;;; old, but worked pretty good (just in case)...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
501 ;;(defmacro strokes-define-stroke (stroke-map stroke def)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
502 ;; "Add STROKE to STROKE-MAP alist with given command DEF"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
503 ;; (list 'if (list '< (list 'length stroke) 3)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
504 ;; (list 'error
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
505 ;; "That's a click, not a stroke. See `strokes-click-command'")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
506 ;; (list 'setq stroke-map (list 'cons (list 'cons stroke def)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
507 ;; (list 'remassoc stroke stroke-map)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
508
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
509 (defmacro strokes-define-stroke (stroke-map stroke def)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
510 "Add STROKE to STROKE-MAP alist with given command DEF."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
511 `(if (strokes-click-p ,stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
512 (error "That's a click, not a stroke; see `strokes-click-command'")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
513 (setq ,stroke-map (cons (cons ,stroke ,def)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
514 (remassoc ,stroke ,stroke-map)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
515
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
516 (defalias 'define-stroke 'strokes-define-stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
517
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
518 (defsubst strokes-square (x)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
519 "Returns the square of the number X"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
520 (* x x))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
521
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
522 (defsubst strokes-distance-squared (p1 p2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
523 "Gets the distance (squared) between to points P1 and P2.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
524 P1 and P2 are cons cells in the form (X . Y)."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
525 (let ((x1 (car p1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
526 (y1 (cdr p1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
527 (x2 (car p2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
528 (y2 (cdr p2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
529 (+ (strokes-square (- x2 x1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
530 (strokes-square (- y2 y1)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
531
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
532 ;;; Advice for various functions...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
533
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
534 ;; I'd originally wanted to write a macro that would just take in the
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
535 ;; generic functions which use mouse button2 in various modes. Most
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
536 ;; of them are identical in form: they take an event as the single
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
537 ;; argument and then do their thing. I tried writing a macro that
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
538 ;; looked something like this, but failed. Advice just ain't that
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
539 ;; easy. The one that bugged me the most was `Manual-follow-xref',
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
540 ;; because that had &rest arguments, and I didn't know how to work
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
541 ;; around it in defadvice. However, I was able to fix up most of the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
542 ;; important modes (i.e. the ones I use all the time). One `bug' in
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
543 ;; the program that I just can't seem to figure out is why I can only
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
544 ;; advise other button2 functions successfully when the variable
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
545 ;; `strokes-use-strokes-buffer' is nil. I did all the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
546 ;; save-excursion/save-window-excursion stuff SPECIFICALLY so that
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
547 ;; using the strokes buffer or not would absolutely not affect any
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
548 ;; other part of the program. If someone can figure out how to make
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
549 ;; the following advices work w/ regardless of that variable
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
550 ;; `strokes-use-strokes-buffer', then that would be a great victory.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
551 ;; If someone out there would be kind enough to make the commented
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
552 ;; code below work, I'd be grateful. By the way, I put the `protect'
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
553 ;; keywords there to insure that if a stroke went bad, then
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
554 ;; `strokes-click-command' would be set back. If this isn't
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
555 ;; necessary, then feel free to let me know.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
556
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
557 ;; For what follows, I really wanted something that would work like this:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
558
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
559 ;;(strokes-fix-button2 'vm-mouse-button-2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
560
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
561 ;; Or even better, I could have simply done something like:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
562
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
563 ;;(mapcar 'strokes-fix-button2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
564 ;; '(vm-mouse-button-2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
565 ;; rmail-summary-mouse-goto-msg
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
566 ;; <rest of them>))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
567
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
568 ;;; With help from Hans (author of advice.el)...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
569 (defmacro strokes-fix-button2-command (command)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
570 "Fix COMMAND so that it can also work with strokes.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
571 COMMAND must take one event argument.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
572 Example of how one might fix up a command that's bound to button2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
573 and which is an interactive funcion of one event argument:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
574
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
575 (strokes-fix-button2-command 'vm-mouse-button-2)"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
576 (let ((command (eval command)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
577 `(progn
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
578 (defadvice ,command (around strokes-fix-button2 compile preactivate)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
579 ,(format "Fix %s to work with strokes." command)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
580 (let ((strokes-click-command
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
581 ',(intern (format "ad-Orig-%s" command))))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
582 (strokes-do-stroke (ad-get-arg 0)))))))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
583
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
584 (strokes-fix-button2-command 'vm-mouse-button-2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
585 (strokes-fix-button2-command 'rmail-summary-mouse-goto-msg)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
586 (strokes-fix-button2-command 'Buffer-menu-mouse-select)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
587 (strokes-fix-button2-command 'w3-widget-button-click)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
588 (strokes-fix-button2-command 'widget-image-button-press)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
589 (strokes-fix-button2-command 'Info-follow-clicked-node)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
590 (strokes-fix-button2-command 'compile-mouse-goto-error)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
591 (strokes-fix-button2-command 'gdbsrc-select-or-yank)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
592 (strokes-fix-button2-command 'hypropos-mouse-get-doc)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
593 (strokes-fix-button2-command 'gnus-mouse-pick-group)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
594 (strokes-fix-button2-command 'gnus-mouse-pick-article)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
595 (strokes-fix-button2-command 'gnus-article-push-button)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
596 (strokes-fix-button2-command 'dired-mouse-find-file)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
597 (strokes-fix-button2-command 'url-dired-find-file-mouse)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
598 (strokes-fix-button2-command 'dired-u-r-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
599 (strokes-fix-button2-command 'dired-u-w-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
600 (strokes-fix-button2-command 'dired-u-x-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
601 (strokes-fix-button2-command 'dired-g-r-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
602 (strokes-fix-button2-command 'dired-g-w-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
603 (strokes-fix-button2-command 'dired-g-x-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
604 (strokes-fix-button2-command 'dired-o-r-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
605 (strokes-fix-button2-command 'dired-o-w-mouse-toggle)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
606 (strokes-fix-button2-command 'isearch-yank-x-selection)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
607 (strokes-fix-button2-command 'occur-mode-mouse-goto)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
608 (strokes-fix-button2-command 'cvs-mouse-find-file)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
609
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
610 ;;; I can fix the customize widget button click, but then
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
611 ;;; people will get confused when they try to customize
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
612 ;;; strokes with the mouse and customize tells them that
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
613 ;;; `strokes-click-command' is mapped to `ad-Orig-widget-button-click'
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
614 ;;(strokes-fix-button2-command 'widget-button-click)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
615
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
616 ;;; without the advice, each advised function would look like...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
617 ;;(defadvice vm-mouse-button-2 (around vm-strokes activate protect)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
618 ;; "Allow strokes to work in VM."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
619 ;; (if strokes-use-strokes-buffer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
620 ;; ;; then strokes is no good and we'll have to use the original
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
621 ;; ad-do-it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
622 ;; ;; otherwise, we can make strokes work too...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
623 ;; (let ((strokes-click-command 'ad-Orig-vm-mouse-button-2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
624 ;; (strokes-do-stroke (ad-get-arg 0)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
625
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
626 ;;; Functions...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
627
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
628 (defun strokes-lift-p (object)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
629 "Return non-nil if object is a stroke-lift."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
630 (eq object strokes-lift))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
631
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
632 (defun strokes-unset-last-stroke ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
633 "Undo the last stroke definition."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
634 (interactive)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
635 (let ((command (cdar strokes-global-map)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
636 (if (y-or-n-p-maybe-dialog-box
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
637 (format "really delete last stroke definition, defined to `%s'? "
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
638 command))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
639 (progn
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
640 (setq strokes-global-map (cdr strokes-global-map))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
641 (message "That stroke has been deleted"))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
642 (message "Nothing done"))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
643
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
644 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
645 (defun strokes-global-set-stroke (stroke command)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
646 "Interactively give STROKE the global binding as COMMAND.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
647 Operated just like `global-set-key', except for strokes.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
648 COMMAND is a symbol naming an interactively-callable function. STROKE
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
649 is a list of sampled positions on the stroke grid as described in the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
650 documentation for the `strokes-define-stroke' function."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
651 (interactive
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
652 (list
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
653 (and (or strokes-mode (strokes-mode t))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
654 (strokes-read-complex-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
655 "Define a new stroke. Draw with button1 (or 2). End with button3..."))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
656 (read-command-or-command-sexp "command to map stroke to: ")))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
657 (strokes-define-stroke strokes-global-map stroke command))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
658
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
659 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
660 (defalias 'global-set-stroke 'strokes-global-set-stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
661
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
662 ;;(defun global-unset-stroke (stroke); FINISH THIS DEFUN!
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
663 ;; "delete all strokes matching STROKE from `strokes-global-map',
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
664 ;; letting the user input
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
665 ;; the stroke with the mouse"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
666 ;; (interactive
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
667 ;; (list
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
668 ;; (strokes-read-stroke "Enter the stroke you want to delete...")))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
669 ;; (strokes-define-stroke 'strokes-global-map stroke command))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
670
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
671 (defun strokes-get-grid-position (stroke-extent position &optional grid-resolution)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
672 "Map POSITION to a new grid position based on its STROKE-EXTENT and GRID-RESOLUTION.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
673 STROKE-EXTENT as a list \(\(XMIN . YMIN\) \(XMAX . YMAX\)\).
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
674 If POSITION is a `strokes-lift', then it is itself returned.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
675 Optional GRID-RESOLUTION may be used in place of STROKES-GRID-RESOLUTION.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
676 The grid is a square whose dimesion is [0,GRID-RESOLUTION)."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
677 (cond ((consp position) ; actual pixel location
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
678 (let ((grid-resolution (or grid-resolution strokes-grid-resolution))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
679 (x (car position))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
680 (y (cdr position))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
681 (xmin (caar stroke-extent))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
682 (ymin (cdar stroke-extent))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
683 ;; the `1+' is there to insure that the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
684 ;; formula evaluates correctly at the boundaries
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
685 (xmax (1+ (caadr stroke-extent)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
686 (ymax (1+ (cdadr stroke-extent))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
687 (cons (floor (* grid-resolution
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
688 (/ (float (- x xmin))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
689 (- xmax xmin))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
690 (floor (* grid-resolution
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
691 (/ (float (- y ymin))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
692 (- ymax ymin)))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
693 ((strokes-lift-p position) ; stroke lift
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
694 strokes-lift)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
695
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
696 (defun strokes-get-stroke-extent (pixel-positions)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
697 "From a list of absolute PIXEL-POSITIONS, returns absolute spatial extent.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
698 The return value is a list ((XMIN . YMIN) (XMAX . YMAX))."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
699 (if pixel-positions
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
700 (let ((xmin (caar pixel-positions))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
701 (xmax (caar pixel-positions))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
702 (ymin (cdar pixel-positions))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
703 (ymax (cdar pixel-positions))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
704 (rest (cdr pixel-positions)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
705 (while rest
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
706 (if (consp (car rest))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
707 (let ((x (caar rest))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
708 (y (cdar rest)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
709 (if (< x xmin)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
710 (setq xmin x))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
711 (if (> x xmax)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
712 (setq xmax x))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
713 (if (< y ymin)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
714 (setq ymin y))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
715 (if (> y ymax)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
716 (setq ymax y))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
717 (setq rest (cdr rest)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
718 (let ((delta-x (- xmax xmin))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
719 (delta-y (- ymax ymin)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
720 (if (> delta-x delta-y)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
721 (setq ymin (- ymin
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
722 (/ (- delta-x delta-y)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
723 2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
724 ymax (+ ymax
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
725 (/ (- delta-x delta-y)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
726 2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
727 (setq xmin (- xmin
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
728 (/ (- delta-y delta-x)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
729 2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
730 xmax (+ xmax
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
731 (/ (- delta-y delta-x)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
732 2))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
733 (list (cons xmin ymin)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
734 (cons xmax ymax))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
735 nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
736
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
737 (defun strokes-eliminate-consecutive-redundancies (entries)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
738 "Returns a list with no consecutive redundant entries."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
739 ;; defun a grande vitesse grace a Dave G.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
740 (loop for element on entries
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
741 if (not (equal (car element) (cadr element)))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
742 collect (car element)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
743 ;; (loop for element on entries
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
744 ;; nconc (if (not (equal (car el) (cadr el)))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
745 ;; (list (car el)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
746 ;; yet another (orig) way of doing it...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
747 ;; (if entries
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
748 ;; (let* ((current (car entries))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
749 ;; (rest (cdr entries))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
750 ;; (non-redundant-list (list current))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
751 ;; (next nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
752 ;; (while rest
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
753 ;; (setq next (car rest))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
754 ;; (if (equal current next)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
755 ;; (setq rest (cdr rest))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
756 ;; (setq non-redundant-list (cons next non-redundant-list)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
757 ;; current next
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
758 ;; rest (cdr rest))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
759 ;; (nreverse non-redundant-list))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
760 ;; nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
761
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
762 (defun strokes-renormalize-to-grid (positions &optional grid-resolution)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
763 "Map POSITIONS to a new grid whose dimensions are based on GRID-RESOLUTION.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
764 POSITIONS is a list of positions and stroke-lifts.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
765 Optional GRID-RESOLUTION may be used in place of STROKES-GRID-RESOLUTION.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
766 The grid is a square whose dimesion is [0,GRID-RESOLUTION)."
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
767 (or grid-resolution (setq grid-resolution strokes-grid-resolution))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
768 (let ((stroke-extent (strokes-get-stroke-extent positions)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
769 (mapcar (function
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
770 (lambda (pos)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
771 (strokes-get-grid-position stroke-extent pos grid-resolution)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
772 positions)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
773
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
774 (defun strokes-fill-stroke (unfilled-stroke &optional force)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
775 "Fill in missing grid locations in the list of UNFILLED-STROKE.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
776 If FORCE is non-nil, then fill the stroke even if it's `stroke-click'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
777 NOTE: This is where the global variable `strokes-last-stroke' is set."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
778 (setq strokes-last-stroke ; this is global
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
779 (if (and (strokes-click-p unfilled-stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
780 (not force))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
781 unfilled-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
782 (loop for grid-locs on unfilled-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
783 nconc (let* ((current (car grid-locs))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
784 (current-is-a-point-p (consp current))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
785 (next (cadr grid-locs))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
786 (next-is-a-point-p (consp next))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
787 (both-are-points-p (and current-is-a-point-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
788 next-is-a-point-p))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
789 (x1 (and current-is-a-point-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
790 (car current)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
791 (y1 (and current-is-a-point-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
792 (cdr current)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
793 (x2 (and next-is-a-point-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
794 (car next)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
795 (y2 (and next-is-a-point-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
796 (cdr next)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
797 (delta-x (and both-are-points-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
798 (- x2 x1)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
799 (delta-y (and both-are-points-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
800 (- y2 y1)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
801 (slope (and both-are-points-p
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
802 (if (zerop delta-x)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
803 nil ; undefined vertical slope
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
804 (/ (float delta-y)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
805 delta-x)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
806 (cond ((not both-are-points-p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
807 (list current))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
808 ((null slope) ; undefinded vertical slope
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
809 (if (>= delta-y 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
810 (loop for y from y1 below y2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
811 collect (cons x1 y))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
812 (loop for y from y1 above y2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
813 collect (cons x1 y))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
814 ((zerop slope) ; (= y1 y2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
815 (if (>= delta-x 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
816 (loop for x from x1 below x2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
817 collect (cons x y1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
818 (loop for x from x1 above x2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
819 collect (cons x y1))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
820 ((>= (abs delta-x) (abs delta-y))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
821 (if (> delta-x 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
822 (loop for x from x1 below x2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
823 collect (cons x
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
824 (+ y1
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
825 (round (* slope
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
826 (- x x1))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
827 (loop for x from x1 above x2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
828 collect (cons x
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
829 (+ y1
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
830 (round (* slope
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
831 (- x x1))))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
832 (t ; (< (abs delta-x) (abs delta-y))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
833 (if (> delta-y 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
834 (loop for y from y1 below y2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
835 collect (cons (+ x1
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
836 (round (/ (- y y1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
837 slope)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
838 y))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
839 (loop for y from y1 above y2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
840 collect (cons (+ x1
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
841 (round (/ (- y y1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
842 slope)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
843 y))))))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
844
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
845 (defun strokes-rate-stroke (stroke1 stroke2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
846 "Rates STROKE1 with STROKE2 and returns a score based on a distance metric.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
847 Note: the rating is an error rating, and therefore, a return of 0
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
848 represents a perfect match. Also note that the order of stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
849 arguments is order-independent for the algorithm used here."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
850 (if (and stroke1 stroke2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
851 (let ((rest1 (cdr stroke1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
852 (rest2 (cdr stroke2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
853 (err (strokes-distance-squared (car stroke1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
854 (car stroke2))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
855 (while (and rest1 rest2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
856 (while (and (consp (car rest1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
857 (consp (car rest2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
858 (setq err (+ err
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
859 (strokes-distance-squared (car rest1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
860 (car rest2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
861 stroke1 rest1
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
862 stroke2 rest2
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
863 rest1 (cdr stroke1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
864 rest2 (cdr stroke2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
865 (cond ((and (strokes-lift-p (car rest1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
866 (strokes-lift-p (car rest2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
867 (setq rest1 (cdr rest1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
868 rest2 (cdr rest2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
869 ((strokes-lift-p (car rest2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
870 (while (consp (car rest1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
871 (setq err (+ err
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
872 (strokes-distance-squared (car rest1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
873 (car stroke2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
874 rest1 (cdr rest1))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
875 ((strokes-lift-p (car rest1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
876 (while (consp (car rest2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
877 (setq err (+ err
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
878 (strokes-distance-squared (car stroke1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
879 (car rest2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
880 rest2 (cdr rest2))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
881 (if (null rest2)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
882 (while (consp (car rest1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
883 (setq err (+ err
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
884 (strokes-distance-squared (car rest1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
885 (car stroke2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
886 rest1 (cdr rest1))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
887 (if (null rest1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
888 (while (consp (car rest2))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
889 (setq err (+ err
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
890 (strokes-distance-squared (car stroke1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
891 (car rest2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
892 rest2 (cdr rest2))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
893 (if (or (strokes-lift-p (car rest1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
894 (strokes-lift-p (car rest2)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
895 (setq err nil)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
896 err))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
897 nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
898
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
899 (defun strokes-match-stroke (stroke stroke-map)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
900 "Finds the best matching command of STROKE in STROKE-MAP.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
901 Returns the corresponding match as (COMMAND . SCORE)."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
902 (if (and stroke stroke-map)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
903 (let ((score (strokes-rate-stroke stroke (caar stroke-map)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
904 (command (cdar stroke-map))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
905 (map (cdr stroke-map)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
906 (while map
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
907 (let ((newscore (strokes-rate-stroke stroke (caar map))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
908 (if (or (and newscore score (< newscore score))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
909 (and newscore (null score)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
910 (setq score newscore
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
911 command (cdar map)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
912 (setq map (cdr map))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
913 (if score
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
914 (cons command score)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
915 nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
916 nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
917
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
918 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
919 (defun strokes-read-stroke (&optional prompt event)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
920 "Read a simple stroke (interactively) and return the stroke.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
921 Optional PROMPT in minibuffer displays before and during stroke reading.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
922 This function will display the stroke interactively as it is being
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
923 entered in the strokes buffer if the variable
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
924 `strokes-use-strokes-buffer' is non-nil.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
925 Optional EVENT is acceptable as the starting event of the stroke"
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
926 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
927 (let ((pix-locs nil)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
928 (grid-locs nil)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
929 (safe-to-draw-p nil))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
930 (strokes-while-inhibiting-garbage-collector
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
931 (if strokes-use-strokes-buffer
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
932 ;; switch to the strokes buffer and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
933 ;; display the stroke as it's being read
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
934 (save-window-excursion
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
935 (set-window-configuration strokes-window-configuration)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
936 (when prompt
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
937 (setq event (next-command-event event prompt))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
938 (or (button-press-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
939 (error "You must draw with the mouse")))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
940 (or event (setq event (next-event nil prompt)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
941 safe-to-draw-p t))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
942 (unwind-protect
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
943 (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
944 (while (not (button-release-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
945 (if (mouse-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
946 (let ((point (event-closest-point event)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
947 (if (and point safe-to-draw-p)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
948 ;; we can draw that point
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
949 (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
950 (goto-char point)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
951 (subst-char-in-region point (1+ point) ?\ strokes-character))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
952 ;; otherwise, we can start drawing the next time...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
953 (setq safe-to-draw-p t))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
954 (push (cons (event-x-pixel event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
955 (event-y-pixel event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
956 pix-locs))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
957 ;; otherwise, if it's not a mouse-event...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
958 (dispatch-event event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
959 (setq event (next-event event))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
960 ;; protected
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
961 ;; clean up strokes buffer and then bury it.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
962 (when (equal (buffer-name) strokes-buffer-name)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
963 (subst-char-in-region (point-min) (point-max) strokes-character ?\ )
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
964 (goto-char (point-min))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
965 (bury-buffer))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
966 ;; Otherwise, don't use strokes buffer and read stroke silently
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
967 (when prompt
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
968 (setq event (next-command-event event prompt))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
969 (or (button-press-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
970 (error "You must draw with the mouse")))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
971 (or event (setq event (next-event nil prompt)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
972 (while (not (button-release-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
973 (if (mouse-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
974 (push (cons (event-x-pixel event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
975 (event-y-pixel event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
976 pix-locs)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
977 (dispatch-event event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
978 (setq event (next-event event)))))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
979 (setq grid-locs (strokes-renormalize-to-grid (nreverse pix-locs)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
980 (strokes-fill-stroke (strokes-eliminate-consecutive-redundancies grid-locs)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
981
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
982 ;;; This version of `strokes-read-stroke' is not broken, but pathetic.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
983 ;;(defun strokes-read-stroke (&optional prompt event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
984 ;; "Read a simple stroke (interactively) and return the stroke.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
985 ;;Optional PROMPT in minibuffer displays before and during stroke reading.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
986 ;;This function will display the stroke interactively as it is being
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
987 ;;entered in the strokes buffer if the variable
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
988 ;;`strokes-use-strokes-buffer' is non-nil.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
989 ;;Optional EVENT is currently not used, but hopefully will be soon."
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
990 ;; (save-excursion
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
991 ;; (strokes-while-inhibiting-garbage-collector
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
992 ;; (let ((pix-locs nil)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
993 ;; (grid-locs nil)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
994 ;; (event (or event (make-event))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
995 ;; (if strokes-use-strokes-buffer
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
996 ;; ;; switch to the strokes buffer and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
997 ;; ;; display the stroke as it's being read
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
998 ;; (save-window-excursion
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
999 ;; (set-window-configuration strokes-window-configuration)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1000 ;; (if prompt
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1001 ;; (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1002 ;; (setq event (next-event event prompt))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1003 ;; (while (not (button-press-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1004 ;; (dispatch-event event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1005 ;; (setq event (next-event event)))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1006 ;; (unwind-protect
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1007 ;; (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1008 ;; (setq event (next-event event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1009 ;; (while (not (button-release-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1010 ;; (if (mouse-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1011 ;; (let ((point (event-closest-point event)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1012 ;; (when point
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1013 ;; (goto-char point)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1014 ;; (subst-char-in-region point (1+ point) ?\ strokes-character))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1015 ;; (push (cons (event-x-pixel event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1016 ;; (event-y-pixel event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1017 ;; pix-locs)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1018 ;; (setq event (next-event event))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1019 ;; ;; protected
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1020 ;; ;; clean up strokes buffer and then bury it.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1021 ;; (when (equal (buffer-name) strokes-buffer-name)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1022 ;; (subst-char-in-region (point-min) (point-max) strokes-character ?\ )
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1023 ;; (goto-char (point-min))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1024 ;; (bury-buffer))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1025 ;; ;; Otherwise, don't use strokes buffer and read stroke silently
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1026 ;; (if prompt
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1027 ;; (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1028 ;; (setq event (next-event event prompt))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1029 ;; (while (not (button-press-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1030 ;; (dispatch-event event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1031 ;; (setq event (next-event event)))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1032 ;; (setq event (next-event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1033 ;; (while (not (button-release-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1034 ;; (if (mouse-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1035 ;; (push (cons (event-x-pixel event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1036 ;; (event-y-pixel event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1037 ;; pix-locs))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1038 ;; (setq event (next-event event))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1039 ;; (setq grid-locs (strokes-renormalize-to-grid (nreverse pix-locs)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1040 ;; (strokes-fill-stroke (strokes-eliminate-consecutive-redundancies grid-locs))))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1041
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1042 (defun strokes-read-complex-stroke (&optional prompt event)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1043 "Read a complex stroke (interactively) and return the stroke.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1044 Optional PROMPT in minibuffer displays before and during stroke reading.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1045 Note that a complex stroke allows the user to pen-up and pen-down. This
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1046 is implemented by allowing the user to paint with button1 or button2 and
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1047 then complete the stroke with button3.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1048 Optional EVENT is acceptable as the starting event of the stroke"
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1049 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1050 (save-window-excursion
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1051 (strokes-while-inhibiting-garbage-collector
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1052 (set-window-configuration strokes-window-configuration)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1053 (let ((pix-locs nil)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1054 (grid-locs nil)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1055 (safe-to-draw-p nil))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1056 (when prompt
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1057 (setq event (next-command-event event prompt))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1058 (or (button-press-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1059 (error "You must draw with the mouse")))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1060 (or event (setq event (next-event nil prompt)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1061 safe-to-draw-p t))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1062 (unwind-protect
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1063 (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1064 (while (not (and (button-press-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1065 (eq (event-button event) 3)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1066 (while (not (button-release-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1067 (if (mouse-event-p event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1068 (let ((point (event-closest-point event)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1069 (if (and point safe-to-draw-p)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1070 ;; we can draw that point
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1071 (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1072 (goto-char point)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1073 (subst-char-in-region point (1+ point) ?\ strokes-character))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1074 ;; otherwise, we can start drawing the next time...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1075 (setq safe-to-draw-p t))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1076 (push (cons (event-x-pixel event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1077 (event-y-pixel event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1078 pix-locs))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1079 (dispatch-event event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1080 (setq event (next-event event prompt)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1081 (push strokes-lift pix-locs)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1082 (while (not (button-press-event-p event))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1083 (dispatch-event event)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1084 (setq event (next-event event prompt))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1085 (setq pix-locs (nreverse (cdr pix-locs)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1086 ;; minor bug fix here for when user enters ` *strokes*'
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1087 ;; buffer with a click instead of a drag...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1088 (when (strokes-lift-p (car pix-locs))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1089 (setq pix-locs (cdr pix-locs)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1090 (setq grid-locs (strokes-renormalize-to-grid pix-locs))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1091 (strokes-fill-stroke
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1092 (strokes-eliminate-consecutive-redundancies grid-locs)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1093 ;; protected
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1094 (when (equal (buffer-name) strokes-buffer-name)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1095 (subst-char-in-region (point-min) (point-max) strokes-character ?\ )
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1096 (goto-char (point-min))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1097 (bury-buffer))))))))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1098
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1099 (defun strokes-execute-stroke (stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1100 "Given STROKE, execute the command which corresponds to it.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1101 The command will be executed provided one exists for that stroke,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1102 based on the variable `strokes-minimum-match-score'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1103 If no stroke matches, nothing is done and return value is nil."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1104 (let* ((match (strokes-match-stroke stroke strokes-global-map))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1105 (command (car match))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1106 (score (cdr match)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1107 (cond ((strokes-click-p stroke)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1108 ;; This is the case of a `click' type event.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1109 ;; The `sit-for' is a minor frob that has to do with timing
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1110 ;; problems. Without the `sit-for', mouse-yank will not
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1111 ;; yank at the proper location if the user opted for
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1112 ;; mouse-yank-at-point to be nil (i.e. mouse-yank takes
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1113 ;; place at pointer position). The sit-for tells redisplay
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1114 ;; to be sure to wait for the `*strokes*' buffer to vanish
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1115 ;; from consideration when deciding on a point to be used
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1116 ;; for mouse-yank.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1117 (sit-for 0)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1118 (command-execute strokes-click-command))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1119 ((and match (<= score strokes-minimum-match-score))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1120 (message "%s" command)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1121 (command-execute command))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1122 ((null strokes-global-map)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1123 (if (file-exists-p strokes-file)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1124 (and (y-or-n-p-maybe-dialog-box
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1125 (format "No strokes loaded. Load `%s'? "
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1126 strokes-file))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1127 (strokes-load-user-strokes))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1128 (error "No strokes defined; use `global-set-stroke'")))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1129 (t
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1130 (error
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1131 "No stroke matches; see variable `strokes-minimum-match-score'")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1132 nil))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1133
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1134 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1135 (defun strokes-do-stroke (event)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1136 "Read a simple stroke from the user and then exectute its command.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1137 This must be bound to a mouse event."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1138 (interactive "e")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1139 (or strokes-mode (strokes-mode t))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1140 (strokes-execute-stroke (strokes-read-stroke nil event)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1141
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1142 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1143 (defun strokes-do-complex-stroke (event)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1144 "Read a complex stroke from the user and then exectute its command.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1145 This must be bound to a mouse event."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1146 (interactive "e")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1147 (or strokes-mode (strokes-mode t))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1148 (strokes-execute-stroke (strokes-read-complex-stroke nil event)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1149
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1150 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1151 (defun strokes-describe-stroke (stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1152 "Displays the command which STROKE maps to, reading STROKE interactively."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1153 (interactive
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1154 (list
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1155 (strokes-read-complex-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1156 "Enter stroke to describe; end with button3...")))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1157 (let* ((match (strokes-match-stroke stroke strokes-global-map))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1158 (command (or (and (strokes-click-p stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1159 strokes-click-command)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1160 (car match)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1161 (score (cdr match)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1162 (if (or (and match
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1163 (<= score strokes-minimum-match-score))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1164 (and (strokes-click-p stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1165 strokes-click-command))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1166 (message "That stroke maps to `%s'" command)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1167 (message "That stroke is undefined"))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1168 (sleep-for 1))) ; helpful for recursive edits
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1169
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1170 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1171 (defalias 'describe-stroke 'strokes-describe-stroke)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1172
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1173 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1174 (defun strokes-help ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1175 "Get instructional help on using the the `strokes' package."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1176 (interactive)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1177 (with-displaying-help-buffer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1178 (function
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1179 (lambda ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1180 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1181 (let ((helpdoc
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1182 "This is help for the strokes package.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1183
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1184 If you find something wrong with strokes, or feel that it can be
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1185 improved in some way, then please feel free to email me:
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1186
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1187 David Bakhash <cadet@mit.edu>
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1188
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1189 or just do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1190
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1191 M-x strokes-report-bug
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1192
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1193 ------------------------------------------------------------
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1194
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1195 ** Strokes...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1196
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1197 The strokes package allows you to define strokes (that you make with
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1198 the mouse or other pointer device) that XEmacs can interpret as
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1199 corresponding to commands, and then executes the commands. It does
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1200 character recognition, so you don't have to worry about getting it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1201 right every time.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1202
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1203 Strokes also allows you to compose documents graphically. You can
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1204 fully edit documents in Chinese, Japanese, etc. based on XEmacs
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1205 strokes. Once you've done so, you can ascii compress-and-encode them
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1206 and then safely save them for later use, send letters to friends
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1207 (using XEmacs, of course). Strokes will later decode these documents,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1208 extracting the strokes for editing use once again, so the editing
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1209 cycle can continue.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1210
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1211 Strokes are easy to program and fun to use. To start strokes going,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1212 you'll want to put the following line in your .emacs file:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1213
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1214 (if window-system
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1215 (require 'strokes))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1216
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1217 This will load strokes when and only when you start XEmacs on a window
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1218 system (i.e. that has a pointer (mouse) device, etc.).
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1219
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1220 To toggle strokes-mode, you just do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1221
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1222 > M-x strokes-mode
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1223
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1224 ** Strokes for controlling the behavior of XEmacs...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1225
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1226 When you're ready to start defining strokes, just use the command
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1227
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1228 > M-x global-set-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1229
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1230 You will see a ` *strokes*' buffer which is waiting for you to enter in
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1231 your stroke. When you enter in the stroke, you draw with button1 or
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1232 button2, and then end with button3. Next, you enter in the command
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1233 which will be executed when that stroke is invoked. Simple as that.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1234 For now, try to define a stroke to copy a region. This is a popular
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1235 edit command, so type
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1236
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1237 > M-x global-set-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1238
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1239 Then, in the ` *strokes*' buffer, draw the letter `C' (for `copy')
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1240 and then, when it asks you to enter the command to map that to, type
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1241
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1242 > copy-region-as-kill
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1243
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1244 That's about as hard as it gets.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1245 Remember: paint with button1 or button2 and then end with button3.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1246
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1247 If ever you want to know what a certain strokes maps to, then do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1248
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1249 > M-x describe-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1250
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1251 and you can enter in any arbitrary stroke. Remember: The strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1252 package lets you program in simple and complex (multi-lift) strokes.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1253 The only difference is how you *invoke* the two. You will most likely
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1254 use simple strokes, as complex strokes were developed for
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1255 Chinese/Japanese/Korean. So the middle mouse button (button2) will
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1256 invoke the command `strokes-do-stroke' in buffers where button2 doesn't
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1257 already have a meaning other than its original, which is `mouse-yank'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1258 But don't worry: `mouse-yank' will still work with strokes (see the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1259 variable `strokes-click-command').
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1260
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1261 If ever you define a stroke which you don't like, then you can unset
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1262 it with the command
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1263
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1264 > M-x strokes-unset-last-stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1265
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1266 You can always get an idea of what your current strokes look like with
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1267 the command
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1268
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1269 > M-x list-strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1270
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1271 Your strokes will be displayed in alphabetical order (based on command
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1272 names) and the beginning of each simple stroke will be marked by a
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1273 color dot. Since you may have several simple strokes in a complex
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1274 stroke, the dot colors are arranged in the rainbow color sequence,
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1275 `ROYGBIV'. If you want a listing of your strokes from most recent
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1276 down, then use a prefix argument:
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1277
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1278 > C-u M-x list-strokes
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1279
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1280 Your strokes are stored as you enter them. They get saved in a file
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1281 called ~/.strokes, along with other strokes configuration variables.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1282 You can change this location by setting the variable `strokes-file'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1283 You will be prompted to save them when you exit XEmacs, or you can save
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1284 them with
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1285
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1286 > M-x save-strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1287
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1288 Your strokes get loaded automatically when you enable `strokes-mode'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1289 You can also load in your user-defined strokes with
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1290
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1291 > M-x load-user-strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1292
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1293 ** Strokes for pictographic editing...
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1294
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1295 If you'd like to create graphical files with strokes, you'll have to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1296 be running XEmacs on a window system, with XPM support. You use the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1297 binding C-button2 to start drawing your strokes. These are just
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1298 complex strokes, and thus you continue drawing with buttons 1 or 2 and
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1299 end with button-3. Then the stroke glyph gets inserted into the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1300 buffer. You treat it like any other character, which you can copy,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1301 paste, delete, move, etc. The command which is bound to C-button2 is
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1302 called `strokes-compose-complex-stroke'. When all is done, you may
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1303 want to send the file, or save it. This is done with
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1304
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1305 > M-x strokes-encode-buffer
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1306
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1307 Likewise, to decode the strokes from a strokes-encoded buffer you do
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1308
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1309 > M-x strokes-decode-buffer
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1310
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1311 ** A few more important things...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1312
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1313 o The command `strokes-do-complex-stroke' is invoked with M-button2, so that you
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1314 can execute complex strokes (i.e. with more than one lift) if preferred.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1315
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1316 o Strokes are a bit computer-dependent in that they depend somewhat on
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1317 the speed of the computer you're working on. This means that you
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1318 may have to tweak some variables. You can read about them in the
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1319 commentary of `strokes.el'. Better to just use apropos and read their
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1320 docstrings. All variables/functions start with `strokes'. The one
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1321 variable which many people wanted to see was
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1322 `strokes-use-strokes-buffer' which allows the user to use strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1323 silently--without displaying the strokes. All variables can be set
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1324 by customizing the group named `strokes' via the customization package:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1325
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1326 > M-x customize"))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1327 (princ helpdoc standard-output)))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1328
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1329 (defun strokes-report-bug ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1330 "Submit a bug report for strokes."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1331 (interactive)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1332 (let ((reporter-prompt-for-summary-p t))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1333 (or (boundp 'reporter-version)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1334 (setq reporter-version
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1335 "Your version of reporter is obsolete. Please upgrade."))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1336 (reporter-submit-bug-report
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1337 strokes-bug-address "Strokes"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1338 (cons
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1339 'strokes-version
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1340 (nconc
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1341 (mapcar
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1342 'intern
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1343 (sort
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1344 (let (completion-ignore-case)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1345 (all-completions "strokes-" obarray 'user-variable-p))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1346 'string-lessp))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1347 (list 'reporter-version)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1348 (function
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1349 (lambda ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1350 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1351 (mail-position-on-field "subject")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1352 (beginning-of-line)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1353 (skip-chars-forward "^:\n")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1354 (if (looking-at ": Strokes;")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1355 (progn
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1356 (goto-char (match-end 0))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1357 (delete-char -1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1358 (insert " " strokes-version " bug:")))))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1359
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1360 (defsubst strokes-fill-current-buffer-with-whitespace ()
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1361 "Erase the contents of the current buffer and fill it with whitespace."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1362 (erase-buffer)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1363 (loop repeat (frame-height) do
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1364 (insert-char ?\ (1- (frame-width)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1365 (newline))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1366 (goto-char (point-min)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1367
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1368 (defun strokes-window-configuration-changed-p ()
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1369 "Non-nil if the `strokes-window-configuration' frame properties changed.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1370 This is based on the last time the `strokes-window-configuration was updated."
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1371 (not (and (eq (selected-frame)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1372 (plist-get strokes-window-configuration-plist
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1373 'frame))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1374 (eq (frame-height)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1375 (plist-get strokes-window-configuration-plist
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1376 'frame-height))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1377 (eq (frame-width)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1378 (plist-get strokes-window-configuration-plist
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1379 'frame-width)))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1380
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1381 (defun strokes-update-window-configuration-plist ()
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1382 "Update the `strokes-window-configuration-plist' based on the current state."
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1383 (plist-put strokes-window-configuration-plist
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1384 'frame
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1385 (selected-frame))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1386 (plist-put strokes-window-configuration-plist
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1387 'frame-height
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1388 (frame-height))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1389 (plist-put strokes-window-configuration-plist
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1390 'frame-width
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1391 (frame-width)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1392
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1393 (defun strokes-update-window-configuration ()
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1394 "Update the `strokes-window-configuration'."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1395 (interactive)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1396 (let ((current-window (selected-window)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1397 (cond ((or (window-minibuffer-p current-window)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1398 (window-dedicated-p current-window))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1399 ;; don't try to update strokes window configuration
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1400 ;; if window is dedicated or a minibuffer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1401 nil)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1402 ((or (interactive-p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1403 (not (buffer-live-p (get-buffer strokes-buffer-name)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1404 (null strokes-window-configuration))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1405 ;; create `strokes-window-configuration' from scratch...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1406 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1407 (save-window-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1408 (get-buffer-create strokes-buffer-name)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1409 (set-window-buffer current-window strokes-buffer-name)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1410 (delete-other-windows)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1411 (fundamental-mode)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1412 (auto-save-mode 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1413 (if (featurep 'font-lock)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1414 (font-lock-mode 0))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1415 (abbrev-mode 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1416 (buffer-disable-undo (current-buffer))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1417 (setq truncate-lines nil)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1418 (strokes-fill-current-buffer-with-whitespace)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1419 (setq strokes-window-configuration (current-window-configuration))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1420 (strokes-update-window-configuration-plist)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1421 (bury-buffer))))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1422 ((strokes-window-configuration-changed-p) ; simple update
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1423 ;; update the strokes-window-configuration for this
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1424 ;; specific frame...
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1425 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1426 (save-window-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1427 (set-window-buffer current-window strokes-buffer-name)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1428 (delete-other-windows)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1429 (strokes-fill-current-buffer-with-whitespace)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1430 (setq strokes-window-configuration (current-window-configuration))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1431 (strokes-update-window-configuration-plist)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1432 (bury-buffer)))))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1433
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1434 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1435 (defun strokes-load-user-strokes ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1436 "Load user-defined strokes from file named by `strokes-file'."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1437 (interactive)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1438 (cond ((and (file-exists-p strokes-file)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1439 (file-readable-p strokes-file))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1440 (load-file strokes-file))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1441 ((interactive-p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1442 (error "Trouble loading user-defined strokes; nothing done"))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1443 (t
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1444 (message "No user-defined strokes, sorry"))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1445
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1446 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1447 (defalias 'load-user-strokes 'strokes-load-user-strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1448
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1449 (defun strokes-prompt-user-save-strokes ()
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1450 "Save user-defined strokes to file named by `strokes-file'."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1451 (interactive)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1452 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1453 (let ((current strokes-global-map))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1454 (unwind-protect
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1455 (progn
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1456 (setq strokes-global-map nil)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1457 (strokes-load-user-strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1458 (if (and (not (equal current strokes-global-map))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1459 (or (interactive-p)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1460 (yes-or-no-p-maybe-dialog-box "save your strokes? ")))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1461 (progn
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1462 (require 'pp) ; pretty-print variables
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1463 (message "Saving strokes in %s..." strokes-file)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1464 (get-buffer-create "*saved-strokes*")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1465 (set-buffer "*saved-strokes*")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1466 (erase-buffer)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1467 (emacs-lisp-mode)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1468 (goto-char (point-min))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1469 (insert-string
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1470 ";; -*- Syntax: Emacs-Lisp; Mode: emacs-lisp -*-\n")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1471 (insert-string (format ";;; saved strokes for %s, as of %s\n\n"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1472 (user-full-name)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1473 (format-time-string "%B %e, %Y" nil)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1474 (message "Saving strokes in %s..." strokes-file)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1475 (insert-string (format "(setq strokes-global-map '%s)"
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1476 (pp current)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1477 (message "Saving strokes in %s..." strokes-file)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1478 (indent-region (point-min) (point-max) nil)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1479 (write-region (point-min)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1480 (point-max)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1481 strokes-file))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1482 (message "(no changes need to be saved)")))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1483 ;; protected
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1484 (if (get-buffer "*saved-strokes*")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1485 (kill-buffer (get-buffer "*saved-strokes*")))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1486 (setq strokes-global-map current)))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1487
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1488 (defalias 'save-strokes 'strokes-prompt-user-save-strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1489
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1490 (defun strokes-toggle-strokes-buffer (&optional arg)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1491 "Toggle the use of the strokes buffer.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1492 In other words, toggle the variabe `strokes-use-strokes-buffer'.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1493 With ARG, use strokes buffer if and only if ARG is positive or true.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1494 Returns value of `strokes-use-strokes-buffer'."
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1495 (interactive "P")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1496 (setq strokes-use-strokes-buffer
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1497 (if arg (> (prefix-numeric-value arg) 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1498 (not strokes-use-strokes-buffer))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1499
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1500 (defun strokes-xpm-for-stroke (&optional stroke bufname b/w-only)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1501 "Create an xpm pixmap for the given STROKE in buffer `*strokes-xpm*'.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1502 If STROKE is not supplied, then `strokes-last-stroke' will be used.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1503 Optional BUFNAME to name something else.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1504 The pixmap will contain time information via rainbow dot colors
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1505 where each individual strokes begins.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1506 Optional B/W-ONLY non-nil will create a mono pixmap, not intended
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1507 for trying to figure out the order of strokes, but rather for reading
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1508 the stroke as a character in some language."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1509 (interactive)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1510 (save-excursion
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1511 (let ((buf (get-buffer-create (or bufname "*strokes-xpm*")))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1512 (stroke (strokes-eliminate-consecutive-redundancies
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1513 (strokes-fill-stroke
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1514 (strokes-renormalize-to-grid (or stroke
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1515 strokes-last-stroke)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1516 31))))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1517 (lift-flag t)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1518 (rainbow-chars (list ?R ?O ?Y ?G ?B ?P))) ; ROYGBIV w/o indigo
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1519 (set-buffer buf)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1520 (erase-buffer)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1521 (insert strokes-xpm-header)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1522 (loop repeat 33 do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1523 (insert-char ?\")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1524 (insert-char ?\ 33)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1525 (insert "\",")
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1526 (newline)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1527 finally
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1528 (forward-line -1)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1529 (end-of-line)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1530 (insert "}\n"))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1531 (loop for point in stroke
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1532 for x = (car-safe point)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1533 for y = (cdr-safe point) do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1534 (cond ((consp point)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1535 ;; draw a point, and possibly a starting-point
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1536 (if (and lift-flag (not b/w-only))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1537 ;; mark starting point with the appropriate color
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1538 (let ((char (or (car rainbow-chars) ?\.)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1539 (loop for i from 0 to 2 do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1540 (loop for j from 0 to 2 do
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1541 (goto-line (+ 16 i y))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1542 (forward-char (+ 1 j x))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1543 (delete-char 1)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1544 (insert-char char)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1545 (setq rainbow-chars (cdr rainbow-chars)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1546 lift-flag nil))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1547 ;; Otherwise, just plot the point...
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1548 (goto-line (+ 17 y))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1549 (forward-char (+ 2 x))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1550 (subst-char-in-region (point) (1+ (point)) ?\ ?\*)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1551 ((strokes-lift-p point)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1552 ;; a lift--tell the loop to X out the next point...
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1553 (setq lift-flag t))))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1554 (when (interactive-p)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1555 (require 'xpm-mode)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1556 (pop-to-buffer "*strokes-xpm*")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1557 ;; (xpm-mode 1)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1558 (xpm-show-image)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1559 (goto-char (point-min))))))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1560
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1561 ;;; Strokes Edit stuff... ### NOT IMLEMENTED YET ###
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1562
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1563 ;;(defun strokes-edit-quit ()
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1564 ;; (interactive)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1565 ;; (or (one-window-p t 0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1566 ;; (delete-window))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1567 ;; (kill-buffer "*Strokes List*"))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1568
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1569 ;;(define-derived-mode edit-strokes-mode list-mode
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1570 ;; "Edit-Strokes"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1571 ;; "Major mode for `edit-strokes' and `list-strokes' buffers.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1572
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1573 ;;Editing commands:
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1574
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1575 ;;\\{edit-strokes-mode-map}"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1576 ;; (setq truncate-lines nil
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1577 ;; auto-show-mode nil ; don't want problems here either
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1578 ;; mode-popup-menu edit-strokes-menu) ; what about extent-specific stuff?
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1579 ;; (and (featurep 'menubar)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1580 ;; current-menubar
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1581 ;; (set (make-local-variable 'current-menubar)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1582 ;; (copy-sequence current-menubar))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1583 ;; (add-submenu nil edit-strokes-menu)))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1584
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1585 ;;(let ((map edit-strokes-mode-map))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1586 ;; (define-key map "<" 'beginning-of-buffer)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1587 ;; (define-key map ">" 'end-of-buffer)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1588 ;; ;; (define-key map "c" 'strokes-copy-other-face)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1589 ;; ;; (define-key map "C" 'strokes-copy-this-face)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1590 ;; ;; (define-key map "s" 'strokes-smaller)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1591 ;; ;; (define-key map "l" 'strokes-larger)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1592 ;; ;; (define-key map "b" 'strokes-bold)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1593 ;; ;; (define-key map "i" 'strokes-italic)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1594 ;; (define-key map "e" 'strokes-list-edit)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1595 ;; ;; (define-key map "f" 'strokes-font)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1596 ;; ;; (define-key map "u" 'strokes-underline)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1597 ;; ;; (define-key map "t" 'strokes-truefont)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1598 ;; ;; (define-key map "F" 'strokes-foreground)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1599 ;; ;; (define-key map "B" 'strokes-background)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1600 ;; ;; (define-key map "D" 'strokes-doc-string)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1601 ;; (define-key map "a" 'strokes-global-set-stroke)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1602 ;; (define-key map "d" 'strokes-list-delete-stroke)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1603 ;; ;; (define-key map "n" 'strokes-list-next)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1604 ;; ;; (define-key map "p" 'strokes-list-prev)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1605 ;; ;; (define-key map " " 'strokes-list-next)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1606 ;; ;; (define-key map "\C-?" 'strokes-list-prev)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1607 ;; (define-key map "g" 'strokes-list-strokes) ; refresh display
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1608 ;; (define-key map "q" 'strokes-edit-quit)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1609 ;; (define-key map [(control c) (control c)] 'bury-buffer))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1610
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1611 ;;;;;###autoload
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1612 ;;(defun strokes-edit-strokes (&optional chronological strokes-map)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1613 ;; ;; ### DEAL WITH THE 2nd ARGUMENT ISSUE! ###
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1614 ;; "Edit strokes in a pop-up buffer containing strokes and their definitions.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1615 ;;If STROKES-MAP is not given, `strokes-global-map' will be used instead.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1616
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1617 ;;Editing commands:
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1618
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1619 ;;\\{edit-faces-mode-map}"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1620 ;; (interactive "P")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1621 ;; (pop-to-buffer (get-buffer-create "*Strokes List*"))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1622 ;; (reset-buffer (current-buffer)) ; handy function from minibuf.el
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1623 ;; (setq strokes-map (or strokes-map
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1624 ;; strokes-global-map
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1625 ;; (progn
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1626 ;; (strokes-load-user-strokes)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1627 ;; strokes-global-map)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1628 ;; (or chronological
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1629 ;; (setq strokes-map (sort (copy-sequence strokes-map)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1630 ;; 'strokes-alphabetic-lessp)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1631 ;; ;; (push-window-configuration)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1632 ;; (insert
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1633 ;; "Command Stroke\n"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1634 ;; "------- ------")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1635 ;; (loop for def in strokes-map
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1636 ;; for i from 0 to (1- (length strokes-map)) do
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1637 ;; (let ((stroke (car def))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1638 ;; (command-name (symbol-name (cdr def))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1639 ;; (strokes-xpm-for-stroke stroke " *strokes-xpm*")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1640 ;; (newline 2)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1641 ;; (insert-char ?\ 45)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1642 ;; (beginning-of-line)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1643 ;; (insert command-name)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1644 ;; (beginning-of-line)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1645 ;; (forward-char 45)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1646 ;; (set (intern (format "strokes-list-annotation-%d" i))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1647 ;; (make-annotation (make-glyph
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1648 ;; (list
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1649 ;; (vector 'xpm
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1650 ;; :data (buffer-substring
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1651 ;; (point-min " *strokes-xpm*")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1652 ;; (point-max " *strokes-xpm*")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1653 ;; " *strokes-xpm*"))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1654 ;; [string :data "[Stroke]"]))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1655 ;; (point) 'text))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1656 ;; (set-annotation-data (symbol-value (intern (format "strokes-list-annotation-%d" i)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1657 ;; def))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1658 ;; finally do (kill-region (1+ (point)) (point-max)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1659 ;; (edit-strokes-mode)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1660 ;; (goto-char (point-min)))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1661
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1662 ;;;;;###autoload
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1663 ;;(defalias 'edit-strokes 'strokes-edit-strokes)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1664
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1665 ;;;###autoload
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1666 (defun strokes-list-strokes (&optional chronological strokes-map)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1667 "Pop up a buffer containing an alphabetical listing of strokes in STROKES-MAP.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1668 With CHRONOLOGICAL prefix arg \(\\[universal-argument]\) list strokes
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1669 chronologically by command name.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1670 If STROKES-MAP is not given, `strokes-global-map' will be used instead."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1671 (interactive "P")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1672 (setq strokes-map (or strokes-map
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1673 strokes-global-map
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1674 (progn
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1675 (strokes-load-user-strokes)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1676 strokes-global-map)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1677 (if (not chronological)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1678 ;; then alphabetize the strokes based on command names...
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1679 (setq strokes-map (sort (copy-sequence strokes-map)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1680 'strokes-alphabetic-lessp)))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1681 (push-window-configuration)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1682 (set-buffer (get-buffer-create "*Strokes List*"))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1683 (setq buffer-read-only nil)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1684 (erase-buffer)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1685 (insert
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1686 "Command Stroke\n"
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1687 "------- ------")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1688 (loop for def in strokes-map do
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1689 (let ((stroke (car def))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1690 (command-name (symbol-name (cdr def))))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1691 (strokes-xpm-for-stroke stroke " *strokes-xpm*")
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1692 (newline 2)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1693 (insert-char ?\ 45)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1694 (beginning-of-line)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1695 (insert command-name)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1696 (beginning-of-line)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1697 (forward-char 45)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1698 (make-annotation (make-glyph
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1699 (list
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1700 (vector 'xpm
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1701 :data (buffer-substring
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1702 (point-min " *strokes-xpm*")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1703 (point-max " *strokes-xpm*")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1704 " *strokes-xpm*"))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1705 [string :data "[Image]"]))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1706 (point) 'text))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1707 finally do (kill-region (1+ (point)) (point-max)))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1708 (view-buffer "*Strokes List*" t)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1709 (goto-char (point-min))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1710 (define-key view-minor-mode-map [(q)] (lambda ()
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1711 (interactive)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1712 (view-quit)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1713 (pop-window-configuration)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1714 ;; (bury-buffer "*Strokes List*")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1715 (define-key view-minor-mode-map [(q)] 'view-quit))))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1716
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1717 (defun strokes-alphabetic-lessp (stroke1 stroke2)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1718 "T iff command name for STROKE1 is less than STROKE2's in lexicographic order."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1719 (let ((command-name-1 (symbol-name (cdr stroke1)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1720 (command-name-2 (symbol-name (cdr stroke2))))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1721 (string-lessp command-name-1 command-name-2)))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1722
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1723 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1724 (defalias 'list-strokes 'strokes-list-strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1725
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1726 ;;;###autoload
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1727 (defun strokes-mode (&optional arg)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1728 "Toggle strokes being enabled.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1729 With ARG, turn strokes on if and only if ARG is positive or true.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1730 Note that `strokes-mode' is a global mode. Think of it as a minor
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1731 mode in all buffers when activated.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1732 By default, strokes are invoked with mouse button-2. You can define
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1733 new strokes with
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1734
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1735 > M-x global-set-stroke
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1736
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1737 To use strokes for pictographic editing, such as Chinese/Japanese, use
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1738 Sh-button-2, which draws strokes and inserts them. Encode/decode your
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1739 strokes with
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1740
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1741 > M-x strokes-encode-buffer
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1742 > M-x strokes-decode-buffer"
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1743 (interactive "P")
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1744 (let ((on-p (if arg
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1745 (> (prefix-numeric-value arg) 0)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1746 (not strokes-mode))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1747 (cond ((not (device-on-window-system-p))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1748 (error "Can't use strokes without windows"))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1749 (on-p ; turn on strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1750 (and (file-exists-p strokes-file)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1751 (null strokes-global-map)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1752 (strokes-load-user-strokes))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1753 (add-hook 'kill-emacs-query-functions
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1754 'strokes-prompt-user-save-strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1755 (add-hook 'select-frame-hook
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1756 'strokes-update-window-configuration)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1757 (strokes-update-window-configuration)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1758 (define-key global-map [(button2)] 'strokes-do-stroke)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1759 (define-key global-map [(meta button2)] 'strokes-do-complex-stroke)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1760 ;; (define-key global-map [(control button2)] 'strokes-do-complex-stroke)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1761 (define-key global-map [(control button2)]
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1762 'strokes-compose-complex-stroke)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1763 (ad-activate-regexp "^strokes-") ; advise button2 commands
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1764 (setq strokes-mode t))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1765 (t ; turn off strokes
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1766 (if (get-buffer strokes-buffer-name)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1767 (kill-buffer (get-buffer strokes-buffer-name)))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1768 (remove-hook 'select-frame-hook
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1769 'strokes-update-window-configuration)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1770 (if (string-match "^strokes-" (symbol-name (key-binding [(button2)])))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1771 (define-key global-map [(button2)] strokes-click-command))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1772 (if (string-match "^strokes-" (symbol-name (key-binding [(meta button2)])))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1773 (global-unset-key [(meta button2)]))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1774 (if (string-match "^strokes-" (symbol-name (key-binding [(control button2)])))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1775 (global-unset-key [(control button2)]))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1776 ;; (if (string-match "^strokes-" (symbol-name (key-binding [(shift button2)])))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1777 ;; (global-unset-key [(shift button2)]))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1778 (ad-deactivate-regexp "^strokes-") ; unadvise strokes-button2 commands
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1779 (setq strokes-mode nil))))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1780 (redraw-modeline))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1781
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1782 (add-minor-mode 'strokes-mode strokes-modeline-string nil nil 'strokes-mode)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
1783
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1784 ;;;; strokes-xpm stuff (later may be separate)...
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1785
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1786 ;; This is the stuff that will eventuall be used for composing letters in
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1787 ;; any language, compression, decompression, graphics, editing, etc.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1788
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1789 (require 'atomic-extents) ; might as well say
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1790 ; (require 'not-so-atomic-extents)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1791 ; but what can you do?
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1792
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1793 ;;(unless (find-face 'strokes-char-face)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1794 (copy-face 'default 'strokes-char-face)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1795 (set-face-background 'strokes-char-face "lightgray") ; I should really
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1796 ; make this a
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1797 ; user-option,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1798 ; but I'm too
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1799 ; lazy right now.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1800 ; In a few days.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1801
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1802 (defconst strokes-char-value-hashtable (make-hashtable 62) ;
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1803 ; (make-char-table
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1804 ; 'syntax)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1805 ; in 20.*
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
1806 ;; ### This will/should become a char-table for XEmacs-20 !!! ###
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1807 "The table which stores values for the character keys.")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1808 (puthash ?0 0 strokes-char-value-hashtable) ; (put-char-table ?0 0
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1809 ; strokes-value-chartable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1810 ; in 20.*
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1811 (puthash ?1 1 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1812 (puthash ?2 2 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1813 (puthash ?3 3 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1814 (puthash ?4 4 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1815 (puthash ?5 5 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1816 (puthash ?6 6 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1817 (puthash ?7 7 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1818 (puthash ?8 8 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1819 (puthash ?9 9 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1820 (puthash ?a 10 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1821 (puthash ?b 11 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1822 (puthash ?c 12 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1823 (puthash ?d 13 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1824 (puthash ?e 14 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1825 (puthash ?f 15 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1826 (puthash ?g 16 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1827 (puthash ?h 17 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1828 (puthash ?i 18 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1829 (puthash ?j 19 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1830 (puthash ?k 20 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1831 (puthash ?l 21 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1832 (puthash ?m 22 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1833 (puthash ?n 23 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1834 (puthash ?o 24 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1835 (puthash ?p 25 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1836 (puthash ?q 26 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1837 (puthash ?r 27 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1838 (puthash ?s 28 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1839 (puthash ?t 29 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1840 (puthash ?u 30 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1841 (puthash ?v 31 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1842 (puthash ?w 32 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1843 (puthash ?x 33 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1844 (puthash ?y 34 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1845 (puthash ?z 35 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1846 (puthash ?A 36 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1847 (puthash ?B 37 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1848 (puthash ?C 38 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1849 (puthash ?D 39 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1850 (puthash ?E 40 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1851 (puthash ?F 41 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1852 (puthash ?G 42 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1853 (puthash ?H 43 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1854 (puthash ?I 44 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1855 (puthash ?J 45 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1856 (puthash ?K 46 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1857 (puthash ?L 47 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1858 (puthash ?M 48 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1859 (puthash ?N 49 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1860 (puthash ?O 50 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1861 (puthash ?P 51 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1862 (puthash ?Q 52 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1863 (puthash ?R 53 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1864 (puthash ?S 54 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1865 (puthash ?T 55 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1866 (puthash ?U 56 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1867 (puthash ?V 57 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1868 (puthash ?W 58 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1869 (puthash ?X 59 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1870 (puthash ?Y 60 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1871 (puthash ?Z 61 strokes-char-value-hashtable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1872
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1873 (defconst strokes-base64-chars
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1874 ;; I can easily have made this a vector of single-character strings,
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1875 ;; like (vector "0" "1" "2" ...), and then the program would run
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1876 ;; faster since it wouldn't then have to call `char-to-string' when it
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1877 ;; did the `concat'. I left them as chars here because I want
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1878 ;; *them* to change `concat' so that it accepts chars and deals with
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1879 ;; them properly. i.e. the form: (concat "abc" ?T "xyz") should
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1880 ;; return "abcTxyz" NOT "abc84xyz" (XEmacs 19.*) and NOT an error
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1881 ;; (XEmacs 20.*).
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1882 ;; (vector "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1883 ;; "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1884 ;; "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1885 ;; "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1886 ;; "T" "U" "V" "W" "X" "Y" "Z")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1887 (vector ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1888 ?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1889 ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1890 "Character vector for fast lookup of base-64 encoding of numbers in [0,61].")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1891
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1892 (defsubst strokes-xpm-char-on-p (char)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1893 ;; ### CAUTION: `char-equal' may need to change to `char=' ###
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1894 "Non-nil if CHAR represents an `on' bit in the xpm."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1895 (char-equal char ?*))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1896
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1897 (defsubst strokes-xpm-char-bit-p (char)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1898 "Non-nil if CHAR represents an `on' or `off' bit in the xpm."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1899 ;; ### CAUTION: `char-equal' may need to change to `char=' ###
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1900 (or (char-equal char ?\ )
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1901 (char-equal char ?*)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1902
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1903 ;;(defsubst strokes-xor (a b) ### Should I make this an inline function? ###
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1904 ;; "T iff one and only one of A and B is non-nil; otherwise, returns nil.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1905 ;;NOTE: Don't use this as a numeric xor since it treats all non-nil
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1906 ;; values as t including `0' (zero)."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1907 ;; (eq (null a) (not (null b))))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1908
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1909 (defsubst strokes-xpm-encode-length-as-string (length)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1910 "Given some LENGTH in [0,62) do a fast lookup of it's encoding."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1911 (char-to-string (aref strokes-base64-chars length)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1912
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1913 (defsubst strokes-xpm-decode-char (character)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1914 "Given a CHARACTER, do a fast lookup to find its corresponding integer value."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1915 ;; ### NOTE: for XEmacs-20.* this will need to be changed to deal w/
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1916 ;; char-tables !!! ###
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1917 (gethash character strokes-char-value-hashtable)) ; (get-char-table
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1918 ; character
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1919 ; strokes-value-chartable)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1920
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1921 (defun strokes-xpm-to-compressed-string (&optional xpm-buffer)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1922 "Convert the xpm in XPM-BUFFER into a compressed string representing the stroke.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1923 XPM-BUFFER is an optional argument, and defaults to `*strokes-xpm*'."
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1924 (save-excursion
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1925 (set-buffer (setq xpm-buffer (or xpm-buffer "*strokes-xpm*")))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1926 (goto-char (point-min))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1927 (search-forward "/* pixels */") ; skip past header junk
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1928 (forward-char 2)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1929 ;; a note for below:
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1930 ;; the `current-char' is the char being counted -- NOT the char at (point)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1931 ;; which happens to be called `char-at-point'
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1932 (let ((compressed-string "+/") ; initialize the output
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1933 (count 0) ; keep a current count of
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1934 ; `current-char'
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1935 (last-char-was-on-p t) ; last entered stream
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1936 ; represented `on' bits
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1937 (current-char-is-on-p nil) ; current stream represents `on' bits
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1938 (char-at-point (char-after))) ; read the first char
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1939 (while (not (char-equal char-at-point ?})) ; a `}' denotes the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1940 ; end of the pixmap
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1941 (cond ((zerop count) ; must restart counting
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1942 ;; check to see if the `char-at-point' is an actual pixmap bit
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1943 (when (strokes-xpm-char-bit-p char-at-point)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1944 (setq count 1
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1945 current-char-is-on-p (strokes-xpm-char-on-p char-at-point)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1946 (forward-char 1))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1947 ((= count 61) ; maximum single char's
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1948 ; encoding length
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1949 (setq compressed-string (concat compressed-string
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1950 ;; add a zero-length
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1951 ;; encoding when
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1952 ;; necessary
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1953 (when (eq last-char-was-on-p
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1954 current-char-is-on-p)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1955 ;; "0"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1956 (strokes-xpm-encode-length-as-string 0))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1957 (strokes-xpm-encode-length-as-string 61))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1958 last-char-was-on-p current-char-is-on-p
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1959 count 0)) ; note that we just set
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1960 ; count=0 and *don't* advance
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1961 ; (point)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1962 ((strokes-xpm-char-bit-p char-at-point) ; an actual xpm bit
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1963 (if (eq current-char-is-on-p
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1964 (strokes-xpm-char-on-p char-at-point))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1965 ;; yet another of the same bit-type, so we continue
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1966 ;; counting...
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1967 (progn
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1968 (incf count)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1969 (forward-char 1))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1970 ;; otherwise, it's the opposite bit-type, so we do a
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1971 ;; write and then restart count ### NOTE (for myself
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1972 ;; to be aware of) ### I really should advance
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1973 ;; (point) in this case instead of letting another
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1974 ;; iteration go through and letting the case: count=0
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1975 ;; take care of this stuff for me. That's why
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1976 ;; there's no (forward-char 1) below.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1977 (setq compressed-string (concat compressed-string
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1978 ;; add a zero-length
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1979 ;; encoding when
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1980 ;; necessary
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1981 (when (eq last-char-was-on-p
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1982 current-char-is-on-p)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1983 ;; "0"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1984 (strokes-xpm-encode-length-as-string 0))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1985 (strokes-xpm-encode-length-as-string count))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1986 count 0
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1987 last-char-was-on-p current-char-is-on-p)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1988 (t ; ELSE it's some other useless
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1989 ; char, like `"' or `,'
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1990 (forward-char 1)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1991 (setq char-at-point (char-after)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1992 (concat compressed-string
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1993 (when (> count 0)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1994 (concat (when (eq last-char-was-on-p
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1995 current-char-is-on-p)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1996 ;; "0"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1997 (strokes-xpm-encode-length-as-string 0))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1998 (strokes-xpm-encode-length-as-string count)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
1999 "/"))))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2000
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2001 ;;;###autoload
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2002 (defun strokes-decode-buffer (&optional buffer force)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2003 "Decode stroke strings in BUFFER and display their corresponding glyphs.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2004 Optional BUFFER defaults to the current buffer.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2005 Optional FORCE non-nil will ignore the buffer's read-only status."
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2006 (interactive)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2007 ;; (interactive "*bStrokify buffer: ")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2008 (save-excursion
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2009 (set-buffer (setq buffer (get-buffer (or buffer (current-buffer)))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2010 (when (or (not buffer-read-only)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2011 force
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2012 inhibit-read-only
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2013 (y-or-n-p-maybe-dialog-box
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2014 (format "Buffer %s is read-only. Strokify anyway? " buffer)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2015 (let ((inhibit-read-only t))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2016 (message "Strokifying %s..." buffer)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2017 (goto-char (point-min))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2018 (let (ext string)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2019 ;; The comment below is what i'd have to do if I wanted to
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2020 ;; deal with random newlines in the midst of the compressed
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2021 ;; strings. If I do this, I'll also have to change
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2022 ;; `strokes-xpm-to-compress-string' to deal with the newline,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2023 ;; and possibly other whitespace stuff. YUCK!
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2024 ;; (while (re-search-forward "\\+/\\(\\w\\|\\)+/" nil t nil (get-buffer buffer))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2025 (while (re-search-forward "\\+/\\w+/" nil t nil buffer)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2026 (setq string (buffer-substring (+ 2 (match-beginning 0))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2027 (1- (match-end 0))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2028 (strokes-xpm-for-compressed-string string " *strokes-xpm*")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2029 (replace-match " ")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2030 (setq ext (make-extent (1- (point)) (point)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2031 (set-extent-property ext 'type 'stroke-glyph)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2032 (set-extent-property ext 'start-open t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2033 (set-extent-property ext 'end-open t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2034 (set-extent-property ext 'detachable t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2035 (set-extent-property ext 'duplicable t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2036 (set-extent-property ext 'data string)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2037 (set-extent-face ext 'default)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2038 (set-extent-end-glyph ext (make-glyph
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2039 (list
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2040 (vector 'xpm
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2041 :data (buffer-substring
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2042 (point-min " *strokes-xpm*")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2043 (point-max " *strokes-xpm*")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2044 " *strokes-xpm*"))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2045 [string :data "[Stroke]"])))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2046 (message "Strokifying %s...done" buffer)))))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2047
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2048 (defun strokes-encode-buffer (&optional buffer force)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2049 "Convert the glyphs in BUFFER to thier base-64 ASCII representations.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2050 Optional BUFFER defaults to the current buffer.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2051 Optional FORCE non-nil will ignore the buffer's read-only status."
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2052 ;; ### NOTE !!! ### (for me)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2053 ;; For later on, you can/should make the inserted strings atomic
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2054 ;; extents, so that the users have a clue that they shouldn't be
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2055 ;; editing inside them. Plus, if you make them extents, you can
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2056 ;; very easily just hide the glyphs, so if you unstrokify, and the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2057 ;; restrokify, then those that already are glyphed don't need to be
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2058 ;; re-calculated, etc. It's just nicer that way. The only things
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2059 ;; to worry about is cleanup (i.e. do the glyphs get gc'd when the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2060 ;; buffer is killed?
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2061 ;; (interactive "*bUnstrokify buffer: ")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2062 (interactive)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2063 (save-excursion
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2064 (set-buffer (setq buffer (or buffer (current-buffer))))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2065 (when (or (not buffer-read-only)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2066 force
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2067 inhibit-read-only
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2068 (y-or-n-p-maybe-dialog-box
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2069 (format "Buffer %s is read-only. Encode anyway? " buffer)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2070 (message "Encoding strokes in %s..." buffer)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2071 ;; (map-extents
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2072 ;; (lambda (ext buf)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2073 ;; (when (eq (extent-property ext 'type) 'stroke-glyph)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2074 ;; (goto-char (extent-start-position ext))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2075 ;; (delete-char 1) ; ### What the hell do I do here? ###
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2076 ;; (insert "+/" (extent-property ext 'data) "/")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2077 ;; (delete-extent ext))))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2078 (let ((inhibit-read-only t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2079 (start nil))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2080 (loop repeat 2 do ; ### KLUDGE!!! This it pure crap! ###
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2081 (map-extents
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2082 (lambda (ext buf)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2083 (when (eq (extent-property ext 'type) 'stroke-glyph)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2084 (setq start (goto-char (extent-start-position ext)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2085 ;; (insert "+/" (extent-property ext 'data) "/")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2086 (insert-string "+/")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2087 (insert-string (extent-property ext 'data))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2088 (insert-string "/")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2089 (delete-char 1)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2090 (set-extent-endpoints ext start (point))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2091 (set-extent-property ext 'type 'stroke-string)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2092 (set-extent-property ext 'atomic t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2093 ;; (set-extent-property ext 'read-only t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2094 (set-extent-face ext 'strokes-char-face)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2095 (set-extent-property ext 'stroke-glyph (extent-end-glyph ext))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2096 (set-extent-end-glyph ext nil))))))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2097 (message "Encoding strokes in %s...done" buffer))))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2098
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2099 (defun strokes-xpm-for-compressed-string (compressed-string &optional bufname)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2100 "Convert the stroke represented by COMPRESSED-STRING into an xpm.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2101 Store xpm in buffer BUFNAME if supplied \(default is `*strokes-xpm*'\)"
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2102 (save-excursion
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2103 (or bufname (setq bufname "*strokes-xpm*"))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2104 (erase-buffer (set-buffer (get-buffer-create bufname)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2105 (insert compressed-string)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2106 (goto-char (point-min))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2107 (let ((current-char-is-on-p nil))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2108 (while (not (eobp))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2109 (insert-char
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2110 (if current-char-is-on-p
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2111 ?*
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2112 ?\ )
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2113 (strokes-xpm-decode-char (char-after)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2114 (delete-char 1)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2115 (setq current-char-is-on-p (not current-char-is-on-p)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2116 (goto-char (point-min))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2117 (loop repeat 33 do
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2118 (insert-char ?\")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2119 (forward-char 33)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2120 (insert "\",\n"))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2121 (goto-char (point-min))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2122 (insert strokes-xpm-header))))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2123
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2124 ;;;###autoload
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2125 (defun strokes-compose-complex-stroke ()
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2126 ;; ### NOTE !!! ###
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2127 ;; Even though we have lexical scoping, it's somewhat ugly how I
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2128 ;; pass around variables in the global name space. I can/should
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2129 ;; change this.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2130 "Read a complex stroke and insert its glyph into the current buffer."
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2131 (interactive "*")
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2132 (let ((strokes-grid-resolution 33))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2133 (strokes-read-complex-stroke)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2134 (strokes-xpm-for-stroke nil " *strokes-xpm*" t)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2135 (insert (strokes-xpm-to-compressed-string " *strokes-xpm*"))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
2136 (strokes-decode-buffer)))
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2137
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
2138 (provide 'strokes)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
2139 (run-hooks 'strokes-load-hook)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents:
diff changeset
2140
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 153
diff changeset
2141 ;;; strokes.el ends here