DTEDITORINSERT(3)

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

okay bestie, welcome to the DtEditorInsert(library call) page β€” the manual name is folded in right here at the top so we can get straight to the group-chat tea πŸ«–βœ¨

🌸 NAME 🌸

DtEditorInsert β€” insert data into a DtEditor widget. literally the moment you slide new content into the widget at the insertion cursor, no cap πŸ’…

✨ SYNOPSIS ✨

okay so you include this and call it like this, fr fr:

#include &<Dt/Editor.h>
DtEditorErrorCode DtEditorInsert(
Widget widget,
DtEditorContentRec *data);

πŸŽ€ DESCRIPTION πŸŽ€

so the way that DtEditorInsert works is: it inserts either a string, a wide character string or a sized buffer at the insertion cursor position in a DtEditor widget. it’s giving precision placement, iconic behavior 🎯✨

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 appended, the insertion cursor is positioned after the last character inserted. periodt πŸ’–

  • widget β€” the DtEditor widget ID. that’s your main-character widget right there πŸ‘‘
  • data β€” a pointer to a data structure containing the data to insert. lowkey straightforward 🫢

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). iykyk πŸ“š

πŸ”₯ RETURN VALUE πŸ”₯

Upon successful completion, the DtEditorInsert function returns one of the following values:

  • DtEDITOR_NO_ERRORS β€” the data was inserted sucessfully. slay βœ…
  • DtEDITOR_NULLS_REMOVED β€” NULL characters were found and removed from the data. cleanup queen 🧼

Otherwise, if the DtEditorInsert function cannot insert the data into the DtEditor widget, it returns one of the following values:

  • DtEDITOR_INVALID_TYPE β€” the Type field is not recognized. 🚩
  • DtEDITOR_ILLEGAL_SIZE β€” the size of the buffer passed in is negative. yeah, negative is not the move πŸ’€
  • DtEDITOR_NULL_ITEM β€” the buffer is NULL. 🫠
  • DtEDITOR_INSUFFICIENT_MEMORY β€” not enough system memory is available to insert the data. 😭

πŸ¦‹ EXAMPLES πŸ¦‹

The following code segment sets the contents of a DtEditor widget to The quick brown fox. β€” yes bestie, the classic pangram moment 🦊✨

Widget                  editor;
DtEditorContentRec      cr;
DtEditorErrorCode       status;
char                    *sampleString1="The brown fox",
                        *sampleString2=" quick";
cr.type = DtEDITOR_TEXT;
cr.value.string = sampleString1;
status = DtEditorSetContents(editor, &&cr);
if (status != DtEDITOR_NO_ERRORS &&&& status != DtEDITOR_NULLS_REMOVED) {
        printf("Unable to set contents of the widget0);
} else {
  /*
   * Move the insertion cursor so it is after the
   * letter 'e' in "The".
   */
        DtEditorSetInsertionCursorPosition(editor, 2);
        cr.type = DtEDITOR_TEXT;
        cr.data.string = sampleString2;
        status = DtEditorInsert(editor, &&cr);
        if (status != DtEDITOR_NO_ERRORS)
          printf("Unable to insert into the contents of the widget0);
}

🌈 APPLICATION USAGE 🌈

If the data is in a disk file, rather than in memory, the application should use DtEditorInsertFromFile(3). that’s the move per the manual, bestie πŸ’Ύβœ¨

πŸ’œ SEE ALSO πŸ’œ

the whole friend group is here, no cap:


okay bestie, that’s the DtEditorInsert(library call) page β€” the footer has no version or date stamp to spill, just that same library call energy, so this is your cute sign-off: go insert something iconic and be the main character of your widget πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from