selection

Manipulate the X selection

SYNOPSIS

(selection option ?arg arg ...?)

DESCRIPTION

This procedure provides a STk interface to the X selection mechanism and implements the full selection functionality described in the X Inter-Client Communication Conventions Manual (ICCCM).

The first argument to selection determines the format of the rest of the arguments and the behavior of the procedure. The following forms are currently supported:

(selection 'clear ?:displayof window? ?:selection selection?)
If selection exists anywhere on window's display, clear it so that no window owns the selection anymore. Selection specifies the X selection that should be cleared, and should be an atom name such as PRIMARY or CLIPBOARD; see the Inter-Client Communication Conventions Manual for complete details. Selection defaults to PRIMARY and window defaults to ``.''. Returns an empty list.

(selection 'get ?:displayof window? ?:selection selection? ?:type type?)
Retrieves the value of selection from window's display and returns it as a result. Selection defaults to PRIMARY and window defaults to ``*root*''. Type specifies the form in which the selection is to be returned (the desired ``target'' for conversion, in ICCCM terminology), and should be an atom name such as STRING or FILE_NAME; see the Inter-Client Communication Conventions Manual for complete details. Type defaults to STRING. The selection owner may choose to return the selection in any of several different representation formats, such as STRING, ATOM, INTEGER, etc. (this format is different than the selection type; see the ICCCM for all the confusing details). If the selection is returned in a non-string format, such as INTEGER or ATOM, the selection procedure converts it to string format as a collection of fields separated by spaces: atoms are converted to their textual names, and anything else is converted to hexadecimal integers.

(selection 'handle ?:selection selection? ?:type type? ?:format format? window procedure)
Creates a handler for selection requests, such that procedure will be executed whenever selection is owned by window and someone attempts to retrieve it in the form given by type (e.g. type is specified in the selection get procedure). Selection defaults to PRIMARY, type defaults to STRING, and format defaults to STRING. If procedure is an empty string then any existing handler for window, type, and selection is removed.

(selection 'own ?:displayof window? ?:selection selection?)
(selection 'own ?:procedure procedure? ?:selection selection? window)
The first form of selection own returns the path name of the window in this application that owns selection on the display containing window, or #f if no window in this application owns the selection. Selection defaults to "PRIMARY" and window defaults to ``*root*''.


The second form of selection own causes window to become the new owner of selection on window's display, returning an empty list as result. The existing owner, if any, is notified that it has lost the selection. If procedure is specified, it is a STk script to execute when some other window claims ownership of the selection away from window. Selection defaults to "PRIMARY".

Back to the STk main page