| 1 |
# Copyright (c) 1990-1994 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 3 |
# See the file "license.terms" for information on usage and redistribution |
| 4 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 5 |
# |
| 6 |
# |
| 7 |
|
| 8 |
=head1 NAME |
| 9 |
|
| 10 |
Tk_GetSelection - retrieve the contents of a selection |
| 11 |
|
| 12 |
=for category C Programming |
| 13 |
|
| 14 |
=head1 SYNOPSIS |
| 15 |
|
| 16 |
B<#include E<lt>tk.hE<gt>> |
| 17 |
|
| 18 |
int |
| 19 |
B<Tk_GetSelection>(I<interp, tkwin, selection, target, proc, clientData>) |
| 20 |
|
| 21 |
=head1 ARGUMENTS |
| 22 |
|
| 23 |
=over 4 |
| 24 |
|
| 25 |
=item Tcl_Interp *interp (in) |
| 26 |
|
| 27 |
Interpreter to use for reporting errors. |
| 28 |
|
| 29 |
=item Tk_Window tkwin (in) |
| 30 |
|
| 31 |
Window on whose behalf to retrieve the selection (determines |
| 32 |
display from which to retrieve). |
| 33 |
|
| 34 |
=item Atom selection (in) |
| 35 |
|
| 36 |
The name of the selection to be retrieved. |
| 37 |
|
| 38 |
=item Atom target (in) |
| 39 |
|
| 40 |
Form in which to retrieve selection. |
| 41 |
|
| 42 |
=item Tk_GetSelProc *proc (in) |
| 43 |
|
| 44 |
Procedure to invoke to process pieces of the selection as they |
| 45 |
are retrieved. |
| 46 |
|
| 47 |
=item ClientData clientData (in) |
| 48 |
|
| 49 |
Arbitrary one-word value to pass to I<proc>. |
| 50 |
|
| 51 |
=back |
| 52 |
|
| 53 |
=head1 DESCRIPTION |
| 54 |
|
| 55 |
B<Tk_GetSelection> retrieves the selection specified by the atom |
| 56 |
I<selection> in the format specified by I<target>. The |
| 57 |
selection may actually be retrieved in several pieces; as each piece |
| 58 |
is retrieved, I<proc> is called to process the piece. I<Proc> |
| 59 |
should have arguments and result that match the type |
| 60 |
B<Tk_GetSelProc>: |
| 61 |
|
| 62 |
typedef int Tk_GetSelProc( |
| 63 |
ClientData clientData, |
| 64 |
Tcl_Interp *interp, |
| 65 |
char *portion); |
| 66 |
|
| 67 |
The I<clientData> and I<interp> parameters to I<proc> |
| 68 |
will be copies of the corresponding arguments to |
| 69 |
B<Tk_GetSelection>. I<Portion> will be a pointer to |
| 70 |
a string containing part or all of the selection. For large |
| 71 |
selections, I<proc> will be called several times with successive |
| 72 |
portions of the selection. The X Inter-Client Communication |
| 73 |
Conventions Manual allows a selection to be returned in formats |
| 74 |
other than strings, e.g. as an array of atoms or integers. If |
| 75 |
this happens, Tk converts the selection back into a string |
| 76 |
before calling I<proc>. If a selection is returned as an |
| 77 |
array of atoms, Tk converts it to a string containing the atom names |
| 78 |
separated by white space. For any other format besides string, |
| 79 |
Tk converts a selection to a string containing hexadecimal |
| 80 |
values separated by white space. |
| 81 |
|
| 82 |
B<Tk_GetSelection> returns to its caller when the selection has |
| 83 |
been completely retrieved and processed by I<proc>, or when a |
| 84 |
fatal error has occurred (e.g. the selection owner didn't respond |
| 85 |
promptly). B<Tk_GetSelection> normally returns TCL_OK; if |
| 86 |
an error occurs, it returns TCL_ERROR and leaves an error message |
| 87 |
in I<interp-E<gt>result>. I<Proc> should also return either |
| 88 |
TCL_OK or TCL_ERROR. If I<proc> encounters an error in dealing with the |
| 89 |
selection, it should leave an error message in I<interp-E<gt>result> |
| 90 |
and return TCL_ERROR; this will abort the selection retrieval. |
| 91 |
|
| 92 |
=head1 KEYWORDS |
| 93 |
|
| 94 |
format, get, selection retrieval |