diff options
author | Bram Moolenaar <Bram@vim.org> | 2009-07-01 16:04:58 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2009-07-01 16:04:58 +0000 |
commit | bbc936bebec333159bdf43ffbf0da18880023059 (patch) | |
tree | 1e4fbbbd61eeb6dcc5c6e1888295b37bd383d826 /src/ui.c | |
parent | 2bc76e617b85366156c3aed82db20dcac52c64fc (diff) | |
download | vim-bbc936bebec333159bdf43ffbf0da18880023059.zip |
updated for version 7.2-221
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 66 |
1 files changed, 55 insertions, 11 deletions
@@ -2104,8 +2104,6 @@ clip_x11_request_selection(myShell, dpy, cbd) Atom type; static int success; int i; - int nbytes = 0; - char_u *buffer; time_t start_time; int timed_out = FALSE; @@ -2185,15 +2183,7 @@ clip_x11_request_selection(myShell, dpy, cbd) } /* Final fallback position - use the X CUT_BUFFER0 store */ - buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0); - if (nbytes > 0) - { - /* Got something */ - clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); - XFree((void *)buffer); - if (p_verbose > 0) - verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection")); - } + yank_cut_buffer0(dpy, cbd); } static Boolean clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *)); @@ -2369,6 +2359,60 @@ clip_x11_set_selection(cbd) } #endif +#if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) \ + || defined(FEAT_GUI_GTK) || defined(PROTO) +/* + * Get the contents of the X CUT_BUFFER0 and put it in "cbd". + */ + void +yank_cut_buffer0(dpy, cbd) + Display *dpy; + VimClipboard *cbd; +{ + int nbytes = 0; + char_u *buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0); + + if (nbytes > 0) + { +#ifdef FEAT_MBYTE + int done = FALSE; + + /* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when + * using a multi-byte encoding. Conversion between two 8-bit + * character sets usually fails and the text might actually be in + * 'enc' anyway. */ + if (has_mbyte) + { + char_u *conv_buf = buffer; + vimconv_T vc; + + vc.vc_type = CONV_NONE; + if (convert_setup(&vc, (char_u *)"latin1", p_enc) == OK) + { + conv_buf = string_convert(&vc, buffer, &nbytes); + if (conv_buf != NULL) + { + clip_yank_selection(MCHAR, conv_buf, (long)nbytes, cbd); + vim_free(conv_buf); + done = TRUE; + } + convert_setup(&vc, NULL, NULL); + } + } + if (!done) /* use the text without conversion */ +#endif + clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); + XFree((void *)buffer); + if (p_verbose > 0) + { + verbose_enter(); + verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection")); + verbose_leave(); + } + } +} +#endif + #if defined(FEAT_MOUSE) || defined(PROTO) /* |