Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dteditorsetcontents(3) [hpux man page]

DtEditorSetContents(library call)										 DtEditorSetContents(library call)

NAME
DtEditorSetContents -- place data into a DtEditor widget SYNOPSIS
#include <Dt/Editor.h> DtEditorErrorCode DtEditorSetContents( Widget widget, DtEditorContentRec *data); DESCRIPTION
The DtEditorSetContents function places a NULL-terminated string, wide character string or sized buffer into a DtEditor widget. Any data currently in the DtEditor widget is lost. The data is transferred to the DtEditor widget using a DtEditorContentRec, which indicates the type of data being transferred along with the actual data. After the data is placed into the DtEditor widget, the insertion cursor is positioned at the first character. The widget argument specifies the DtEditor widget ID. The data argument is a pointer to a data structure containing the new contents of widget. For a complete definition of the DtEditor widget and its associated resources, see DtEditor(3). For a complete definition of DtEditorContentRec, see Dt/Editor.h - DtEditor(5). RETURN VALUE
Upon successful completion, the DtEditorSetContents function returns one of the following values: DtEDITOR_NO_ERRORS The data was loaded sucessfully. DtEDITOR_NULLS_REMOVED NULL characters were found and removed from the data. Otherwise, if the DtEditorSetContents function cannot load the data in the DtEditor widget, it returns one of the following values: DtEDITOR_INVALID_TYPE The Type field is unrecognized. DtEDITOR_ILLEGAL_SIZE The size of the buffer passed in is negative. DtEDITOR_NULL_ITEM The buffer is NULL. DtEDITOR_INSUFFICIENT_MEMORY Not enough system memory is available to load the data. EXAMPLES
The following code segment sets the contents of a DtEditor widget to ``The quick brown fox.'' Widget editor; DtEditorContentRec cr; DtEditorErrorCode status; char *sampleString="The quick brown fox"; cr.type = DtEDITOR_TEXT; cr.value.string = sampleString; status = DtEditorSetContents(editor, &cr); if (status != DtEDITOR_NO_ERRORS && status != DtEDITOR_NULLS_REMOVED) { printf("Unable to set contents of the widget "); APPLICATION USAGE
If the data is in a disk file, rather than in memory, the application should use DtEditorSetContentsFromFile(3). SEE ALSO
Dt/Editor.h - DtEditor(5), DtEditor(3), DtEditorAppend(3), DtEditorAppendFromFile(3), DtEditorGetContents(3), DtEditorInsert(3), DtEdi- torInsertFromFile(3), DtEditorReplace(3), DtEditorReplaceFromFile(3), DtEditorSaveContentsToFile(3), DtEditorSetContentsFromFile(3). DtEditorSetContents(library call)

Check Out this Related Man Page

DtEditorSaveContentsToFile(library call)								  DtEditorSaveContentsToFile(library call)

NAME
DtEditorSaveContentsToFile -- save the contents of a DtEditor widget to a file SYNOPSIS
#include <Dt/Editor.h> DtEditorErrorCode DtEditorSaveContentsToFile( Widget widget, char *fileName, Boolean overwriteIfExists, Boolean hardCarriageReturns, Boolean markContentsAsSaved); DESCRIPTION
The DtEditorSaveContentsToFile function saves the entire contents of the DtEditor widget to a file, optionally replacing soft line feeds (word wraps) with <newline>s. If the file does not exist and the directory has the correct write permissions, the file is created. If the file exists and the overwriteIfExists argument is set to True, the contents of the file are overwritten. If the file or its directory does not have the correct write permissions, an error is returned. The DtEditor widget tracks whether its contents have changed since they were last saved or retrieved. If the markContentsAsSaved argument is set to False, a copy of the data is saved without affecting whether DtEditorCheckForUnsavedChanges(3) reports that there are unsaved changes. This is useful if the application needs to save a copy of the contents to a temporary file. The widget argument specifies the DtEditor widget ID. The fileName argument is the pathname of the file relative to the local system. The overwriteIfExists argument, if set to True, causes DtEditorSaveContentsToFile to save the widget contents even though the file speci- fied by the fileName argument exists and has correct write permissions. If this argument is set to False, DtEditorSaveContentsToFile returns DtEDITOR_WRITABLE_FILE. The hardCarriageReturns argument, if set to True, indicates that the widget should replace any soft line feeds (word wraps) with <newline>s when saving the data. When this argument is set to False, any line wrapped because it reaches the right edge of the window, is saved as one complete line. The markContentsAsSaved argument, when set to True, causes the DtEditor widget to mark that all changes made to date have been saved. When this argument is set to False, the DtEditor widget does not change its status regarding unsaved changes. If an error arises during the save, the status does not change, regardless of the value of the markContentsAsSaved argument. For a complete definition of the DtEditor widget and its associated resources, see DtEditor(3). RETURN VALUE
Upon successful completion, the DtEditorSaveContentsToFile function returns DtEDITOR_NO_ERRORS; otherwise, if it cannot save the data to the file, the function returns one of the following values: DtEDITOR_INVALID_FILENAME No file was specified. DtEDITOR_UNWRITABLE_FILE The application does not have write permission for the file or directory. DtEDITOR_CHAR_SPECIAL_FILE The file is a device-special file. DtEDITOR_BLOCK_MODE_FILE The file is a block-mode device. DtEDITOR_NO_FILE_ACCESS The file cannot be accessed. DtEDITOR_SAVE_FAILED The contents could not be saved for an unspecified reason. DtEDITOR_WRITABLE_FILE The named files exist and the overwriteIfExists argument is set to False. EXAMPLES
The following code segment saves the contents of a DtEditor widget to the local file, Foo, substituting <newline>s for soft line feeds. It also indicates that all changes to the contents of the widget have been saved. Widget editor; DtEditorErrorCode status; char *fname = "Foo"; Boolean overwrite = False, hardReturns = True, markContentsAsSaved = True; status = DtEditorSaveContentsToFile(editor, fname, overwrite, hardReturns, markContentsAsSaved); switch(status) { case DtEDITOR_NO_ERRORS: break; case DtEDITOR_WRITABLE_FILE: printf("Save failed. The file already exists. "); break; default: printf("Could not save contents. "); break; } APPLICATION USAGE
The application should use DtEditorGetContents(3) to retrieve the data in a memory buffer, rather than a disk file. SEE ALSO
Dt/Editor.h - DtEditor(5), DtEditor(3), DtEditorAppend(3), DtEditorAppendFromFile(3), DtEditorCheckForUnsavedChanges(3), DtEditorGetCon- tents(3), DtEditorInsert(3), DtEditorInsertFromFile(3), DtEditorReplace(3), DtEditorReplaceFromFile(3), DtEditorSetContentsFromFile(3), DtEditorSetContents(3). DtEditorSaveContentsToFile(library call)
Man Page