Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

DtEditorGetContents(3)  —  Subroutines

CDE

NAME

DtEditorGetContents − retrieve the contents of a DtEditor widget

SYNOPSIS

#include <Dt/Editor.h> DtEditorErrorCode DtEditorGetContents(Widget widget,  DtEditorContentRec ∗data,  Boolean hardCarriageReturns,  Boolean markContentsAsSaved);

DESCRIPTION

The DtEditorGetContents function retrieves the entire contents of a DtEditor widget as a string, wide character string or sized buffer of data.  The data is transferred from the DtEditor widget using a DtEditorContentRec, which indicates the type of data being transferred along with the actual data.  If desired, any soft line feeds (word wraps) can be replaced with newline s. 

The DtEditor widget tracks whether its contents have changed since they were last saved or retrieved.  Setting the markContentsAsSaved argument to True retrieves a copy of the data without affecting whether DtEditorCheckForUnsavedChanges3 reports that there are unsaved changes.  This is useful if the application needs a temporary copy of the contents. 

The widget argument specifies the DtEditor widget ID. 

The data argument is a pointer to a data structure to receive the contents of widget. 

The hardCarriageReturns argument, if set to True, indicates that the DtEditor widget should replace any soft line feeds (word wraps) with newline s when saving the data.  When hardCarriageReturns 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, if set to True, causes the DtEditor widget to mark that all changes made to date have been saved.  When markContentsAsSaved is set to False, the DtEditor widget does not change its status regarding unsaved changes. 

For a complete definition of the DtEditor widget and its associated resources, see DtEditor3. 

For a complete definition of DtEditorContentRec, see Dt/Editor5. 

RETURN VALUE

Upon successful completion, the DtEditorGetContents function returns DtEDITOR_­NO_ERRORS; otherwise, it returns DtEDITOR_INVALID_TYPE if the Type field is not recognized. 

EXAMPLES

The following code segment retrieves the contents of a DtEditor widget, marking that all changes to date have been saved. 

Widget                  editor;
DtEditorContentRec      cr;
DtEditorErrorCode       status;
Boolean                 markContentsAsSaved = True;
cr.type = DtEDITOR_TEXT;
status = DtEditorGetContents(editor, &cr, markContentsAsSaved);
if (status == DtEDITOR_NO_ERRORS)
        printf("The contents are:\n%s\n", cr.value.string);
else
        printf("Unable to retrieve contents of the widget\n");

APPLICATION USAGE

To write the data directly to a file, the application should use DtEditorSaveContentsToFile3. 

SEE ALSO

Dt/Editor.h5, DtEditor3, DtEditorAppend3, DtEditorAppendFromFile3, DtEditorCheckForUnsavedChanges3, DtEditorInsert3, DtEditorInsertFromFile3, DtEditorReplace3, DtEditorReplaceFromFile3, DtEditorSaveContentsToFile3, DtEditorSetContents3, DtEditorSetContentsFromFile3. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026