home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / doc / Xaw / TextSource < prev    next >
Encoding:
Text File  |  1991-07-29  |  10.3 KB  |  347 lines

  1. .NH 2
  2. TextSrc Object
  3. .LP
  4. .XS
  5.     TextSrc Object
  6. .XE
  7. .IN "TextSrc object" "" "@DEF@"
  8. .LP
  9. .Ds 0
  10. .TA 2.0i
  11. .ta 2.0i
  12. Application Header file    <X11/Xaw/TextSrc.h>
  13. .IN "TextSrc.h" ""
  14. Class Header file    <X11/Xaw/TextSrcP.h>
  15. .IN "TextSrcP.h" ""
  16. Class        textSrcObjectClass
  17. .IN "textSrcObjectClass" ""
  18. Class Name    TextSrc
  19. .IN "TextSrc object" "class name"
  20. Superclass    Object
  21. .sp 1
  22. .LP
  23. The TextSrc object is the root object for all text sources.  Any new text
  24. source objects should be subclasses of the TextSrc Object.  The
  25. TextSrc Class contains all methods the Text widget expects a text
  26. source to export.
  27. .LP
  28. Since all text sources will have some resources in common the
  29. TextSrc defines a few new resources.  
  30. .De
  31. .NH 3
  32. Resources
  33. .LP
  34. When creating an TextSrc object instance, the following resources are
  35. retrieved from the argument list or from the resource database:
  36. .LP
  37. .IN "TextSrc object" "resources"
  38. .ps 9
  39. .nr PS 9
  40. .vs 11
  41. .nr VS 11
  42. .TS H
  43. lw(1i) lw(1i) lw(1i) lw(.5i) lw(2i).
  44. _
  45. .sp 3p
  46. .TB
  47. Name    Class    Type    Notes    Default Value
  48. .sp 3p
  49. _
  50. .TH
  51. .R
  52. .sp 3p
  53. destroyCallback    Callback    XtCallbackList        NULL
  54. editType    EditType    EditMode        NULL
  55. .sp 3p
  56. _
  57. .TE
  58. .ps 11
  59. .nr PS 11
  60. .vs 13
  61. .nr VS 13
  62. .Dc
  63. .Oe Bold
  64. .NH 3
  65. Subclassing the TextSrc
  66. .IN "TextSrc object" "subclassing" "@DEF@"
  67. .LP
  68. The only purpose of the TextSrc Object is to be subclassed.  It contains
  69. the minimum set of class methods that all text sources must have.  All
  70. class methods of the TextSrc must be defined, as the Text widget uses
  71. them all.  While all may be inherited, the direct descendant of TextSrc
  72. \fBmust\fP specify some of them as TextSrc does not contain enough
  73. information to be a valid text source by itself.  Do not try to use the
  74. TextSrc as a valid source for the Text widget; it is not intended to be
  75. used as a source by itself and bad things will probably happen.
  76. .ps 9
  77. .nr PS 9
  78. .vs 11
  79. .nr VS 11
  80. .TS H
  81. lw(1i) lw(1.5i) lw(2i) lw(1i).
  82. _
  83. .sp 3p
  84. .TB
  85. Function    Inherit with    Public Interface    must specify
  86. .sp 3p
  87. _
  88. .TH
  89. .R
  90. .sp 3p
  91. Read    XtInheritRead    XawTextSourceRead    yes
  92. .IN "XtInheritRead" ""
  93. .IN "XawTextSourceRead" ""
  94. Replace    XtInheritReplace    XawTextSourceReplace    no
  95. .IN "XtInheritReplace" ""
  96. .IN "XawTextSourceReplace" ""
  97. Scan    XtInheritScan    XawTextSourceScan    yes
  98. .IN "XtInheritScan" ""
  99. .IN "XawTextSourceScan" ""
  100. Search    XtInheritSearch    XawTextSourceSearch    no
  101. .IN "XtInheritSearch" ""
  102. .IN "XawTextSourceSearch" ""
  103. SetSelection    XtInheritSetSelection    XawTextSourceSetSelection    no
  104. .IN "XtInheritSetSelection" ""
  105. .IN "XawTextSourceSetSelection" ""
  106. ConvertSelection    XtInheritConvertSelection    XawTextSourceConvertSelection    no
  107. .IN "XtInheritConvertSelection" ""
  108. .IN "XawTextSourceConvertSelection" ""
  109. _
  110. .TE
  111. .ps 11
  112. .nr PS 11
  113. .vs 13
  114. .nr VS 13
  115. .NH 4
  116. Reading Text.
  117. .LP
  118. To read the text in a text source use the \fBRead\fP function:
  119. .IN "TextSrc object" "Read" "@DEF@"
  120. .FD 0
  121. XawTextPosition Read(\fIw\fP, \fIpos\fP, \fItext_return\fP, \fIlength\fP)
  122. .br
  123. Widget \fIw\fP;
  124. .br
  125. XawTextPosition \fIpos\fP;
  126. .br
  127. XawTextBlock \fI*text_return\fP;
  128. .br
  129. int \fIlength\fP;
  130. .FN
  131. .IP \fIw\fP 1i
  132. Specifies the TextSrc object.
  133. .IP \fIpos\fP 1i
  134. Specifies the position of the first character to be read from the text buffer.
  135. .IP \fItext\fP 1i
  136. Returns the text read from the source.
  137. .IP \fIlength\fP 1i
  138. Specifies the maximum number of characters the TextSrc should
  139. return to the application in \fItext_return\fP.
  140. .LP
  141. This function returns the actual number of characters read from the
  142. text buffer.  The function is not required to return \fIlength\fP
  143. characters if that many characters are in the file, it may break at
  144. any point that is convenient to the internal structure of the
  145. source.  It may take several calls to \fBRead\fP before the desired
  146. portion of the text buffer is fully retrieved.
  147. .NH 4
  148. Replacing Text.
  149. .LP
  150. To replace or edit the text in a text buffer use the \fBReplace\fP function:
  151. .FD 0
  152. XawTextPosition Replace(\fIw\fP, \fIstart\fP, \fIend\fP, \fItext\fP)
  153. .IN "TextSrc object" "Replace" @DEF@
  154. .br
  155. Widget \fIw\fP;
  156. .br
  157. XawTextPosition \fIstart\fP, \fIend\fP;
  158. .br
  159. XawTextBlock \fI*text\fP;
  160. .FN
  161. .IP \fIw\fP 1i
  162. Specifies the TextSrc object.
  163. .IP \fIstart\fP 1i
  164. Specifies the position of the first character to be removed from the text
  165. buffer.  This is also the location to begin inserting the new text.
  166. .IP \fIend\fP 1i
  167. Specifies the position immediately after the last character to be
  168. removed from the text buffer. 
  169. .IP \fItext\fP 1i
  170. Specifies the text to be added to the text source.
  171. .LP
  172. This function can return any of the following values:
  173. .IP \fBXawEditDone\fP 1.25i
  174. .IN "XawEditDone" ""
  175. The text replacement was successful.
  176. .IP \fBXawPositionError\fP 1.25i
  177. .IN "XawPositionError" ""
  178. The edit mode is \fBXawtextAppend\fP and \fIstart\fP is not the last
  179. character of the source.
  180. .IP \fBXawEditError\fP 1.25i
  181. .IN "XawEditError" ""
  182. Either the Source was read-only or the range to be deleted is larger
  183. than the length of the Source. 
  184. .LP
  185. The \fBReplace\fP arguments \fIstart\fP and \fIend\fP represent the
  186. text source character positions for the existing text that is to be
  187. replaced by the text in the text block.  The characters from
  188. \fIstart\fP up to but not including \fIend\fP are deleted, and the
  189. buffer specified by the text block is inserted in their
  190. place.  If \fIstart\fP and \fIend\fP are equal, no text is deleted and
  191. the new text is inserted after \fIstart\fP.
  192. .NH 4
  193. Scanning the TextSrc
  194. .LP
  195. To search the text source for one of the predefined boundary types use
  196. the \fBScan\fP function:
  197. .FD 0
  198. XawTextPosition Scan(\fIw\fP, \fIposition\fP, \fItype\fP, \fIdir\fP, \fIcount\fP, \fIinclude\fP)
  199. .IN "TextSrc object" "Scan" @DEF@
  200. .br
  201. Widget \fIw\fP;
  202. .br
  203. XawTextPosition \fIposition\fP;
  204. .br
  205. XawTextScanType \fItype\fP;
  206. .br
  207. XawTextScanDirection \fIdir\fP;
  208. .br
  209. int \fIcount\fP;
  210. .br
  211. Boolean \fIinclude\fP;
  212. .FN
  213. .IP \fIw\fP 1i
  214. Specifies the TextSrc object.
  215. .IP \fIposition\fP 1i
  216. Specifies the position to begin scanning the source.
  217. .IP \fItype\fP 1i
  218. Specifies the type of boundary to scan for, may be one of:
  219. \fBXawstPosition\fP, \fBXawstWhiteSpace\fP, \fBXawstEOL\fP,
  220. .IN "XawstPositions" ""
  221. .IN "XawstWhiteSpace" ""
  222. .IN "XawstEOL" ""
  223. \fBXawstParagraph\fP, \fBXawstAll\fP.  The exact meaning of these
  224. .IN "XawstParagraph" ""
  225. .IN "XawstAll" ""
  226. boundaries is left up to the individual text source.
  227. .IP \fIdir\fP 1i
  228. Specifies the direction to scan, may be either \fBXawsdLeft\fP to search
  229. .IN "XawsdLeft" ""
  230. backward, or \fBXawsdRight\fP to search forward.
  231. .IN "XawsdRight" ""
  232. .IP \fIcount\fP 1i
  233. Specifies the number of boundaries to scan for.
  234. .IP \fIinclude\fP 1i
  235. Specifies whether the boundary itself should be included in the scan.
  236. .LP
  237. The \fBScan\fP function returns the position in the text source of the desired
  238. boundary.  It is expected to return a valid address for
  239. all calls made to it, thus if a particular request is made that would take
  240. the text widget beyond the end of the source it must return the
  241. position of that end.
  242. .NH 4
  243. Searching through a TextSrc
  244. .LP
  245. To search for a particular string use the \fBSearch\fP function.
  246. .FD 0
  247. XawTextPosition Search(\fIw\fP, \fIposition\fP, \fIdir\fP, \fItext\fP)
  248. .IN "TextSrc object" "Search" @DEF@
  249. .br
  250. Widget \fIw\fP;
  251. .br
  252. XawTextPosition \fIposition\fP;
  253. .br
  254. XawTextScanDirection \fIdir\fP;
  255. .br
  256. XawTextBlock \fI*text\fP;
  257. .FN
  258. .IP \fIw\fP 1i
  259. Specifies the TextSrc object.
  260. .IP \fIposition\fP 1i
  261. Specifies the position to begin the search.
  262. .IP \fIdir\fP 1i
  263. Specifies the direction to search, may be either \fBXawsdLeft\fP to search
  264. .IN "XawsdLeft" ""
  265. backward, or \fBXawsdRight\fP to search forward.
  266. .IN "XawsdRight" ""
  267. .IP \fItext\fP 1i
  268. Specifies a text block containing the text to search for.
  269. .LP
  270. This function will search through the text buffer attempting to find a
  271. match for the string in the text block.  If a match is found in the
  272. direction specified, then the character location of the first character
  273. in the string is returned.  If no text was found then
  274. \fBXawTextSearchError\fP is returned.
  275. .IN "XawTextSearchError" ""
  276. .NH 4
  277. Text Selections
  278. .LP
  279. While many selection types are handled by the Text widget, text sources
  280. may have selection types unknown to the Text widget.  When a selection
  281. conversion is requested by the X server the Text widget will first call
  282. the \fBConvertSelection\fP function, to attempt the selection
  283. conversion.
  284. .FD 0
  285. Boolean ConvertSelections(\fIw\fP, \fIselection\fP, \fItarget\fP, \fItype\fP, \fIvalue_return\fP, \fIlength_return\fP, \fIformat_return\fP)
  286. .IN "Text widget" "ConvertSelection" @DEF@
  287. .br
  288. Widget \fIw\fP;
  289. .br
  290. Atom \fI*selection\fP, \fI*target\fP, \fI*type\fP;
  291. .br
  292. caddr_t \fI*value_return\fP;
  293. .br
  294. unsigned long \fI*length_return\fP;
  295. .br
  296. int \fI*format_return\fP;
  297. .FN
  298. .IP \fIw\fP 1i
  299. Specifies the TextSrc object.
  300. .IP \fIselection\fP 1i
  301. Specifies the type of selection that was requested (e.g. \fBPRIMARY\fP).
  302. .IP \fItarget\fP 1i
  303. Specifies the type of the selection that has been requested, which
  304. indicates the desired information about the selection (e.g. Filename,
  305. Text, Window).
  306. .IP \fItype\fP 1i
  307. Specifies a pointer to the atom into which the property type of the converted
  308. value of the selection is to be stored.  For instance, either file
  309. name or text might have property type \fBXA_STRING\fP.
  310. .IP \fIvalue_return\fP 1i
  311. Returns a pointer into which a pointer to the converted value of the
  312. selection 
  313. is to be stored.  The selection owner is responsible for allocating
  314. this storage.  The memory is considered owned by the toolkit, and is
  315. freed by XtFree when the Intrinsics selection mechanism is done with it.
  316. .IP \fIlength_return\fP 1i
  317. Returns a pointer into which the number of elements in value is to be stored.
  318. The size of each element is determined by \fIformat\fP.
  319. .IP \fIformat_return\fP 1i
  320. Returns a pointer into which the size in bits of the data elements of the
  321. selection value is to be stored.
  322. .LP
  323. If this function returns \fBTrue\fP then the Text widget will assume
  324. that the source has taken care of converting the selection, Otherwise the
  325. Text widget will attempt to convert the selection itself.
  326. .LP
  327. .sp
  328. If the source needs to know when the text selection is modified it
  329. should define a \fBSetSelection\fP procedure:
  330. .FD 0
  331. void SetSelection(\fIw\fP, \fIstart\fP, \fIend\fP, \fIselection\fP)
  332. Widget \fIw\fP;
  333. .IN "SetSelection" "" @DEF@
  334. .br
  335. XawTextPosition \fIstart\fP, \fIend\fP;
  336. .br
  337. Atom \fIselection\fP;
  338. .FN
  339. .IP \fIw\fP 1i
  340. Specifies the TextSrc object.
  341. .IP \fIstart\fP 1i
  342. Specifies the character position of the beginning of the new text selection.
  343. .IP \fIend\fP
  344. Specifies the character position of the end of the new text selection.
  345. .IP \fIselection\fP 1i
  346. Specifies the type of selection that was requested (e.g. \fBPRIMARY\fP).
  347.