Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tk_getselection(3) [mojave man page]

Tk_GetSelection(3)					       Tk Library Procedures						Tk_GetSelection(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_GetSelection - retrieve the contents of a selection SYNOPSIS
#include <tk.h> int Tk_GetSelection(interp, tkwin, selection, target, proc, clientData) ARGUMENTS
Tcl_Interp *interp (in) Interpreter to use for reporting errors. Tk_Window tkwin (in) Window on whose behalf to retrieve the selection (determines display from which to retrieve). Atom selection (in) The name of the selection to be retrieved. Atom target (in) Form in which to retrieve selection. Tk_GetSelProc *proc (in) Procedure to invoke to process pieces of the selection as they are retrieved. ClientData clientData (in) Arbitrary one-word value to pass to proc. _________________________________________________________________ DESCRIPTION
Tk_GetSelection retrieves the selection specified by the atom selection in the format specified by target. The selection may actually be retrieved in several pieces; as each piece is retrieved, proc is called to process the piece. Proc should have arguments and result that match the type Tk_GetSelProc: typedef int Tk_GetSelProc( ClientData clientData, Tcl_Interp *interp, char *portion); The clientData and interp parameters 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. 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. If this happens, Tk converts the selection back into a string before calling proc. 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). Tk_GetSelection normally returns TCL_OK; if an error occurs, it returns TCL_ERROR and leaves an error message in interp->result. Proc should also return either TCL_OK or TCL_ERROR. If proc encounters an error in dealing with the selection, it should leave an error message in interp->result and return TCL_ERROR; this will abort the selection retrieval. KEYWORDS
format, get, selection retrieval Tk 4.0 Tk_GetSelection(3)

Check Out this Related Man Page

Tk_CreateSelHandler(3)					       Tk Library Procedures					    Tk_CreateSelHandler(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_CreateSelHandler, Tk_DeleteSelHandler - arrange to handle requests for a selection SYNOPSIS
#include <tk.h> Tk_CreateSelHandler(tkwin, selection, target, proc, clientData, format) Tk_DeleteSelHandler(tkwin, selection, target) ARGUMENTS
Tk_Window tkwin (in) Window for which proc will provide selection information. Atom selection (in) The name of the selection for which proc will provide selection information. Atom target (in) Form in which proc can provide the selection (e.g. STRING or FILE_NAME). Corresponds to type arguments in selection commands. Tk_SelectionProc *proc (in) Procedure to invoke whenever the selection is owned by tkwin and the selection contents are requested in the format given by target. ClientData clientData (in) Arbitrary one-word value to pass to proc. Atom format (in) If the selection requestor is not in this process, format determines the representation used to transmit the selection to its requestor. _________________________________________________________________ DESCRIPTION
Tk_CreateSelHandler arranges for a particular procedure (proc) to be called whenever selection is owned by tkwin and the selection contents are requested in the form given by target. Target should be one of the entries defined in the left column of Table 2 of the X Inter-Client Communication Conventions Manual (ICCCM) or any other form in which an application is willing to present the selection. The most common form is STRING. Proc should have arguments and result that match the type Tk_SelectionProc: typedef int Tk_SelectionProc( ClientData clientData, int offset, char *buffer, int maxBytes); The clientData parameter to proc is a copy of the clientData argument given to Tk_CreateSelHandler. Typically, clientData points to a data structure containing application-specific information that is needed to retrieve the selection. Offset specifies an offset position into the selection, buffer specifies a location at which to copy information about the selection, and maxBytes specifies the amount of space available at buffer. Proc should place a NULL-terminated string at buffer containing maxBytes or fewer characters (not including the ter- minating NULL), and it should return a count of the number of non-NULL characters stored at buffer. If the selection no longer exists (e.g. it once existed but the user deleted the range of characters containing it), then proc should return -1. When transferring large selections, Tk will break them up into smaller pieces (typically a few thousand bytes each) for more efficient transmission. It will do this by calling proc one or more times, using successively higher values of offset to retrieve successive por- tions of the selection. If proc returns a count less than maxBytes it means that the entire remainder of the selection has been returned. If proc's return value is maxBytes it means there may be additional information in the selection, so Tk must make another call to proc to retrieve the next portion. Proc always returns selection information in the form of a character string. However, the ICCCM allows for information to be transmitted from the selection owner to the selection requestor in any of several formats, such as a string, an array of atoms, an array of integers, etc. The format argument to Tk_CreateSelHandler indicates what format should be used to transmit the selection to its requestor (see the middle column of Table 2 of the ICCCM for examples). If format is not STRING, then Tk will take the value returned by proc and divided it into fields separated by white space. If format is ATOM, then Tk will return the selection as an array of atoms, with each field in proc's result treated as the name of one atom. For any other value of format, Tk will return the selection as an array of 32-bit values where each field of proc's result is treated as a number and translated to a 32-bit value. In any event, the format atom is returned to the selection requestor along with the contents of the selection. If Tk_CreateSelHandler is called when there already exists a handler for selection and target on tkwin, then the existing handler is replaced with a new one. Tk_DeleteSelHandler removes the handler given by tkwin, selection, and target, if such a handler exists. If there is no such handler then it has no effect. KEYWORDS
format, handler, selection, target Tk 4.0 Tk_CreateSelHandler(3)
Man Page