EdReplac.sgm 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <!-- $XConsortium: EdReplac.sgm /main/6 1996/09/08 20:03:38 rws $ -->
  2. <!-- (c) Copyright 1995 Digital Equipment Corporation. -->
  3. <!-- (c) Copyright 1995 Hewlett-Packard Company. -->
  4. <!-- (c) Copyright 1995 International Business Machines Corp. -->
  5. <!-- (c) Copyright 1995 Sun Microsystems, Inc. -->
  6. <!-- (c) Copyright 1995 Novell, Inc. -->
  7. <!-- (c) Copyright 1995 FUJITSU LIMITED. -->
  8. <!-- (c) Copyright 1995 Hitachi. -->
  9. <![ %CDE.C.CDE; [<RefEntry Id="CDEMX.XCSA.MAN35.rsml.1">]]>
  10. <![ %CDE.C.XO; [<RefEntry Id="XCSA.MAN35.rsml.1">]]>
  11. <RefMeta>
  12. <RefEntryTitle>DtEditorReplace</RefEntryTitle>
  13. <ManVolNum>library call</ManVolNum>
  14. </RefMeta>
  15. <RefNameDiv>
  16. <RefName><Function>DtEditorReplace</Function></RefName>
  17. <RefPurpose>replace a portion of the contents of a DtEditor widget
  18. </RefPurpose>
  19. </RefNameDiv>
  20. <!-- CDE Common Source Format, Version 1.0.0-->
  21. <!-- *************************************************************************-->
  22. <!-- ** (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company-->
  23. <!-- ** (c) Copyright 1993, 1994, 1995 International Business Machines Corp.-->
  24. <!-- ** (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.-->
  25. <!-- ** (c) Copyright 1993, 1994, 1995 Novell, Inc.-->
  26. <!-- *************************************************************************-->
  27. <RefSynopsisDiv>
  28. <FuncSynopsis Remap="ANSI">
  29. <FuncSynopsisInfo>#include &lt;Dt/Editor.h>
  30. </FuncSynopsisInfo>
  31. <FuncDef>DtEditorErrorCode <Function>DtEditorReplace</Function></FuncDef>
  32. <ParamDef>Widget <Parameter>widget</Parameter></ParamDef>
  33. <ParamDef>XmTextPosition <Parameter>startPos</Parameter></ParamDef>
  34. <ParamDef>XmTextPosition <Parameter>endPos</Parameter></ParamDef>
  35. <ParamDef>DtEditorContentRec *<Parameter>data</Parameter></ParamDef>
  36. </FuncSynopsis>
  37. </RefSynopsisDiv>
  38. <RefSect1>
  39. <Title>DESCRIPTION</Title>
  40. <Para>The
  41. <Function>DtEditorReplace</Function> function replaces part of the contents of a DtEditor widget with a string,
  42. a wide character string or sized buffer.
  43. The data is transferred to the
  44. DtEditor widget using a
  45. <StructName Role="typedef">DtEditorContentRec</StructName>, which indicates the
  46. type of data being transferred along with the actual data.
  47. All data following the start position
  48. and up to, but not including, the end position is replaced.
  49. If the start position and the end position are equal, the
  50. data is inserted after the end position.
  51. The character positions begin at zero and are numbered sequentially
  52. from the beginning of the text.
  53. After the replacement, the insertion cursor is positioned after the
  54. last character inserted.
  55. </Para>
  56. <Para>The
  57. <Symbol Role="Variable">widget</Symbol> argument specifies the DtEditor widget ID.
  58. </Para>
  59. <Para>The
  60. <Symbol Role="Variable">startPos</Symbol> argument specifies the starting character position of
  61. the portion to replace.
  62. The replacement begins
  63. at this character.
  64. </Para>
  65. <Para>The
  66. <Symbol Role="Variable">endPos</Symbol> argument specifies the ending character position of
  67. the portion to replace.
  68. The replacement ends
  69. before this character.
  70. </Para>
  71. <Para>The
  72. <Symbol Role="Variable">data</Symbol> argument is a pointer to the data structure
  73. containing the data to insert.
  74. <![ %CDE.C.CDE; [</Para>
  75. <Para>For a complete definition of the DtEditor widget
  76. and its associated resources, see
  77. &cdeman.DtEditor;. ]]></Para>
  78. <Para>For a complete definition of
  79. <StructName Role="typedef">DtEditorContentRec</StructName>, see
  80. &cdeman.Dt.Editor.h;.</Para>
  81. </RefSect1>
  82. <RefSect1>
  83. <Title>RETURN VALUE</Title>
  84. <![ %CDE.C.XO; [
  85. <Para>Upon successful completion, the
  86. <Function>DtEditorReplace</Function> function returns
  87. <SystemItem Class="Constant">DtEDITOR_NO_ERRORS</SystemItem>; otherwise, if it cannot
  88. replace the string, the function returns one of the following values:
  89. </Para>
  90. ]]>
  91. <![ %CDE.C.CDE; [
  92. <Para>Upon successful completion, the
  93. <Function>DtEditorReplace</Function> function returns one of the following values:
  94. </Para>
  95. <VariableList>
  96. <VarListEntry>
  97. <Term>DtEDITOR_NO_ERRORS</Term>
  98. <ListItem>
  99. <Para>The data was replaced sucessfully.
  100. </Para>
  101. </ListItem>
  102. </VarListEntry>
  103. <VarListEntry>
  104. <Term>DtEDITOR_NULLS_REMOVED</Term>
  105. <ListItem>
  106. <Para>NULL characters were found and removed from the data.
  107. </Para>
  108. </ListItem>
  109. </VarListEntry>
  110. </VariableList>
  111. <Para>Otherwise, if
  112. the
  113. <Function>DtEditorReplace</Function> function
  114. cannot replace the data in the DtEditor widget,
  115. it returns one of the following values:
  116. </Para>
  117. ]]>
  118. <VariableList>
  119. <VarListEntry>
  120. <Term>DtEDITOR_INVALID_TYPE</Term>
  121. <ListItem>
  122. <Para>The Type field is not recognized.
  123. </Para>
  124. </ListItem>
  125. </VarListEntry>
  126. <VarListEntry>
  127. <Term>DtEDITOR_INVALID_RANGE</Term>
  128. <ListItem>
  129. <Para>The
  130. <Symbol Role="Variable">startPos</Symbol> argument is greater than the
  131. <Symbol Role="Variable">endPos</Symbol> argument.
  132. </Para>
  133. </ListItem>
  134. </VarListEntry>
  135. <VarListEntry>
  136. <Term>DtEDITOR_ILLEGAL_SIZE</Term>
  137. <ListItem>
  138. <Para>The size of the buffer passed in is negative.
  139. </Para>
  140. </ListItem>
  141. </VarListEntry>
  142. <VarListEntry>
  143. <Term>DtEDITOR_NULL_ITEM</Term>
  144. <ListItem>
  145. <Para>The data buffer is
  146. <SystemItem Class="Constant">NULL</SystemItem>. <![ %CDE.C.CDE; [</Para>
  147. </ListItem>
  148. </VarListEntry>
  149. <VarListEntry>
  150. <Term>DtEDITOR_INSUFFICIENT_MEMORY</Term>
  151. <ListItem>
  152. <Para>Not enough system memory is available to replace the data.
  153. ]]></Para>
  154. </ListItem>
  155. </VarListEntry>
  156. </VariableList>
  157. </RefSect1>
  158. <RefSect1>
  159. <Title>EXAMPLES</Title>
  160. <Para>The following code segment modifies the contents of a
  161. DtEditor widget to ``The quick fox.''
  162. </Para>
  163. <InformalExample Remap="indent">
  164. <ProgramListing>Widget editor;
  165. DtEditorContentRec cr;
  166. DtEditorErrorCode status;
  167. XmTextPosition start = (XmTextPosition) 4,
  168. end = (XmTextPosition) 9;
  169. char *sampleString1="The brown fox",
  170. *sampleString2="quick";
  171. cr.type = DtEDITOR_TEXT;
  172. cr.value.string = sampleString1;
  173. status = DtEditorSetContents(editor, &amp;cr);
  174. <![ %CDE.C.XO; [if (status != DtEDITOR_NO_ERRORS) {
  175. ]]><![ %CDE.C.CDE; [if (status != DtEDITOR_NO_ERRORS &amp;&amp; status != DtEDITOR_NULLS_REMOVED) {
  176. ]]> printf("Unable to set contents of the widget&bsol;n");
  177. } else {
  178. cr.type = DtEDITOR_TEXT;
  179. cr.data.string = sampleString2;
  180. status = DtEditorReplace(editor, start, end, &amp;cr);
  181. if (status != DtEDITOR_NO_ERRORS)
  182. printf("Unable to replace part of the widget contents&bsol;n");
  183. }
  184. </ProgramListing>
  185. </InformalExample>
  186. </RefSect1>
  187. <RefSect1>
  188. <Title>APPLICATION USAGE</Title>
  189. <Para>If the data is in a disk file, rather than in memory, the application should
  190. use
  191. &cdeman.DtEditorReplaceFromFile;.</Para>
  192. </RefSect1>
  193. <RefSect1>
  194. <Title>SEE ALSO</Title>
  195. <Para>&cdeman.Dt.Editor.h;, &cdeman.DtEditor;, &cdeman.DtEditorAppend;, &cdeman.DtEditorAppendFromFile;, &cdeman.DtEditorGetContents;, &cdeman.DtEditorInsert;, &cdeman.DtEditorInsertFromFile;, &cdeman.DtEditorReplaceFromFile;, &cdeman.DtEditorSaveContentsToFile;, &cdeman.DtEditorSetContents;, &cdeman.DtEditorSetContentsFromFile;.</Para>
  196. </RefSect1>
  197. </RefEntry>
  198. <!--fickle 1.12 mancsf-to-docbook 1.2 08/07/95 23:40:24-->