162 lines · 3.8 KB · Text
RawDownload
.TH SCRIBBLE 2.SH NAMEscribblealloc,recognize \- character recognition.SH SYNOPSIS.PP.EX.ta 4n +4n +4n +4n +4n +4n +4n +4n +4n +4n#include <u.h>#include <libc.h>#include <draw.h>#include <scribble.h> Scribble	*scribblealloc(void);Rune		recognize(Scribble *);.EE.SH DESCRIPTION.PPThe scribble library implements simple character recognition.All characters are drawn using a single stroke of the pen (mouse button 1)as on a palmtop computer.A reference card is in.BR /sys/src/libscribble/quickref.gif ..PPThe library is not really intended for standalone use.  Its primaryuse is by the scribble graphical control (see.IR control (2))..PP.B Scribbleallocallocates and returns an appropriately initialized.B Scribblestructure:.IP.EX.ta 4n +4n +4n +4n +4n +4n +4n +4n +4n +4n#define	CS_LETTERS			0#define	CS_DIGITS			1#define	CS_PUNCTUATION	2 struct Scribble {	/* private state */	Point			*pt;	int			ppasize;	Stroke	   ps;	Graffiti		*graf;	int			capsLock;	int			puncShift;	int			tmpShift;	int			ctrlShift;	int			curCharSet;};.EE.PPThis structure encodes the points making up the stroketo be recognized, as well as the \f2character group\fP in whichthe stroke should be searched..PPThere are three such groups:.IR letters ,.IR digits ,and.IR punctuation .The current group is encoded in the.B curCharSetfield of the.B Scribblestructure.Special strokes are recognized to switch between groups.In addition, the charater recognized is influenced by.I modeparameters and modifies them.These are identified by the.BR capsLock ,.BR puncShift ,.BR tmpShift ,and.B ctrlShiftfields of the.B Scribblestructure.When.B puncShiftis non-zero, the character is recognized in the punctuationcharacter set.Similarly,when the character recognized is printable and.B ctrlShiftis set, the associated control character is returned as if thecontrol key were depressed,and when the character is a letter and.B capsLockor.B tmpShiftis set, the upper-case version is returned.The.B puncShiftand.B tmpShiftflags are turned offonce a character has been recognized; the others are left set..PPThe character to be recognized is encoded as an array of pen_points in the.B psfield.To allow easy drawing of the stroke as it is drawn,the.I ptand.I ppasizefields are available to the application code for storing an arrayof points for a call to.B poly(see.IR draw (2))..PP.I Recognizerecognizes the character provided in the.B psfield of the.B Scribblestructure; itreturns the rune or zero if nothing was recognized..SH FILES.B /sys/src/libscribble/quickref.gifserves as a quick reference card..PP.B /sys/lib/scribble/classifierscontains the stroke definitions..SH SOURCE.B /sys/src/libscribble.PPThis library is adapted from software reproduced by permission:.PP.B Graffiti.cis based on the file.B Scribble.ccopyrightedby Keith Packard:.IPCopyright © 1999 Keith Packard.PPPermission to use, copy, modify, distribute, and sell this software and itsdocumentation for any purpose is hereby granted without fee, provided thatthe above copyright notice appear in all copies and that both thatcopyright notice and this permission notice appear in supportingdocumentation, and that the name of Keith Packard not be used inadvertising or publicity pertaining to distribution of the software withoutspecific, written prior permission.  Keith Packard makes norepresentations about the suitability of this software for any purpose.  Itis provided "as is" without express or implied warranty..PPPortions of the software Copyright © 1994 by Sun Microsystems Computer Company..PPPortions of the software Copyright © 2000 by Compaq Computer Corporation..SH SEE ALSO.B Keyboardand.B prompterin.IR bitsyload (1),.IR draw (2),.IR control (2)