comparison src/ui.c @ 1924:75a69023117c v7.2.221

updated for version 7.2-221
author vimboss
date Wed, 01 Jul 2009 16:04:58 +0000
parents c8f343a465a2
children 0a1d45e2d8e3
comparison
equal deleted inserted replaced
1923:3eb34a777f49 1924:75a69023117c
2102 { 2102 {
2103 XEvent event; 2103 XEvent event;
2104 Atom type; 2104 Atom type;
2105 static int success; 2105 static int success;
2106 int i; 2106 int i;
2107 int nbytes = 0;
2108 char_u *buffer;
2109 time_t start_time; 2107 time_t start_time;
2110 int timed_out = FALSE; 2108 int timed_out = FALSE;
2111 2109
2112 for (i = 2110 for (i =
2113 #ifdef FEAT_MBYTE 2111 #ifdef FEAT_MBYTE
2183 if (timed_out) 2181 if (timed_out)
2184 break; 2182 break;
2185 } 2183 }
2186 2184
2187 /* Final fallback position - use the X CUT_BUFFER0 store */ 2185 /* Final fallback position - use the X CUT_BUFFER0 store */
2188 buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0); 2186 yank_cut_buffer0(dpy, cbd);
2189 if (nbytes > 0)
2190 {
2191 /* Got something */
2192 clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
2193 XFree((void *)buffer);
2194 if (p_verbose > 0)
2195 verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
2196 }
2197 } 2187 }
2198 2188
2199 static Boolean clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *)); 2189 static Boolean clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *));
2200 2190
2201 static Boolean 2191 static Boolean
2364 */ 2354 */
2365 void 2355 void
2366 clip_x11_set_selection(cbd) 2356 clip_x11_set_selection(cbd)
2367 VimClipboard *cbd UNUSED; 2357 VimClipboard *cbd UNUSED;
2368 { 2358 {
2359 }
2360 #endif
2361
2362 #if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) \
2363 || defined(FEAT_GUI_GTK) || defined(PROTO)
2364 /*
2365 * Get the contents of the X CUT_BUFFER0 and put it in "cbd".
2366 */
2367 void
2368 yank_cut_buffer0(dpy, cbd)
2369 Display *dpy;
2370 VimClipboard *cbd;
2371 {
2372 int nbytes = 0;
2373 char_u *buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0);
2374
2375 if (nbytes > 0)
2376 {
2377 #ifdef FEAT_MBYTE
2378 int done = FALSE;
2379
2380 /* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when
2381 * using a multi-byte encoding. Conversion between two 8-bit
2382 * character sets usually fails and the text might actually be in
2383 * 'enc' anyway. */
2384 if (has_mbyte)
2385 {
2386 char_u *conv_buf = buffer;
2387 vimconv_T vc;
2388
2389 vc.vc_type = CONV_NONE;
2390 if (convert_setup(&vc, (char_u *)"latin1", p_enc) == OK)
2391 {
2392 conv_buf = string_convert(&vc, buffer, &nbytes);
2393 if (conv_buf != NULL)
2394 {
2395 clip_yank_selection(MCHAR, conv_buf, (long)nbytes, cbd);
2396 vim_free(conv_buf);
2397 done = TRUE;
2398 }
2399 convert_setup(&vc, NULL, NULL);
2400 }
2401 }
2402 if (!done) /* use the text without conversion */
2403 #endif
2404 clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
2405 XFree((void *)buffer);
2406 if (p_verbose > 0)
2407 {
2408 verbose_enter();
2409 verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
2410 verbose_leave();
2411 }
2412 }
2369 } 2413 }
2370 #endif 2414 #endif
2371 2415
2372 #if defined(FEAT_MOUSE) || defined(PROTO) 2416 #if defined(FEAT_MOUSE) || defined(PROTO)
2373 2417