summaryrefslogtreecommitdiffstats
path: root/library/tk.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2001-07-03 01:03:16 (GMT)
committerhobbs <hobbs@noemail.net>2001-07-03 01:03:16 (GMT)
commitaff8d598ecf9d73d1ef2ae8a2caadf6d0b5f5e26 (patch)
treef0f5765b05f0fcc773bdb417e722c60e2299bbdb /library/tk.tcl
parentd464edfb42dfa25818f642df3e2eb9fc6adb7f6d (diff)
downloadtk-aff8d598ecf9d73d1ef2ae8a2caadf6d0b5f5e26.zip
tk-aff8d598ecf9d73d1ef2ae8a2caadf6d0b5f5e26.tar.gz
tk-aff8d598ecf9d73d1ef2ae8a2caadf6d0b5f5e26.tar.bz2
* library/console.tcl:
* library/entry.tcl: * library/spinbox.tcl: * library/text.tcl: * library/tk.tcl: added private ::tk::GetSelection command to handle requesting selection. This is to support requesting UTF8_STRING before generic STRING on Unix. Changed Text, Spinbox, Entry and Console to use this command. * tests/select.test: * generic/tkSelect.c (Tk_CreateSelHandler, Tk_DeleteSelHandler): on Unix, a UTF8_STRING handler will be created when the user requests a STRING handler (in addition to the STRING handler). This provides implicit support for the new UTF8_STRING selection target. * unix/tkUnixSelect.c (TkSelEventProc, ConvertSelection): Added support for UTF8_STRING target. [RFE #418653, Patch #433283] * generic/tkInt.h: added utf8Atom to TkDisplay structure. FossilOrigin-Name: 3993717faaae94fc303c678c9c3637465ce2c0a4
Diffstat (limited to 'library/tk.tcl')
-rw-r--r--library/tk.tcl34
1 files changed, 33 insertions, 1 deletions
diff --git a/library/tk.tcl b/library/tk.tcl
index daba5d6..64afbe7 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -3,7 +3,7 @@
# Initialization script normally executed in the interpreter for each
# Tk-based application. Arranges class bindings for widgets.
#
-# RCS: @(#) $Id: tk.tcl,v 1.29 2001/03/31 05:46:10 hobbs Exp $
+# RCS: @(#) $Id: tk.tcl,v 1.30 2001/07/03 01:03:16 hobbs Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -151,6 +151,38 @@ proc ::tk::RestoreFocusGrab {grab focus {destroy destroy}} {
}
}
+# ::tk::GetSelection --
+# This tries to obtain the default selection. On Unix, we first try
+# and get a UTF8_STRING, a type supported by modern Unix apps for
+# passing Unicode data safely. We fall back on the default STRING
+# type otherwise. On Windows, only the STRING type is necessary.
+# Arguments:
+# w The widget for which the selection will be retrieved.
+# Important for the -displayof property.
+# sel The source of the selection (PRIMARY or CLIPBOARD)
+# Results:
+# Returns the selection, or an error if none could be found
+#
+if {[string equal $tcl_platform(platform) "unix"]} {
+ proc ::tk::GetSelection {w {sel PRIMARY}} {
+ if {[catch {selection get -displayof $w -selection $sel \
+ -type UTF8_STRING} txt] \
+ && [catch {selection get -displayof $w -selection $sel} txt]} {
+ return -code error "could not find default selection"
+ } else {
+ return $txt
+ }
+ }
+} else {
+ proc ::tk::GetSelection {w {sel PRIMARY}} {
+ if {[catch {selection get -displayof $w -selection $sel} txt]} {
+ return -code error "could not find default selection"
+ } else {
+ return $txt
+ }
+ }
+}
+
# tkScreenChanged --
# This procedure is invoked by the binding mechanism whenever the
# "current" screen is changing. The procedure does two things.