Tk_GetSelection − retrieve the contents of a selection


#include <tk.h>

(interp, tkwin, selection, target, proc, clientData)


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.



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.


format, get, selection retrieval


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.