DTEDITORGETCONTENTS(3)
okay so welcome to DtEditorGetContents(library call) β the library call that yoinks the whole contents of a DtEditor widget out into your hands, and yes, it's a whole vibe π
πΈ NAME
DtEditorGetContents β retrieve the contents of a DtEditor widget. That's the whole assignment, bestie: get the contents, no cap. β¨
π¦ SYNOPSIS
#include &<Dt/Editor.h>
DtEditorErrorCode DtEditorGetContents(
Widget widget,
DtEditorContentRec *data,
Boolean hardCarriageReturns,
Boolean markContentsAsSaved);
π DESCRIPTION
okay so DtEditorGetContents grabs the entire contents of a DtEditor widget and hands it over as a string, a wide character string, or a sized buffer of data. The transfer goes through a DtEditorContentRec β that struct tells you what kind of data is moving and carries the actual data too. If you want, any soft line feeds (word wraps) can be swapped for <newline>s. π
The DtEditor widget keeps receipts on whether its contents have changed since they were last saved or retrieved. If you set markContentsAsSaved to True, you get a copy of the data without messing with whether DtEditorCheckForUnsavedChanges(3) says there are unsaved changes. That's lowkey perfect when the app just needs a temporary copy. π
Here are the arguments, bestie:
widgetβ the DtEditor widget ID. That's your main character. πdataβ pointer to a data structure that receives the contents ofwidget. It's giving "here's your data bucket" πͺ£hardCarriageReturnsβ set it toTrueand the DtEditor widget should replace any soft line feeds (word wraps) with<newline>s when saving the data. Set it toFalseand any line that wrapped because it reached the right edge of the window gets saved as one complete line. No cap. πmarkContentsAsSavedβ set it toTrueand the DtEditor widget marks that all changes made to date have been saved. Set it toFalseand the DtEditor widget does not change its status regarding unsaved changes. Periodt. β
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). Go read the source of truth, bestie. π
π₯ RETURN VALUE
Upon successful completion, DtEditorGetContents returns DtEDITOR_NO_ERRORS. Otherwise, it returns DtEDITOR_INVALID_TYPE if the Type field is not recognized. That's the whole return vibe check β if you see DtEDITOR_INVALID_TYPE, the Type field did not pass. π
π EXAMPLES
The following code segment retrieves the contents of a DtEditor widget, marking that all changes to date have been saved. Copied exactly, character for character, weird bits and all β no edits from me, fr fr. π
Widget editor;
DtEditorContentRec cr;
DtEditorErrorCode status;
Boolean markContentsAsSaved = True;
cr.type = DtEDITOR_TEXT;
status = DtEditorGetContents(editor, &&cr, False, markContentsAsSaved);
if (status == DtEDITOR_NO_ERRORS)
printf("The contents are:1s0, cr.value.string);
else
printf("Unable to retrieve contents of the widget0);
π¦ APPLICATION USAGE
To write the data directly to a file, the application should use DtEditorSaveContentsToFile(3). That's the move β don't reinvent the file-writing arc. π«Ά
π SEE ALSO
Go say hi to:
Dt/Editor.h - DtEditor(5)DtEditor(3)DtEditorAppend(3)DtEditorAppendFromFile(3)DtEditorCheckForUnsavedChanges(3)DtEditorInsert(3)DtEditorInsertFromFile(3)DtEditorReplace(3)DtEditorReplaceFromFile(3)DtEditorSaveContentsToFile(3)DtEditorSetContents(3)DtEditorSetContentsFromFile(3)
that's the page, bestie β source/version: DtEditorGetContents(library call); date: not listed in the original footer, so we're keeping it mysterious slay π«Άβ¨
π¦ where this page comes from
- nixos 26.05: cde 2.5.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms