Debian Codegraph @

info/gcl-tk/selection.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>selection (GCL TK Manual)</title>
7
8 <meta name="description" content="selection (GCL TK Manual)">
9 <meta name="keywords" content="selection (GCL TK Manual)">
10 <meta name="resource-type" content="document">
11 <meta name="distribution" content="global">
12 <meta name="Generator" content="makeinfo">
13 <link href="index.html" rel="start" title="Top">
14 <link href="wm.html#SEC_Contents" rel="contents" title="Table of Contents">
15 <link href="Control.html" rel="up" title="Control">
16 <link href="send.html" rel="next" title="send">
17 <link href="raise.html" rel="prev" title="raise">
18 <style type="text/css">
19 <!--
20 a.summary-letter {text-decoration: none}
21 blockquote.indentedblock {margin-right: 0em}
22 div.display {margin-left: 3.2em}
23 div.example {margin-left: 3.2em}
24 div.lisp {margin-left: 3.2em}
25 kbd {font-style: oblique}
26 pre.display {font-family: inherit}
27 pre.format {font-family: inherit}
28 pre.menu-comment {font-family: serif}
29 pre.menu-preformatted {font-family: serif}
30 span.nolinebreak {white-space: nowrap}
31 span.roman {font-family: initial; font-weight: normal}
32 span.sansserif {font-family: sans-serif; font-weight: normal}
33 ul.no-bullet {list-style: none}
34 -->
35 </style>
36
37
38 </head>
39
40 <body lang="en">
41 <span id="selection"></span><div class="header">
42 <p>
43 Next: <a href="send.html" accesskey="n" rel="next">send</a>, Previous: <a href="raise.html" accesskey="p" rel="prev">raise</a>, Up: <a href="Control.html" accesskey="u" rel="up">Control</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
44 </div>
45 <hr>
46 <span id="selection-1"></span><h3 class="section">3.17 selection</h3>
47
48 <p>selection \- Manipulate the X selection
49 </p><span id="Synopsis-30"></span><h4 class="unnumberedsubsec">Synopsis</h4>
50 <p><b>selection </b><i>option</i><span class="roman"> ?</span><i>arg arg ...</i>?
51 </p>
52 <span id="Description-28"></span><h4 class="unnumberedsubsec">Description</h4>
53
54 <p>This command provides a Tcl interface to the X selection mechanism and
55 implements the full selection functionality described in the
56 X Inter-Client Communication Conventions Manual (ICCCM), except that it
57 supports only the primary selection.
58 </p>
59 <p>The first argument to <b>selection</b> determines the format of the
60 rest of the arguments and the behavior of the command. The following
61 forms are currently supported:
62 </p>
63 <dl compact="compact">
64 <dt><b>selection :clear </b><i>window</i></dt>
65 <dd><p>If there is a selection anywhere on <i>window</i>&rsquo;s display, clear it
66 so that no window owns the selection anymore. Returns an empty string.
67 </p></dd>
68 <dt><b>selection :get </b><span class="roman">?</span><i>type</i>?</dt>
69 <dd><p>Retrieves the value
70 of the primary selection and returns it as a result.
71 <b>Type</b> specifies the form in which the selection is to be
72 returned (the desired &ldquo;target&rdquo; for conversion, in ICCCM
73 terminology), and should be an
74 atom name such as STRING or FILE_NAME; see the Inter-Client
75 Communication Conventions Manual for complete details.
76 <b>Type</b> defaults to STRING. The selection :owner may choose to
77 return the selection in any of several different representation
78 formats, such as STRING, ATOM, INTEGER, etc. (this format is
79 different than the selection type; see the ICCCM for all the
80 confusing details). If the selection is returned in
81 a non-string format, such as INTEGER or ATOM, the <b>selection</b>
82 command converts it to string format as a collection of fields
83 separated by spaces: atoms are converted to their
84 textual names, and anything else is converted to hexadecimal
85 integers.
86 </p></dd>
87 <dt><b>selection :handle </b><i>window command </i><span class="roman">?</span><i>type</i><span class="roman">? ?</span><i>format</i>?</dt>
88 <dd><p>Creates a handler for selection requests, such that <i>command</i> will
89 be executed whenever the primary selection is
90 owned by <i>window</i> and someone attempts to retrieve it in the form
91 given by <i>type</i><span class="roman"> (e.g. </span><i>type</i><span class="roman"> is specified in the </span><b>selection :get</b>
92 command). <i>Type</i> defaults to STRING.
93 If <i>command</i> is an empty string then any existing handler for
94 <i>window</i><span class="roman"> and </span><i>type</i> is removed.
95 </p>
96 <p>When the selection is requested and <i>window</i> is the selection :owner
97 and <i>type</i><span class="roman"> is the requested type, </span><i>command</i> will be executed
98 as a Tcl command with two additional numbers appended to it
99 (with space separators). The two additional numbers
100 are <i>offset</i><span class="roman"> and </span><i>maxBytes</i><span class="roman">: </span><i>offset</i> specifies a starting
101 character position in the selection and <i>maxBytes</i> gives the maximum
102 number of bytes to retrieve. The command should return a value consisting
103 of at most <i>maxBytes</i> of the selection, starting at position
104 <i>offset</i><span class="roman">. For very large selections (larger than </span><i>maxBytes</i>)
105 the selection will be retrieved using several invocations of <i>command</i>
106 with increasing <i>offset</i><span class="roman"> values. If </span><i>command</i> returns a string
107 whose length is less than <i>maxBytes</i>, the return value is assumed to
108 include all of the remainder of the selection; if the length of
109 <i>command</i><span class="roman">&rsquo;s result is equal to </span><i>maxBytes</i> then
110 <i>command</i> will be invoked again, until it eventually
111 returns a result shorter than <i>maxBytes</i><span class="roman">. The value of </span><i>maxBytes</i>
112 will always be relatively large (thousands of bytes).
113 </p>
114 <p>If <i>command</i> returns an error then the selection retrieval is rejected
115 just as if the selection didn&rsquo;t exist at all.
116 </p>
117 <p>The <i>format</i> argument specifies the representation that should be
118 used to transmit the selection to the requester (the second column of
119 Table 2 of the ICCCM), and defaults to STRING. If <i>format</i> is
120 STRING, the selection is transmitted as 8-bit ASCII characters (i.e.
121 just in the form returned by <i>command</i><span class="roman">). If </span><i>format</i> is
122 ATOM, then the return value from <i>command</i> is divided into fields
123 separated by white space; each field is converted to its atom value,
124 and the 32-bit atom value is transmitted instead of the atom name.
125 For any other <i>format</i><span class="roman">, the return value from </span><i>command</i> is
126 divided into fields separated by white space and each field is
127 converted to a 32-bit integer; an array of integers is transmitted
128 to the selection requester.
129 </p>
130 <p>The <i>format</i> argument is needed only for compatibility with
131 selection requesters that don&rsquo;t use Tk. If the Tk toolkit is being
132 used to retrieve the selection then the value is converted back to
133 a string at the requesting end, so <i>format</i> is
134 irrelevant.
135 .RE
136 </p></dd>
137 <dt><b>selection :own </b><span class="roman">?</span><i>window</i><span class="roman">? ?</span><i>command</i>?</dt>
138 <dd><p>If <i>window</i> is specified, then it becomes the new selection :owner
139 and the command returns an empty string as result.
140 The existing owner, if any, is notified that it has lost the selection.
141 If <i>command</i> is specified, it is a Tcl script to execute when
142 some other window claims ownership of the selection away from
143 <i>window</i>.
144 If neither <i>window</i><span class="roman"> nor </span><i>command</i> is specified then
145 the command returns the path name of the window in this application
146 that owns the selection, or an empty string if no window in this
147 application owns the selection.
148 </p>
149 </dd>
150 </dl>
151 <span id="Keywords-31"></span><h4 class="unnumberedsubsec">Keywords</h4>
152 <p>clear, format, handler, ICCCM, own, selection, target, type
153 </p><hr>
154 <div class="header">
155 <p>
156 Next: <a href="send.html" accesskey="n" rel="next">send</a>, Previous: <a href="raise.html" accesskey="p" rel="prev">raise</a>, Up: <a href="Control.html" accesskey="u" rel="up">Control</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
157 </div>
158
159
160
161 </body>
162 </html>