Package: x11-apps Version: 7.3+2 Severity: normal While reading manuals on X selections and libxt I have added support of UTF-8 to xclipboard. Please, find a patch attached. To enable correct display of international texts in Xt widgets one has to define *international: true in her/his ~./Xresources file. An enough rich set of bitmap fonts must be also installed. Just for reference I also attach a screenshot. -- System Information: Debian Release: lenny/sid APT prefers testing APT policy: (900, 'testing'), (90, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.24-1-686 (SMP w/1 CPU core) Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages x11-apps depends on: ii cpp 4:4.3.1-1 The GNU C preprocessor (cpp) ii libc6 2.7-10 GNU C Library: Shared libraries ii libice6 2:1.0.4-1 X11 Inter-Client Exchange library ii libpng12-0 1.2.27-1 PNG library - runtime ii libsm6 2:1.0.3-2 X11 Session Management library ii libx11-6 2:1.1.4-2.1 X11 client-side library ii libxaw7 2:1.0.4-2 X11 Athena Widget library ii libxcursor1 1:1.1.9-1 X cursor management library ii libxext6 2:1.0.4-1 X11 miscellaneous extension librar ii libxft2 2.1.12-3 FreeType-based font drawing librar ii libxkbfile1 1:1.0.5-1 X11 keyboard file manipulation lib ii libxmu6 2:1.0.4-1 X11 miscellaneous utility library ii libxmuu1 2:1.0.4-1 X11 miscellaneous micro-utility li ii libxrender1 1:0.9.4-2 X Rendering Extension client libra ii libxt6 1:1.0.5-3 X11 toolkit intrinsics library ii x11-common 1:7.3+12 X Window System (X.Org) infrastruc x11-apps recommends no packages. -- no debconf information
Attachment:
xclipboard_unicode.png
Description: PNG image
--- x11-apps-7.3+2.orig/xclipboard/xclipboard.c 2007-05-16 19:44:53.000000000 +0400
+++ x11-apps-7.3+2+nmu1/xclipboard/xclipboard.c 2008-07-09 09:57:11.000000000 +0400
@@ -27,6 +27,7 @@
* Author: Ralph Swick, DEC/Project Athena
* Updated for R4: Chris D. Peterson, MIT X Consortium.
* Reauthored by: Keith Packard, MIT X Consortium.
+ * Added UTF-8 support: Stanislav Maslovski <stanislav.maslovski@gmail.com>
*/
/* $XFree86: xc/programs/xclipboard/xclipboard.c,v 1.8tsi Exp $ */
@@ -70,6 +71,7 @@
static Atom wm_delete_window;
static Atom wm_protocols;
+static Atom UTF8_STRING;
static void EraseTextWidget ( void );
static void NewCurrentClipContents ( char *data, int len );
@@ -477,6 +479,19 @@
XFree(value);
}
+static void
+InsertClipboardUtf8(Widget w, XtPointer client_data, Atom *selection,
+ Atom *type, XtPointer value, unsigned long *length,
+ int *format)
+{
+ if (*type == XT_CONVERT_FAIL)
+ XtGetSelectionValue(w, *selection, XA_STRING, InsertClipboard,
+ NULL, CurrentTime);
+ else
+ InsertClipboard(w, client_data, selection, type,
+ value, length, format);
+}
+
static Boolean
ConvertSelection(Widget w, Atom *selection, Atom *target,
Atom *type, XtPointer *value, unsigned long *length,
@@ -493,8 +508,9 @@
XmuConvertStandardSelection(w, req->time, selection, target, type,
(XPointer*)&std_targets, &std_length,
format);
- *value = XtMalloc(sizeof(Atom)*(std_length + 5));
+ *value = XtMalloc(sizeof(Atom)*(std_length + 6));
targetP = *(Atom**)value;
+ *targetP++ = UTF8_STRING;
*targetP++ = XA_STRING;
*targetP++ = XA_TEXT(d);
*targetP++ = XA_LENGTH(d);
@@ -554,6 +570,23 @@
return True;
}
+ if (*target == UTF8_STRING)
+ {
+ Arg args[1];
+ Widget source;
+ char *data;
+
+ source = XawTextGetSource (text);
+ XtSetArg (args[0], XtNstring, &data);
+ XtGetValues (source, args, 1);
+ *length = strlen (data);
+ *value = XtMalloc (*length + 1);
+ strcpy(*value, data);
+ *type = UTF8_STRING;
+ *format = 8;
+ return True;
+ }
+
if (XmuConvertStandardSelection(w, req->time, selection, target, type,
(XPointer *) value, length, format))
return True;
@@ -564,7 +597,7 @@
static void
LoseSelection(Widget w, Atom *selection)
{
- XtGetSelectionValue(w, *selection, XA_STRING, InsertClipboard,
+ XtGetSelectionValue(w, *selection, UTF8_STRING, InsertClipboardUtf8,
NULL, CurrentTime);
}
@@ -620,6 +653,7 @@
/* CLIPBOARD_MANAGER is a non-standard mechanism */
ManagerAtom = XInternAtom(XtDisplay(top), "CLIPBOARD_MANAGER", False);
ClipboardAtom = XA_CLIPBOARD(XtDisplay(top));
+ UTF8_STRING = XInternAtom(XtDisplay(top), "UTF8_STRING", False);
if (XGetSelectionOwner(XtDisplay(top), ManagerAtom))
XtError("another clipboard is already running\n");