]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/scribble
tmparse: put in local timezone hack
[plan9front.git] / sys / man / 2 / scribble
1 .TH SCRIBBLE 2
2 .SH NAME
3 scribblealloc,
4 recognize \- character recognition
5 .SH SYNOPSIS
6 .PP
7 .EX
8 .ta 4n +4n +4n +4n +4n +4n +4n +4n +4n +4n
9 #include <u.h>
10 #include <libc.h>
11 #include <draw.h>
12 #include <scribble.h>
13
14 Scribble        *scribblealloc(void);
15 Rune            recognize(Scribble *);
16 .EE
17 .SH DESCRIPTION
18 .PP
19 The scribble library implements simple character recognition.
20 All characters are drawn using a single stroke of the pen (mouse button 1)
21 as on a palmtop computer.
22 .PP
23 The library is not really intended for standalone use.  Its primary
24 use is by the scribble graphical control (see
25 .IR control (2)).
26 .PP
27 .B Scribblealloc
28 allocates and returns an appropriately initialized
29 .B Scribble
30 structure:
31 .IP
32 .EX
33 .ta 4n +4n +4n +4n +4n +4n +4n +4n +4n +4n
34 #define CS_LETTERS                      0
35 #define CS_DIGITS                       1
36 #define CS_PUNCTUATION  2
37
38 struct Scribble {
39         /* private state */
40         Point                   *pt;
41         int                     ppasize;
42         Stroke     ps;
43         Graffiti                *graf;
44         int                     capsLock;
45         int                     puncShift;
46         int                     tmpShift;
47         int                     ctrlShift;
48         int                     curCharSet;
49 };
50 .EE
51 .PP
52 This structure encodes the points making up the stroke
53 to be recognized, as well as the \f2character group\fP in which
54 the stroke should be searched.
55 .PP
56 There are three such groups:
57 .IR letters ,
58 .IR digits ,
59 and
60 .IR punctuation .
61 The current group is encoded in the
62 .B curCharSet
63 field of the
64 .B Scribble
65 structure.
66 Special strokes are recognized to switch between groups.
67 In addition, the charater recognized is influenced by
68 .I mode
69 parameters and modifies them.
70 These are identified by the
71 .BR capsLock ,
72 .BR puncShift ,
73 .BR tmpShift ,
74 and
75 .B ctrlShift
76 fields of the
77 .B Scribble
78 structure.
79 When
80 .B puncShift
81 is non-zero, the character is recognized in the punctuation
82 character set.
83 Similarly,
84 when the character recognized is printable and
85 .B ctrlShift
86 is set, the associated control character is returned as if the
87 control key were depressed,
88 and when the character is a letter and
89 .B capsLock
90 or
91 .B tmpShift
92 is set, the upper-case version is returned.
93 The
94 .B puncShift
95 and
96 .B tmpShift
97 flags are turned off
98 once a character has been recognized; the others are left set.
99 .PP
100 The character to be recognized is encoded as an array of pen_points in the
101 .B ps
102 field.
103 To allow easy drawing of the stroke as it is drawn,
104 the
105 .I pt
106 and
107 .I ppasize
108 fields are available to the application code for storing an array
109 of points for a call to
110 .B poly
111 (see
112 .IR draw (2)).
113 .PP
114 .I Recognize
115 recognizes the character provided in the
116 .B ps
117 field of the
118 .B Scribble
119 structure; it
120 returns the rune or zero if nothing was recognized.
121 .SH FILES
122 .B /sys/lib/scribble/classifiers
123 contains the stroke definitions.
124 .SH SOURCE
125 .B /sys/src/libscribble
126 .PP
127 This library is adapted from software reproduced by permission:
128 .PP
129 .B Graffiti.c
130 is based on the file
131 .B Scribble.c
132 copyrighted
133 by Keith Packard:
134 .IP
135 Copyright © 1999 Keith Packard
136 .PP
137 Permission to use, copy, modify, distribute, and sell this software and its
138 documentation for any purpose is hereby granted without fee, provided that
139 the above copyright notice appear in all copies and that both that
140 copyright notice and this permission notice appear in supporting
141 documentation, and that the name of Keith Packard not be used in
142 advertising or publicity pertaining to distribution of the software without
143 specific, written prior permission.  Keith Packard makes no
144 representations about the suitability of this software for any purpose.  It
145 is provided "as is" without express or implied warranty.
146 .PP
147 Portions of the software Copyright © 1994 by Sun Microsystems Computer Company.
148 .PP
149 Portions of the software Copyright © 2000 by Compaq Computer Corporation.
150 .SH SEE ALSO
151 .B Keyboard
152 and
153 .B prompter
154 in
155 .IR bitsyload (1),
156 .IR draw (2),
157 .IR control (2)