1
0

scribble 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. Scribble *scribblealloc(void);
  14. Rune recognize(Scribble *);
  15. .EE
  16. .SH DESCRIPTION
  17. .PP
  18. The scribble library implements simple character recognition.
  19. All characters are drawn using a single stroke of the pen (mouse button 1)
  20. as on a palmtop computer.
  21. A reference card is in
  22. .BR /sys/src/libscribble/quickref.gif .
  23. .PP
  24. The library is not really intended for standalone use. Its primary
  25. use is by the scribble graphical control (see
  26. .IR control (2)).
  27. .PP
  28. .B Scribblealloc
  29. allocates and returns an appropriately initialized
  30. .B Scribble
  31. structure:
  32. .IP
  33. .EX
  34. .ta 4n +4n +4n +4n +4n +4n +4n +4n +4n +4n
  35. #define CS_LETTERS 0
  36. #define CS_DIGITS 1
  37. #define CS_PUNCTUATION 2
  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/src/libscribble/quickref.gif
  123. serves as a quick reference card.
  124. .PP
  125. .B /sys/lib/scribble/classifiers
  126. contains the stroke definitions.
  127. .SH SOURCE
  128. .B /sys/src/libscribble
  129. .PP
  130. This library is adapted from software reproduced by permission:
  131. .PP
  132. .B Graffiti.c
  133. is based on the file
  134. .B Scribble.c
  135. copyrighted
  136. by Keith Packard:
  137. .IP
  138. Copyright © 1999 Keith Packard
  139. .PP
  140. Permission to use, copy, modify, distribute, and sell this software and its
  141. documentation for any purpose is hereby granted without fee, provided that
  142. the above copyright notice appear in all copies and that both that
  143. copyright notice and this permission notice appear in supporting
  144. documentation, and that the name of Keith Packard not be used in
  145. advertising or publicity pertaining to distribution of the software without
  146. specific, written prior permission. Keith Packard makes no
  147. representations about the suitability of this software for any purpose. It
  148. is provided "as is" without express or implied warranty.
  149. .PP
  150. Portions of the software Copyright © 1994 by Sun Microsystems Computer Company.
  151. .PP
  152. Portions of the software Copyright © 2000 by Compaq Computer Corporation.
  153. .SH SEE ALSO
  154. .B Keyboard
  155. and
  156. .B prompter
  157. in
  158. .IR bitsyload (1),
  159. .IR draw (2),
  160. .IR control (2)