1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Vim does not support UTF8_STRING for the X selection.
12 Solution: Add UTF8_STRING atom support. (Alex Efros) Use it only when
13 'encoding' is set to Unicode.
17 *** ../vim-7.3.439/src/ui.c 2012-02-04 21:57:44.000000000 +0100
18 --- src/ui.c 2012-02-12 01:28:30.000000000 +0100
22 static Atom vim_atom; /* Vim's own special selection format */
24 static Atom vimenc_atom; /* Vim's extended selection format */
25 + static Atom utf8_atom;
27 static Atom compound_text_atom;
28 static Atom text_atom;
32 vim_atom = XInternAtom(dpy, VIM_ATOM_NAME, False);
34 vimenc_atom = XInternAtom(dpy, VIMENC_ATOM_NAME,False);
35 + utf8_atom = XInternAtom(dpy, "UTF8_STRING", False);
37 compound_text_atom = XInternAtom(dpy, "COMPOUND_TEXT", False);
38 text_atom = XInternAtom(dpy, "TEXT", False);
44 ! else if (*type == compound_text_atom || (
52 ! else if (*type == compound_text_atom
54 ! || *type == utf8_atom
79 case 0: type = vimenc_atom; break;
81 case 1: type = vim_atom; break;
82 ! case 2: type = compound_text_atom; break;
83 ! case 3: type = text_atom; break;
84 default: type = XA_STRING;
87 XtGetSelectionValue(myShell, cbd->sel_atom, type,
88 clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
90 case 0: type = vimenc_atom; break;
92 case 1: type = vim_atom; break;
94 ! case 2: type = utf8_atom; break;
96 ! case 3: type = compound_text_atom; break;
97 ! case 4: type = text_atom; break;
98 default: type = XA_STRING;
101 + if (type == utf8_atom && !enc_utf8)
102 + /* Only request utf-8 when 'encoding' is utf8. */
106 XtGetSelectionValue(myShell, cbd->sel_atom, type,
107 clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
113 ! if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 6))) == NULL)
115 *value = (XtPointer)array;
117 - array[i++] = XA_STRING;
118 array[i++] = targets_atom;
120 array[i++] = vimenc_atom;
122 array[i++] = vim_atom;
123 array[i++] = text_atom;
124 array[i++] = compound_text_atom;
126 /* This used to be: *format = sizeof(Atom) * 8; but that caused
127 * crashes on 64 bit machines. (Peter Derr) */
132 ! if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 7))) == NULL)
134 *value = (XtPointer)array;
136 array[i++] = targets_atom;
138 array[i++] = vimenc_atom;
140 array[i++] = vim_atom;
143 + array[i++] = utf8_atom;
145 + array[i++] = XA_STRING;
146 array[i++] = text_atom;
147 array[i++] = compound_text_atom;
150 /* This used to be: *format = sizeof(Atom) * 8; but that caused
151 * crashes on 64 bit machines. (Peter Derr) */
155 if ( *target != XA_STRING
157 && *target != vimenc_atom
158 + && *target != utf8_atom
160 && *target != vim_atom
161 && *target != text_atom
167 ! if (*target == XA_STRING)
169 mch_memmove(result, string, (size_t)(*length));
172 ! else if (*target == compound_text_atom
173 ! || *target == text_atom)
175 XTextProperty text_prop;
176 char *string_nt = (char *)alloc((unsigned)*length + 1);
181 ! if (*target == XA_STRING
183 ! || (*target == utf8_atom && enc_utf8)
187 mch_memmove(result, string, (size_t)(*length));
190 ! else if (*target == compound_text_atom || *target == text_atom)
192 XTextProperty text_prop;
193 char *string_nt = (char *)alloc((unsigned)*length + 1);
194 *** ../vim-7.3.439/src/version.c 2012-02-12 00:31:47.000000000 +0100
195 --- src/version.c 2012-02-12 01:34:22.000000000 +0100
199 { /* Add new patch number below this line */
205 hundred-and-one symptoms of being an internet addict:
206 42. Your virtual girlfriend finds a new net sweetheart with a larger bandwidth.
208 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
209 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
210 \\\ an exciting new programming language -- http://www.Zimbu.org ///
211 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///