SDL_GetPrimarySelectionText(3)

✨ SDL_GetPrimarySelectionText ✨

okay bestie, so this one lives in the SDL3 FUNCTIONS corner of the SDL_GetPrimarySelectionText(3) manual, and it's literally the vibe: get UTF-8 text from the primary selection. πŸ’–


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_clipboard.h>

char * SDL_GetPrimarySelectionText(void);

no args, no stress, just a void and a dream. 🫢


πŸ’… DESCRIPTION πŸ’…

so like, this function hands you the primary selection's content as UTF-8 text.

and here's the tea πŸ“: if there is not enough memory left for a copy of the primary selection's content, it returns an empty string. yes, that's the fail state. it's giving "quiet quitting" but make it a char *.


πŸ‘‘ RETURN VALUE πŸ‘‘

  • on success β€” you get the primary selection text ✨
  • on failure β€” you get an empty string 😭 and you should call SDL_GetError() for more information, fr fr

and listen β€” when you're done with it, it should be freed with SDL_free(). no cap. do not leave it hanging, that's not the move. 🧚


🧡 THREAD SAFETY 🧡

⚠️ this function should only be called on the main thread. main character energy only, bestie. do not bring your little background threads to this party. πŸ’€

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. iconic. historic. periodt. πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹

iykyk β€” go read those next, they're the whole squad. πŸŽ€


kisses, and remember: free your strings, protect your main thread, and stay hydrated πŸ’–βœ¨

this has been your girl, bringing you Simple Directmedia Layer β€” SDL 3.4.18 β€” SDL_GetPrimarySelectionText(3). slay, bye! πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from