Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / selection.pod
CommitLineData
86530b38
AT
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
10Tk::Selection - Manipulate the X selection
11
12=for category User Interaction
13
14=head1 SYNOPSIS
15
16I<$widget>-E<gt>B<Selection>I<Option>?(I<args>)?
17
18=head1 DESCRIPTION
19
20This command provides an interface to the X selection mechanism and
21implements the full selection functionality described in the
22X Inter-Client Communication Conventions Manual (ICCCM).
23
24The widget object used to invoke the methods below determines which
25display is used to access the selection.
26In order to avoid conflicts with B<selection> methods of widget classes
27(e.g. B<Text>) this set of methods uses the prefix B<Selection>.
28The following methods are currently supported:
29
30=over 4
31
32=item I<$widget>-E<gt>B<SelectionClear>?(B<-selection>=E<gt>I<selection>)?
33
34If I<selection> exists anywhere on I<$widget>'s display, clear it
35so that no window owns the selection anymore. I<Selection>
36specifies the X selection that should be cleared, and should be an
37atom name such as PRIMARY or CLIPBOARD; see the Inter-Client
38Communication Conventions Manual for complete details.
39I<Selection> defaults to PRIMARY.
40Returns an empty string.
41
42=item I<$widget>-E<gt>B<SelectionGet>?(?B<-selection>=E<gt>I<selection>?,?B<-type>=E<gt>I<type>?)?
43
44Retrieves the value of I<selection> from I<$widget>'s display and
45returns it as a result. I<Selection> defaults to PRIMARY.
46
47I<Type> specifies the form in which the selection is to be returned
48(the desired ``target'' for conversion, in ICCCM terminology), and
49should be an atom name such as STRING or FILE_NAME; see the
50Inter-Client Communication Conventions Manual for complete details.
51I<Type> defaults to STRING. The selection owner may choose to
52return the selection in any of several different representation
53formats, such as STRING, ATOM, INTEGER, etc. (this format is different
54than the selection type; see the ICCCM for all the confusing details).
55
56If I<format> is not STRING then things get messy, the following
57description is from the Tcl/Tk man page as yet incompetely translated for
58the perl version - it is misleading at best.
59
60If the selection is returned in a non-string format, such as INTEGER
61or ATOM, the B<SelectionGet> converts it to a list of perl
62values: atoms are converted to their
63textual names, and anything else is converted integers.
64
65A goal of the perl port is to provide better handling of different
66formats than Tcl/Tk does, which should be possible given perl's
67wider range of ``types''. Although some thought went into this
68in very early days of perl/Tk what exactly happens is still
69"not quite right" and subject to change.
70
71=item I<$widget>-E<gt>B<SelectionHandle>(?B<-selection>=E<gt>I<selection>?,?B<-type>=E<gt>I<type>?,?B<-format>=E<gt>I<format>? I<callback>)
72
73Creates a handler for selection requests, such that I<callback> will
74be executed whenever I<selection> is owned by I<$widget> and
75someone attempts to retrieve it in the form given by I<type>
76(e.g. I<type> is specified in the B<selection get> command).
77I<Selection> defaults to PRIMARY, I<type> defaults to STRING, and
78I<format> defaults to STRING. If I<callback> is an empty string
79then any existing handler for I<$widget>, I<type>, and
80I<selection> is removed.
81
82=over 8
83
84When I<selection> is requested, I<$widget> is the selection owner,
85and I<type> is the requested type, I<callback> will be executed
86with two additional arguments.
87The two additional arguments
88are I<offset> and I<maxBytes>: I<offset> specifies a starting
89character position in the selection and I<maxBytes> gives the maximum
90number of bytes to retrieve. The command should return a value consisting
91of at most I<maxBytes> of the selection, starting at position
92I<offset>. For very large selections (larger than I<maxBytes>)
93the selection will be retrieved using several invocations of I<callback>
94with increasing I<offset> values. If I<callback> returns a string
95whose length is less than I<maxBytes>, the return value is assumed to
96include all of the remainder of the selection; if the length of
97I<callback>'s result is equal to I<maxBytes> then
98I<callback> will be invoked again, until it eventually
99returns a result shorter than I<maxBytes>. The value of I<maxBytes>
100will always be relatively large (thousands of bytes).
101
102If I<callback> returns an error (e.g. via B<die>)
103then the selection retrieval is rejected
104just as if the selection didn't exist at all.
105
106The I<format> argument specifies the representation that should be
107used to transmit the selection to the requester (the second column of
108Table 2 of the ICCCM), and defaults to STRING. If I<format> is
109STRING, the selection is transmitted as 8-bit ASCII characters (i.e.
110just in the form returned by I<command>).
111
112If I<format> is not STRING then things get messy, the following
113description is from the Tcl/Tk man page as yet untranslated for
114the perl version - it is misleading at best.
115
116If I<format> is
117ATOM, then the return value from I<command> is divided into fields
118separated by white space; each field is converted to its atom value,
119and the 32-bit atom value is transmitted instead of the atom name.
120For any other I<format>, the return value from I<command> is
121divided into fields separated by white space and each field is
122converted to a 32-bit integer; an array of integers is transmitted
123to the selection requester.
124
125The I<format> argument is needed only for compatibility with
126many selection requesters, except Tcl/Tk. If Tcl/Tk is being
127used to retrieve the selection then the value is converted back to
128a string at the requesting end, so I<format> is
129irrelevant.
130
131A goal of the perl port is to provide better handling of different
132formats than Tcl/Tk does, which should be possible given perl's
133wider range of ``types''. Although some thought went into this
134in very early days of perl/Tk what exactly happens is still
135"not quite right" and subject to change.
136
137=item I<$widget>-E<gt>B<SelectionOwner>?(B<-selection>=E<gt>I<selection>)?
138
139B<SelectionOwner> returns the
140window in this application that owns I<selection> on the display
141containing I<$widget>, or an empty string if no window in this
142application owns the selection. I<Selection> defaults to PRIMARY.
143
144=item I<$widget>-E<gt>B<SelectionOwn>?(?B<-command>=E<gt>I<callback>?,?B<-selection>=E<gt>I<selection>?)?
145
146B<SelectionOwn> causes I<$widget> to become
147the new owner of I<selection> on I<$widget>'s display, returning
148an empty string as result. The existing owner, if any, is notified
149that it has lost the selection.
150If I<callback> is specified, it will be executed when
151some other window claims ownership of the selection away from
152I<$widget>. I<Selection> defaults to PRIMARY.
153
154=back
155
156=back
157
158=head1 KEYWORDS
159
160clear, format, handler, ICCCM, own, selection, target, type
161
162=cut
163