Tk_GetSelection(3tk)
πΈ NAME πΈ
okay so bestie, this is Tk_GetSelection β the Tk Library Procedures page for it, page Tk_GetSelection(3tk) β and it does exactly one iconic thing: it retrieves the contents of a selection. that's it. that's the whole gig. π
β¨ SYNOPSIS β¨
#include <tk.h>
int
Tk_GetSelection(interp, tkwin, selection, target, proc, clientData)
π ARGUMENTS π
Tcl_Interp *interp(in) β the interpreter we use for reporting errors. she's the one holding the receipts when something goes wrong. πTk_Window tkwin(in) β the window on whose behalf we're retrieving the selection. this is what determines the display we retrieve from. no cap, it's doing the heavy lifting of figuring out where to look. πͺAtom selection(in) β the name of the selection to be retrieved. like, which selection. π―Atom target(in) β the form in which to retrieve the selection. β¨Tk_GetSelProc *proc(in) β the procedure to invoke to process pieces of the selection as they are retrieved. she gets called piece by piece, queen behavior. πvoid *clientData(in) β arbitrary one-word value to pass toproc. literally whatever you want, she doesn't judge. π«Ά
π DESCRIPTION π
Tk_GetSelection retrieves the selection specified by the atom selection, in the format specified by target. and here's the tea: the selection may actually be retrieved in several pieces. as each piece comes in, proc is called to process that piece. so it's not one big dump, it's a lil drip-feed situation. π§οΈ
proc should have arguments and result that match the type Tk_GetSelProc:
typedef int Tk_GetSelProc(
void *clientData,
Tcl_Interp *interp,
char *portion);
the clientData and interp parameters passed to proc will be copies of the corresponding arguments to Tk_GetSelection. portion will be a pointer to a string containing part or all of the selection. for large selections, proc will be called several times with successive portions of the selection β so pace yourself, she's feeding you bites. π
so the X Inter-Client Communication Conventions Manual allows a selection to be returned in formats other than strings, e.g. as an array of atoms or integers. and if that happens? Tk converts the selection back into a string before calling proc. specifically:
- if a selection is returned as an array of atoms, Tk converts it to a string containing the atom names separated by white space. π
- for any other format besides string, Tk converts a selection to a string containing hexadecimal values separated by white space. π₯
Tk_GetSelection returns to its caller when the selection has been completely retrieved and processed by proc, or when a fatal error has occurred (e.g. the selection owner did not respond promptly β rude, honestly π).
Tk_GetSelection normally returns TCL_OK; if an error occurs, it returns TCL_ERROR and leaves an error message in interpreter interp's result.
procshould also return eitherTCL_OKorTCL_ERROR. ifprocencounters an error in dealing with the selection, it should leave an error message in the interpreter result and returnTCL_ERROR; this will abort the selection retrieval. so yeah, that return value matters, don't be sloppy with it bestie. π
π KEYWORDS π
format, get, selection retrieval
and that's the whole page, fr fr. this manual page came to you from Tk, version 4.0 β Tk_GetSelection(3tk) β and yes, she's iconic, she's giving vintage-but-still-slays, and she said what she said. go retrieve a selection. mwah. πβ¨π
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms