{"id":6170,"date":"2022-12-20T18:57:59","date_gmt":"2022-12-20T21:57:59","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/selection-mann\/"},"modified":"2022-12-20T18:57:59","modified_gmt":"2022-12-20T21:57:59","slug":"selection-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/selection-mann\/","title":{"rendered":"selection (mann)"},"content":{"rendered":"<h1 align=\"center\">selection<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#WIDGET FACILITIES\">WIDGET FACILITIES<\/a><br \/> <a href=\"#PORTABILITY ISSUES\">PORTABILITY ISSUES<\/a><br \/> <a href=\"#SECURITY\">SECURITY<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">selection \u2212 Manipulate the X selection<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>selection<\/b> <i>option<\/i> ?<i>arg arg &#8230;<\/i>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This command provides a Tcl interface to the X selection mechanism and implements the full selection functionality described in the X Inter-Client Communication Conventions Manual (ICCCM).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that for management of the <b>CLIPBOARD<\/b> selection (see below), the <b>clipboard<\/b> command may also be used.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The first argument to <b>selection<\/b> determines the format of the rest of the arguments and the behavior of the command. The following forms are currently supported: <b><br \/> selection clear<\/b> ?<b>\u2212displayof<\/b> <i>window<\/i>? ?<b>\u2212selection<\/b> <i>selection<\/i>?<\/p>\n<p style=\"margin-left:22%;\">If <i>selection<\/i> exists anywhere on <i>window<\/i>\u2019s display, clear it so that no window owns the selection anymore. <i>Selection<\/i> specifies the X selection that should be cleared, and should be an atom name such as <b>PRIMARY<\/b> or <b>CLIPBOARD<\/b>; see the Inter-Client Communication Conventions Manual for complete details. <i>Selection<\/i> defaults to <b>PRIMARY<\/b> and <i>window<\/i> defaults to \u201c.\u201d. Returns an empty string.<\/p>\n<p style=\"margin-left:11%;\"><b>selection get<\/b> ?<b>\u2212displayof<\/b> <i>window<\/i>? ?<b>\u2212selection<\/b> <i>selection<\/i>? ?<b>\u2212type<\/b> <i>type<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Retrieves the value of <i>selection<\/i> from <i>window<\/i>\u2019s display and returns it as a result. <i>Selection<\/i> defaults to <b>PRIMARY<\/b> and <i>window<\/i> defaults to \u201c.\u201d. <i>Type<\/i> specifies the form in which the selection is to be returned (the desired \u201ctarget\u201d for conversion, in ICCCM terminology), and should be an atom name such as <b>STRING<\/b> or <b>FILE_NAME<\/b>; see the Inter-Client Communication Conventions Manual for complete details. <i>Type<\/i> defaults to <b>STRING<\/b>. The selection owner may choose to return the selection in any of several different representation formats, such as <b>STRING<\/b>, <b>UTF8_STRING<\/b>, <b>ATOM<\/b>, <b>INTEGER<\/b>, 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 <b>INTEGER<\/b> or <b>ATOM<\/b>, the <b>selection<\/b> command 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. Note that <b>selection get<\/b> does not retrieve the selection in the <b>UTF8_STRING<\/b> format unless told to.<\/p>\n<p style=\"margin-left:11%;\"><b>selection handle<\/b> ?<b>\u2212selection<\/b> <i>s<\/i>? ?<b>\u2212type<\/b> <i>t<\/i>? ?<b>\u2212format<\/b> <i>f<\/i>? <i>window command<\/i><\/p>\n<p style=\"margin-left:22%;\">Creates a handler for selection requests, such that <i>command<\/i> will be executed whenever selection <i>s<\/i> is owned by <i>window<\/i> and someone attempts to retrieve it in the form given by type <i>t<\/i> (e.g. <i>t<\/i> is specified in the <b>selection get<\/b> command). <i>S<\/i> defaults to <b>PRIMARY<\/b>, <i>t<\/i> defaults to <b>STRING<\/b>, and <i>f<\/i> defaults to <b>STRING<\/b>. If <i>command<\/i> is an empty string then any existing handler for <i>window<\/i>, <i>t<\/i>, and <i>s<\/i> is removed. Note that when the selection is handled as type <b>STRING<\/b> it is also automatically handled as type <b>UTF8_STRING<\/b> as well.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">When <i>selection<\/i> is requested, <i>window<\/i> is the selection owner, and <i>type<\/i> is the requested type, <i>command<\/i> will be executed as a Tcl command with two additional numbers appended to it (with space separators). The two additional numbers are <i>offset<\/i> and <i>maxChars<\/i>: <i>offset<\/i> specifies a starting character position in the selection and <i>maxChars<\/i> gives the maximum number of characters to retrieve. The command should return a value consisting of at most <i>maxChars<\/i> of the selection, starting at position <i>offset<\/i>. For very large selections (larger than <i>maxChars<\/i>) the selection will be retrieved using several invocations of <i>command<\/i> with increasing <i>offset<\/i> values. If <i>command<\/i> returns a string whose length is less than <i>maxChars<\/i>, the return value is assumed to include all of the remainder of the selection; if the length of <i>command<\/i>\u2019s result is equal to <i>maxChars<\/i> then <i>command<\/i> will be invoked again, until it eventually returns a result shorter than <i>maxChars<\/i>. The value of <i>maxChars<\/i> will always be relatively large (thousands of characters).<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">If <i>command<\/i> returns an error then the selection retrieval is rejected just as if the selection did not exist at all.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">The <i>format<\/i> argument specifies the representation that should be used to transmit the selection to the requester (the second column of Table 2 of the ICCCM), and defaults to <b>STRING<\/b>. If <i>format<\/i> is <b>STRING<\/b>, the selection is transmitted as 8-bit ASCII characters (i.e. just in the form returned by <i>command<\/i>, in the system <b>encoding<\/b>; the <b>UTF8_STRING<\/b> format always uses UTF-8 as its encoding). If <i>format<\/i> is <b>ATOM<\/b>, then the return value from <i>command<\/i> is divided into fields separated by white space; each field is converted to its atom value, and the 32-bit atom value is transmitted instead of the atom name. For any other <i>format<\/i>, the return value from <i>command<\/i> is divided into fields separated by white space and each field is converted to a 32-bit integer; an array of integers is transmitted to the selection requester.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">The <i>format<\/i> argument is needed only for compatibility with selection requesters that do not use Tk. If Tk is being used to retrieve the selection then the value is converted back to a string at the requesting end, so <i>format<\/i> is irrelevant.<\/p>\n<p style=\"margin-left:11%;\"><b>selection own<\/b> ?<b>\u2212displayof<\/b> <i>window<\/i>? ?<b>\u2212selection<\/b> <i>selection<\/i>? <b><br \/> selection own<\/b> ?<b>\u2212command<\/b> <i>command<\/i>? ?<b>\u2212selection<\/b> <i>selection<\/i>? <i>window<\/i><\/p>\n<p style=\"margin-left:22%;\">The first form of <b>selection own<\/b> returns the path name of the window in this application that owns <i>selection<\/i> on the display containing <i>window<\/i>, or an empty string if no window in this application owns the selection. <i>Selection<\/i> defaults to <b>PRIMARY<\/b> and <i>window<\/i> defaults to \u201c.\u201d.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">The second form of <b>selection own<\/b> causes <i>window<\/i> to become the new owner of <i>selection<\/i> on <i>window<\/i>\u2019s display, returning an empty string as result. The existing owner, if any, is notified that it has lost the selection. If <i>command<\/i> is specified, it is a Tcl script to execute when some other window claims ownership of the selection away from <i>window<\/i>. <i>Selection<\/i> defaults to PRIMARY.<\/p>\n<h2>WIDGET FACILITIES <a name=\"WIDGET FACILITIES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>text<\/b>, <b>entry<\/b>, <b>ttk::entry<\/b>, <b>listbox<\/b>, <b>spinbox<\/b> and <b>ttk::spinbox<\/b> widgets have the option <b>\u2212exportselection<\/b>. If a widget has this option set to boolean <b>true<\/b>, then (in an unsafe interpreter) a selection made in the widget is automatically written to the <b>PRIMARY<\/b> selection.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A GUI event, for example <b><<PasteSelection>><\/b>, can copy the <b>PRIMARY<\/b> selection to certain widgets. This copy is implemented by a widget binding to the event. The binding script makes appropriate calls to the <b>selection<\/b> command.<\/p>\n<h2>PORTABILITY ISSUES <a name=\"PORTABILITY ISSUES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">On X11, the <b>PRIMARY<\/b> selection is a system-wide feature of the X server, allowing communication between different processes that are X11 clients.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">On Windows, the <b>PRIMARY<\/b> selection is not provided by the system, but only by Tk, and so it is shared only between windows of a master interpreter and its unsafe slave interpreters. It is not shared between interpreters in different processes or different threads. Each master interpreter has a separate <b>PRIMARY<\/b> selection that is shared only with its unsafe slaves.<\/p>\n<h2>SECURITY <a name=\"SECURITY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">A safe interpreter cannot read from the <b>PRIMARY<\/b> selection because its <b>selection<\/b> command is hidden. For this reason the <b>PRIMARY<\/b> selection cannot be written to the Tk widgets of a safe interpreter.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A Tk widget can have its option <b>\u2212exportselection<\/b> set to boolean <b>true<\/b>, but in a safe interpreter this option has no effect: writing from the widget to the <b>PRIMARY<\/b> selection is disabled.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">These are security features. A safe interpreter may run untrusted code, and it is a security risk if this untrusted code can read or write the <b>PRIMARY<\/b> selection used by other interpreters.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">On X11 platforms, one of the standard selections available is the <b>SECONDARY<\/b> selection. Hardly anything uses it, but here is how to read it using Tk:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set selContents [<b>selection get<\/b> \u2212selection SECONDARY]<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Many different types of data may be available for a selection; the special type <b>TARGETS<\/b> allows you to get a list of available types:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">foreach type [<b>selection get<\/b> \u2212type TARGETS] { <br \/> puts &#8220;Selection PRIMARY supports type $type&#8221; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To claim the selection, you must first set up a handler to supply the data for the selection. Then you have to claim the selection&#8230;<\/p>\n<p style=\"margin-left:22%;\"># Set up the data handler ready for incoming requests <br \/> set foo &#8220;This is a string with some data in it&#8230; blah blah&#8221; <b><br \/> selection handle<\/b> \u2212selection SECONDARY . getData <br \/> proc getData {offset maxChars} { <br \/> puts &#8220;Retrieving selection starting at $offset&#8221; <br \/> return [string range $::foo $offset [expr {$offset+$maxChars-1}]] <br \/> }<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"># Now we grab the selection itself <br \/> puts &#8220;Claiming selection&#8221; <b><br \/> selection own<\/b> \u2212command lost \u2212selection SECONDARY . <br \/> proc lost {} { <br \/> puts &#8220;Lost selection&#8221; <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">clipboard(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">clear, format, handler, ICCCM, own, selection, target, type<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  selection \u2212 Manipulate the X selection <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2635,2814],"class_list":["post-6170","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-mann","tag-selection"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6170"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6170\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}