summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-07-03 01:03:16 (GMT)
committerhobbs <hobbs>2001-07-03 01:03:16 (GMT)
commit57dee857622ab7a2a15091b6b097f057b0ace6f3 (patch)
treef0f5765b05f0fcc773bdb417e722c60e2299bbdb /unix
parent3083a49a521caabecd2d02fdf45791d35b1f2e34 (diff)
downloadtk-57dee857622ab7a2a15091b6b097f057b0ace6f3.zip
tk-57dee857622ab7a2a15091b6b097f057b0ace6f3.tar.gz
tk-57dee857622ab7a2a15091b6b097f057b0ace6f3.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.
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixSelect.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index e3d6b56..364469d 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixSelect.c,v 1.6 1999/06/03 18:50:46 stanton Exp $
+ * RCS: @(#) $Id: tkUnixSelect.c,v 1.7 2001/07/03 01:03:16 hobbs Exp $
*/
#include "tkInt.h"
@@ -597,7 +597,7 @@ TkSelEventProc(tkwin, eventPtr)
Tcl_Encoding encoding;
if (format != 8) {
char buf[64 + TCL_INTEGER_SPACE];
-
+
sprintf(buf,
"bad format for string selection: wanted \"8\", got \"%d\"",
format);
@@ -633,6 +633,35 @@ TkSelEventProc(tkwin, eventPtr)
interp, Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
Tcl_Release((ClientData) interp);
+ } else if (type == dispPtr->utf8Atom) {
+ /*
+ * The X selection data is in UTF-8 format already.
+ * We can't guarantee that propInfo is NULL-terminated,
+ * so we might have to copy the string.
+ */
+ char *propData = propInfo;
+
+ if (format != 8) {
+ char buf[64 + TCL_INTEGER_SPACE];
+
+ sprintf(buf,
+ "bad format for string selection: wanted \"8\", got \"%d\"",
+ format);
+ Tcl_SetResult(retrPtr->interp, buf, TCL_VOLATILE);
+ retrPtr->result = TCL_ERROR;
+ return;
+ }
+
+ if (propInfo[numItems] != '\0') {
+ propData = ckalloc((size_t) numItems + 1);
+ strcpy(propData, propInfo);
+ propData[numItems] = '\0';
+ }
+ retrPtr->result = (*retrPtr->proc)(retrPtr->clientData,
+ retrPtr->interp, propData);
+ if (propData != propInfo) {
+ ckfree((char *) propData);
+ }
} else if (type == dispPtr->incrAtom) {
/*
@@ -657,7 +686,7 @@ TkSelEventProc(tkwin, eventPtr)
if (format != 32) {
char buf[64 + TCL_INTEGER_SPACE];
-
+
sprintf(buf,
"bad format for selection: wanted \"32\", got \"%d\"",
format);
@@ -940,6 +969,15 @@ ConvertSelection(winPtr, eventPtr)
XChangeProperty(reply.display, reply.requestor,
property, type, format, PropModeReplace,
(unsigned char *) propPtr, numItems);
+ } else if (type == winPtr->dispPtr->utf8Atom) {
+ /*
+ * This matches selection requests of type UTF8_STRING,
+ * which allows us to pass our utf-8 information untouched.
+ */
+
+ XChangeProperty(reply.display, reply.requestor,
+ property, type, 8, PropModeReplace,
+ (unsigned char *) buffer, numItems);
} else if ((type == XA_STRING)
|| (type == winPtr->dispPtr->compoundTextAtom)) {
Tcl_DString ds;