]> granicus.if.org Git - vim/commitdiff
updated for version 7.2-221 v7.2.221
authorBram Moolenaar <Bram@vim.org>
Wed, 1 Jul 2009 16:04:58 +0000 (16:04 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 1 Jul 2009 16:04:58 +0000 (16:04 +0000)
src/gui_gtk_x11.c
src/message.c
src/ops.c
src/proto/ui.pro
src/ui.c
src/version.c

index 29ab9a799141dfcf0d705dd06f920183251c1189..33fdaed4854b69d4367229cf8fe03ab07576d855 100644 (file)
@@ -6717,8 +6717,6 @@ clip_mch_request_selection(VimClipboard *cbd)
 {
     GdkAtom    target;
     unsigned   i;
-    int                nbytes;
-    char_u     *buffer;
     time_t     start;
 
     for (i = 0; i < N_SELECTION_TARGETS; ++i)
@@ -6746,22 +6744,7 @@ clip_mch_request_selection(VimClipboard *cbd)
     }
 
     /* Final fallback position - use the X CUT_BUFFER0 store */
-    nbytes = 0;
-    buffer = (char_u *)XFetchBuffer(GDK_WINDOW_XDISPLAY(gui.mainwin->window),
-                                   &nbytes, 0);
-    if (nbytes > 0)
-    {
-       /* Got something */
-       clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
-       if (p_verbose > 0)
-       {
-           verbose_enter();
-           smsg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
-           verbose_leave();
-       }
-    }
-    if (buffer != NULL)
-       XFree(buffer);
+    yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gui.mainwin->window), cbd);
 }
 
 /*
index c0f661b09b1914b28fca4a35d5bc3feaa86e68a2..e29f5f8fec8e5802713f1fae5bb4407892b9e4b9 100644 (file)
@@ -107,7 +107,7 @@ msg(s)
 }
 
 #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \
-    || defined(PROTO)
+    || defined(FEAT_GUI_GTK) || defined(PROTO)
 /*
  * Like msg() but keep it silent when 'verbosefile' is set.
  */
index 3e595fd427cfb896f32de95a34c56c6746f88572..f75613def2ecdfa6b235f99f0623eb0be528f3b0 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -5591,6 +5591,29 @@ x11_export_final_selection()
     if (dpy != NULL && str != NULL && motion_type >= 0
                                               && len < 1024*1024 && len > 0)
     {
+#ifdef FEAT_MBYTE
+       /* The CUT_BUFFER0 is supposed to always contain latin1.  Convert from
+        * 'enc' when it is a multi-byte encoding.  When 'enc' is an 8-bit
+        * encoding conversion usually doesn't work, so keep the text as-is.
+        */
+       if (has_mbyte)
+       {
+           char_u      *conv_str = str;
+           vimconv_T   vc;
+
+           vc.vc_type = CONV_NONE;
+           if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
+           {
+               conv_str = string_convert(&vc, str, (int*)&len);
+               if (conv_str != NULL)
+               {
+                   vim_free(str);
+                   str = conv_str;
+               }
+               convert_setup(&vc, NULL, NULL);
+           }
+       }
+#endif
        XStoreBuffer(dpy, (char *)str, (int)len, 0);
        XFlush(dpy);
     }
index 8825b6a16878953d6e97277fc797c7e5b45146f9..2bc0c31ec91d3d5ca898c686dd15cb5c4ce24f73 100644 (file)
@@ -48,6 +48,7 @@ int check_row __ARGS((int row));
 void open_app_context __ARGS((void));
 void x11_setup_atoms __ARGS((Display *dpy));
 void clip_x11_request_selection __ARGS((Widget myShell, Display *dpy, VimClipboard *cbd));
+void yank_cut_buffer0 __ARGS((Display *dpy, VimClipboard *cbd));
 void clip_x11_lose_selection __ARGS((Widget myShell, VimClipboard *cbd));
 int clip_x11_own_selection __ARGS((Widget myShell, VimClipboard *cbd));
 void clip_x11_set_selection __ARGS((VimClipboard *cbd));
index 443f9c466d0d4cbfde78d8c73e58bbf76ed90b90..aa8a8ac49ff09eb2950f3167e99576e5a30df5fb 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -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)
 
 /*
index b553e4ed4dc30a3c3c2ebbd7df1870978eb8f011..24544363861bdf84972cd7959a9eb1673328ba84 100644 (file)
@@ -676,6 +676,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    221,
 /**/
     220,
 /**/