DTEDITORGETCONTENTS(3)

πŸ“¦
version 2.5.3 Β· 2 versions
, in nixos 26.05

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 of widget. It's giving "here's your data bucket" πŸͺ£
  • hardCarriageReturns β€” set it to True and the DtEditor widget should replace any soft line feeds (word wraps) with <newline>s when saving the data. Set it to False and any line that wrapped because it reached the right edge of the window gets saved as one complete line. No cap. πŸ“
  • markContentsAsSaved β€” set it to True and the DtEditor widget marks that all changes made to date have been saved. Set it to False and 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:

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