EdSaveCo.sgm 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <!-- $XConsortium: EdSaveCo.sgm /main/6 1996/09/08 20:03:47 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.MAN38.rsml.1">]]>
  10. <![ %CDE.C.XO; [<RefEntry Id="XCSA.MAN38.rsml.1">]]>
  11. <RefMeta>
  12. <RefEntryTitle>DtEditorSaveContentsToFile</RefEntryTitle>
  13. <ManVolNum>library call</ManVolNum>
  14. </RefMeta>
  15. <RefNameDiv>
  16. <RefName><Function>DtEditorSaveContentsToFile</Function></RefName>
  17. <RefPurpose>save the contents of a DtEditor widget to a file
  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>DtEditorSaveContentsToFile</Function></FuncDef>
  32. <ParamDef>Widget <Parameter>widget</Parameter></ParamDef>
  33. <ParamDef>char *<Parameter>fileName</Parameter></ParamDef>
  34. <ParamDef>Boolean <Parameter>overwriteIfExists</Parameter></ParamDef>
  35. <ParamDef>Boolean <Parameter>hardCarriageReturns</Parameter></ParamDef>
  36. <ParamDef>Boolean <Parameter>markContentsAsSaved</Parameter></ParamDef>
  37. </FuncSynopsis>
  38. </RefSynopsisDiv>
  39. <RefSect1>
  40. <Title>DESCRIPTION</Title>
  41. <Para>The
  42. <Function>DtEditorSaveContentsToFile</Function> function saves the entire contents of the DtEditor widget to a file,
  43. optionally replacing soft line feeds (word wraps)
  44. with
  45. <KeySym>newline</KeySym>s. If the file does not exist and the directory has the correct
  46. write permissions, the file is created.
  47. If the file exists and the
  48. <Emphasis>overwriteIfExists</Emphasis> argument is set to
  49. True,
  50. the contents of the file are overwritten.
  51. If the file or its directory does not have the correct write
  52. permissions, an error is returned.
  53. </Para>
  54. <Para>The DtEditor widget tracks whether its contents have changed since they were
  55. last saved or retrieved.
  56. If the
  57. <Emphasis>markContentsAsSaved</Emphasis> argument is set to False,
  58. a copy of the data is saved without affecting whether
  59. &cdeman.DtEditorCheckForUnsavedChanges; reports that there are unsaved changes.
  60. This is useful if the application needs to save a copy of the
  61. contents to a temporary file.
  62. </Para>
  63. <Para>The
  64. <Symbol Role="Variable">widget</Symbol> argument specifies the DtEditor widget ID.
  65. </Para>
  66. <Para>The
  67. <Emphasis>fileName</Emphasis> argument is the pathname of the file
  68. relative to the local system.
  69. </Para>
  70. <Para>The
  71. <Emphasis>overwriteIfExists</Emphasis> argument, if set to
  72. True,
  73. causes
  74. <Function>DtEditorSaveContentsToFile</Function> to save the widget contents even though the file specified by the
  75. <Emphasis>fileName</Emphasis> argument exists and has correct write permissions.
  76. If this argument is set to
  77. False,
  78. <Function>DtEditorSaveContentsToFile</Function> returns
  79. <SystemItem Class="Constant">DtEDITOR_WRITABLE_FILE</SystemItem>.</Para>
  80. <Para>The
  81. <Emphasis>hardCarriageReturns</Emphasis> argument, if set to
  82. True,
  83. indicates that the widget should replace
  84. any soft line feeds (word wraps) with
  85. <KeySym>newline</KeySym>s when saving
  86. the data.
  87. When this argument is set to
  88. False,
  89. any line wrapped because it reaches the
  90. right edge of the window, is saved as one complete line.
  91. </Para>
  92. <Para>The
  93. <Emphasis>markContentsAsSaved</Emphasis> argument, when set to
  94. True,
  95. causes the DtEditor widget to mark that
  96. all changes made to date have been saved.
  97. When this argument is set to
  98. False,
  99. the DtEditor widget
  100. does not change its status regarding unsaved changes.
  101. If an error arises during the save,
  102. the status does not change, regardless of the
  103. value of the
  104. <Emphasis>markContentsAsSaved</Emphasis> argument.
  105. <![ %CDE.C.CDE; [</Para>
  106. <Para>For a complete definition of the DtEditor widget
  107. and its associated resources, see
  108. &cdeman.DtEditor;. ]]></Para>
  109. </RefSect1>
  110. <RefSect1>
  111. <Title>RETURN VALUE</Title>
  112. <Para>Upon successful completion, the
  113. <Function>DtEditorSaveContentsToFile</Function> function returns
  114. <SystemItem Class="Constant">DtEDITOR_NO_ERRORS</SystemItem>; otherwise, if it cannot save the data to the file,
  115. the function returns one of the following values:
  116. </Para>
  117. <VariableList>
  118. <VarListEntry>
  119. <Term>DtEDITOR_INVALID_FILENAME</Term>
  120. <ListItem>
  121. <Para>No file was specified.
  122. </Para>
  123. </ListItem>
  124. </VarListEntry>
  125. <VarListEntry>
  126. <Term>DtEDITOR_UNWRITABLE_FILE</Term>
  127. <ListItem>
  128. <Para>The application does not have write
  129. permission for the file or directory.
  130. </Para>
  131. </ListItem>
  132. </VarListEntry>
  133. <VarListEntry>
  134. <Term>DtEDITOR_CHAR_SPECIAL_FILE</Term>
  135. <ListItem>
  136. <Para>The file is a device-special file.
  137. </Para>
  138. </ListItem>
  139. </VarListEntry>
  140. <VarListEntry>
  141. <Term>DtEDITOR_BLOCK_MODE_FILE</Term>
  142. <ListItem>
  143. <Para>The file is a block-mode device.
  144. </Para>
  145. </ListItem>
  146. </VarListEntry>
  147. <VarListEntry>
  148. <Term>DtEDITOR_NO_FILE_ACCESS</Term>
  149. <ListItem>
  150. <Para>The file cannot be accessed.
  151. </Para>
  152. </ListItem>
  153. </VarListEntry>
  154. <VarListEntry>
  155. <Term>DtEDITOR_SAVE_FAILED</Term>
  156. <ListItem>
  157. <Para>The contents could not be saved for an
  158. unspecified reason.
  159. </Para>
  160. </ListItem>
  161. </VarListEntry>
  162. <VarListEntry>
  163. <Term>DtEDITOR_WRITABLE_FILE</Term>
  164. <ListItem>
  165. <Para>The named files exist and the
  166. <Emphasis>overwriteIfExists</Emphasis> argument is set to
  167. False.
  168. </Para>
  169. </ListItem>
  170. </VarListEntry>
  171. </VariableList>
  172. </RefSect1>
  173. <RefSect1>
  174. <Title>EXAMPLES</Title>
  175. <Para>The following code segment saves the contents
  176. of a DtEditor widget to the local file, Foo, substituting
  177. <KeySym>newline</KeySym>s for soft line feeds.
  178. It also indicates that all changes
  179. to the contents of the widget have been saved.
  180. </Para>
  181. <InformalExample Remap="indent">
  182. <ProgramListing>Widget editor;
  183. DtEditorErrorCode status;
  184. char *fname = "Foo";
  185. Boolean overwrite = False,
  186. hardReturns = True,
  187. markContentsAsSaved = True;
  188. status = DtEditorSaveContentsToFile(editor, fname, overwrite,
  189. hardReturns, markContentsAsSaved);
  190. switch(status)
  191. {
  192. case DtEDITOR_NO_ERRORS:
  193. break;
  194. case DtEDITOR_WRITABLE_FILE:
  195. printf("Save failed. The file already exists.&bsol;n");
  196. break;
  197. default:
  198. printf("Could not save contents.&bsol;n");
  199. break;
  200. }
  201. </ProgramListing>
  202. </InformalExample>
  203. </RefSect1>
  204. <RefSect1>
  205. <Title>APPLICATION USAGE</Title>
  206. <Para>The application should use
  207. &cdeman.DtEditorGetContents; to retrieve the data in a memory buffer,
  208. rather than a disk file.
  209. </Para>
  210. </RefSect1>
  211. <RefSect1>
  212. <Title>SEE ALSO</Title>
  213. <Para>&cdeman.Dt.Editor.h;, &cdeman.DtEditor;, &cdeman.DtEditorAppend;, &cdeman.DtEditorAppendFromFile;, &cdeman.DtEditorCheckForUnsavedChanges;, &cdeman.DtEditorGetContents;, &cdeman.DtEditorInsert;, &cdeman.DtEditorInsertFromFile;, &cdeman.DtEditorReplace;, &cdeman.DtEditorReplaceFromFile;, &cdeman.DtEditorSetContentsFromFile;, &cdeman.DtEditorSetContents;.</Para>
  214. </RefSect1>
  215. </RefEntry>
  216. <!--fickle 1.12 mancsf-to-docbook 1.2 08/07/95 23:40:24-->