annotate lisp/strokes.el @ 85715:f736b2dc38a6

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