Tk_ClipboardClear(3)

✨ Tk_ClipboardClear β€” Manage the clipboard ✨

okay bestie, welcome to the Tk Library Procedures glow-up πŸŽ€ this one's from the Tk_ClipboardClear(3) page and it's literally all about putting stuff on the clipboard and taking it back off. think of the clipboard as the group chat of data: everybody wants in, but only one app gets to own it at a time πŸ’…


🌸 SYNOPSIS 🌸

#include <tk.h>

int
Tk_ClipboardClear(interp, tkwin)

int
Tk_ClipboardAppend(interp, tkwin, target, format, buffer)

πŸ¦‹ ARGUMENTS πŸ¦‹

  • Tcl_Interp *interp (in) β€” the interpreter you use to report errors. she's the messenger when things go sideways 😭
  • Tk_Window tkwin (in) β€” the window that tells you which display's clipboard you're manipulating. like, which friend's drama are we in rn πŸ’€
  • Atom target (in) β€” the conversion type for this clipboard item; has the exact same meaning as the target argument to Tk_CreateSelHandler. no cap.
  • Atom format (in) β€” the representation to use when data is retrieved; has the exact same meaning as the format argument to Tk_CreateSelHandler.
  • const char *buffer (in) β€” a null-terminated string holding the data you're appending to the clipboard. yes, null terminated, fr fr.

πŸ’– DESCRIPTION πŸ’–

These two procedures manage the clipboard for Tk. the whole vibe is: you call Tk_ClipboardClear once, then call Tk_ClipboardAppend to add data for any number of targets. it's giving "clean slate, then decorate" ✨

Tk_ClipboardClear claims the CLIPBOARD selection and frees any data items previously stored on the clipboard in this application. she normally returns TCL_OK, but if an error occurs she returns TCL_ERROR and leaves an error message in interpreter interp's result. important: Tk_ClipboardClear must be called before a sequence of Tk_ClipboardAppend calls can be issued. like, she goes first. main character energy πŸ‘‘

Tk_ClipboardAppend appends a buffer of data to the clipboard. the first buffer for a given target determines the format for that target. any successive appends for that target must have the same format or an error will be returned β€” consistency is key, bestie πŸ™ˆ Tk_ClipboardAppend returns TCL_OK if the buffer is successfully copied onto the clipboard. but if the clipboard is not currently owned by the application β€” either because Tk_ClipboardClear has not been called, or because ownership of the clipboard has changed since the last call to Tk_ClipboardClear β€” then Tk_ClipboardAppend returns TCL_ERROR and leaves an error message in the result of interpreter interp. awkward, but she had to say it πŸ’€

In order to guarantee atomicity, no event handling should occur between Tk_ClipboardClear and the following Tk_ClipboardAppend calls (otherwise someone could retrieve a partially completed clipboard or claim ownership away from this application). so like, don't go taking snack breaks mid-sequence, okay? πŸ”₯

⚠️ watch out: Tk_ClipboardClear may invoke callbacks, including arbitrary Tcl scripts, as a result of losing the CLIPBOARD selection, so any calling function should take care to be re-entrant at the point Tk_ClipboardClear is invoked. this one's highkey important β€” she can re-enter on you, so be ready 🫢

🌈 KEYWORDS 🌈

append, clipboard, clear, format, type


alright that's the whole page, you ate that πŸ’… this was Tk, version 4.0, dated with the Tk_ClipboardClear(3) footer β€” go forth and claim that clipboard, queen πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from