annotate lisp/strokes.el @ 35612:446e8151c90f

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