4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: X cut_buffer0 text is used as-is, it may be in the wrong encoding.
12 Solution: Convert between 'enc' and latin1. (James Vega)
13 Files: src/gui_gtk_x11.c, src/message.c, src/ops.c, src/proto/ui.pro,
17 *** ../vim-7.2.220/src/gui_gtk_x11.c 2009-06-16 15:23:07.000000000 +0200
18 --- src/gui_gtk_x11.c 2009-07-01 11:55:34.000000000 +0200
28 for (i = 0; i < N_SELECTION_TARGETS; ++i)
34 /* Final fallback position - use the X CUT_BUFFER0 store */
36 ! buffer = (char_u *)XFetchBuffer(GDK_WINDOW_XDISPLAY(gui.mainwin->window),
41 ! clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
45 ! smsg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
57 /* Final fallback position - use the X CUT_BUFFER0 store */
58 ! yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gui.mainwin->window), cbd);
62 *** ../vim-7.2.220/src/message.c 2009-05-17 13:30:58.000000000 +0200
63 --- src/message.c 2009-07-01 16:43:08.000000000 +0200
68 #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \
71 * Like msg() but keep it silent when 'verbosefile' is set.
76 #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \
77 ! || defined(FEAT_GUI_GTK) || defined(PROTO)
79 * Like msg() but keep it silent when 'verbosefile' is set.
81 *** ../vim-7.2.220/src/ops.c 2009-05-26 18:12:13.000000000 +0200
82 --- src/ops.c 2009-07-01 12:15:31.000000000 +0200
86 if (dpy != NULL && str != NULL && motion_type >= 0
87 && len < 1024*1024 && len > 0)
90 + /* The CUT_BUFFER0 is supposed to always contain latin1. Convert from
91 + * 'enc' when it is a multi-byte encoding. When 'enc' is an 8-bit
92 + * encoding conversion usually doesn't work, so keep the text as-is.
96 + char_u *conv_str = str;
99 + vc.vc_type = CONV_NONE;
100 + if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
102 + conv_str = string_convert(&vc, str, (int*)&len);
103 + if (conv_str != NULL)
108 + convert_setup(&vc, NULL, NULL);
112 XStoreBuffer(dpy, (char *)str, (int)len, 0);
115 *** ../vim-7.2.220/src/proto/ui.pro 2007-05-05 19:58:49.000000000 +0200
116 --- src/proto/ui.pro 2009-07-01 11:48:11.000000000 +0200
120 void open_app_context __ARGS((void));
121 void x11_setup_atoms __ARGS((Display *dpy));
122 void clip_x11_request_selection __ARGS((Widget myShell, Display *dpy, VimClipboard *cbd));
123 + void yank_cut_buffer0 __ARGS((Display *dpy, VimClipboard *cbd));
124 void clip_x11_lose_selection __ARGS((Widget myShell, VimClipboard *cbd));
125 int clip_x11_own_selection __ARGS((Widget myShell, VimClipboard *cbd));
126 void clip_x11_set_selection __ARGS((VimClipboard *cbd));
127 *** ../vim-7.2.220/src/ui.c 2009-05-17 13:30:58.000000000 +0200
128 --- src/ui.c 2009-07-01 15:44:07.000000000 +0200
137 int timed_out = FALSE;
144 /* Final fallback position - use the X CUT_BUFFER0 store */
145 ! buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0);
148 ! /* Got something */
149 ! clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
150 ! XFree((void *)buffer);
152 ! verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
156 static Boolean clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *));
160 /* Final fallback position - use the X CUT_BUFFER0 store */
161 ! yank_cut_buffer0(dpy, cbd);
164 static Boolean clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *));
171 + #if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) \
172 + || defined(FEAT_GUI_GTK) || defined(PROTO)
174 + * Get the contents of the X CUT_BUFFER0 and put it in "cbd".
177 + yank_cut_buffer0(dpy, cbd)
182 + char_u *buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0);
189 + /* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when
190 + * using a multi-byte encoding. Conversion between two 8-bit
191 + * character sets usually fails and the text might actually be in
195 + char_u *conv_buf = buffer;
198 + vc.vc_type = CONV_NONE;
199 + if (convert_setup(&vc, (char_u *)"latin1", p_enc) == OK)
201 + conv_buf = string_convert(&vc, buffer, &nbytes);
202 + if (conv_buf != NULL)
204 + clip_yank_selection(MCHAR, conv_buf, (long)nbytes, cbd);
205 + vim_free(conv_buf);
208 + convert_setup(&vc, NULL, NULL);
211 + if (!done) /* use the text without conversion */
213 + clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
214 + XFree((void *)buffer);
218 + verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
225 #if defined(FEAT_MOUSE) || defined(PROTO)
228 *** ../vim-7.2.220/src/version.c 2009-07-01 17:11:40.000000000 +0200
229 --- src/version.c 2009-07-01 17:56:02.000000000 +0200
233 { /* Add new patch number below this line */
239 hundred-and-one symptoms of being an internet addict:
240 40. You tell the cab driver you live at
241 http://123.elm.street/house/bluetrim.html
242 41. You actually try that 123.elm.street address.
244 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
245 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
246 \\\ download, build and distribute -- http://www.A-A-P.org ///
247 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///