]> git.pld-linux.org Git - packages/vim.git/blob - 6.2.428
- remove missing .po files
[packages/vim.git] / 6.2.428
1 To: vim-dev@vim.org
2 Subject: Patch 6.2.428
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 CORRECTED PATCH: chunk in gui_gtk_x11.c was removed, it didn't belong here.
11
12 Patch 6.2.428
13 Problem:    The X11 clipboard supports the Vim selection for char/line/block
14             mode, but since the encoding is not included  can't copy/paste
15             between two Vims with a different 'encoding'.
16 Solution:   Add a new selection format that includes the 'encoding'.  Perform
17             conversion when necessary.
18 Files:      src/gui_gtk_x11.c, src/ui.c, src/vim.h
19
20
21 *** ../vim-6.2.427/src/gui_gtk_x11.c    Tue Mar 23 21:19:08 2004
22 --- src/gui_gtk_x11.c   Fri Apr  2 12:52:16 2004
23 ***************
24 *** 102,108 ****
25       TARGET_TEXT,
26       TARGET_TEXT_URI_LIST,
27       TARGET_TEXT_PLAIN,
28 !     TARGET_VIM
29   };
30   
31   /*
32 --- 102,109 ----
33       TARGET_TEXT,
34       TARGET_TEXT_URI_LIST,
35       TARGET_TEXT_PLAIN,
36 !     TARGET_VIM,
37 !     TARGET_VIMENC
38   };
39   
40   /*
41 ***************
42 *** 111,116 ****
43 --- 112,118 ----
44    */
45   static const GtkTargetEntry selection_targets[] =
46   {
47 +     {VIMENC_ATOM_NAME,        0, TARGET_VIMENC},
48       {VIM_ATOM_NAME,   0, TARGET_VIM},
49   #ifdef FEAT_MBYTE
50       {"UTF8_STRING",   0, TARGET_UTF8_STRING},
51 ***************
52 *** 175,180 ****
53 --- 177,185 ----
54   static GdkAtom text_atom = GDK_NONE;
55   #endif
56   static GdkAtom vim_atom = GDK_NONE;   /* Vim's own special selection format */
57 + #ifdef FEAT_MBYTE
58 + static GdkAtom vimenc_atom = GDK_NONE;        /* Vim's extended selection format */
59 + #endif
60   
61   /*
62    * Keycodes recognized by vim.
63 ***************
64 *** 1244,1249 ****
65 --- 1255,1288 ----
66         motion_type = *text++;
67         --len;
68       }
69
70 + #ifdef FEAT_MBYTE
71 +     else if (data->type == vimenc_atom)
72 +     {
73 +       char_u          *enc;
74 +       vimconv_T       conv;
75
76 +       motion_type = *text++;
77 +       --len;
78
79 +       enc = text;
80 +       text += STRLEN(text) + 1;
81 +       len -= text - enc;
82
83 +       /* If the encoding of the text is different from 'encoding', attempt
84 +        * converting it. */
85 +       conv.vc_type = CONV_NONE;
86 +       convert_setup(&conv, enc, p_enc);
87 +       if (conv.vc_type != CONV_NONE)
88 +       {
89 +           tmpbuf = string_convert(&conv, text, &len);
90 +           if (tmpbuf != NULL)
91 +               text = tmpbuf;
92 +           convert_setup(&conv, NULL, NULL);
93 +       }
94 +     }
95 + #endif
96
97   #ifdef HAVE_GTK2
98       /* gtk_selection_data_get_text() handles all the nasty details
99        * and targets and encodings etc.  This rocks so hard. */
100 ***************
101 *** 1351,1356 ****
102 --- 1390,1396 ----
103       if (info != (guint)TARGET_STRING
104   #ifdef FEAT_MBYTE
105             && info != (guint)TARGET_UTF8_STRING
106 +           && info != (guint)TARGET_VIMENC
107   #endif
108             && info != (guint)TARGET_VIM
109             && info != (guint)TARGET_COMPOUND_TEXT
110 ***************
111 *** 1382,1387 ****
112 --- 1422,1448 ----
113         string = tmpbuf;
114         type = vim_atom;
115       }
116
117 + #ifdef FEAT_MBYTE
118 +     else if (info == (guint)TARGET_VIMENC)
119 +     {
120 +       int l = STRLEN(p_enc);
121
122 +       /* contents: motion_type 'encoding' NUL text */
123 +       tmpbuf = alloc((unsigned)length + l + 2);
124 +       if (tmpbuf != NULL)
125 +       {
126 +           tmpbuf[0] = motion_type;
127 +           STRCPY(tmpbuf + 1, p_enc);
128 +           mch_memmove(tmpbuf + l + 2, string, (size_t)length);
129 +       }
130 +       length += l + 2;
131 +       vim_free(string);
132 +       string = tmpbuf;
133 +       type = vimenc_atom;
134 +     }
135 + #endif
136
137   #ifdef HAVE_GTK2
138       /* gtk_selection_data_set_text() handles everything for us.  This is
139        * so easy and simple and cool, it'd be insane not to use it. */
140 ***************
141 *** 3180,3185 ****
142 --- 3241,3249 ----
143        * Set clipboard specific atoms
144        */
145       vim_atom = gdk_atom_intern(VIM_ATOM_NAME, FALSE);
146 + #ifdef FEAT_MBYTE
147 +     vimenc_atom = gdk_atom_intern(VIMENC_ATOM_NAME, FALSE);
148 + #endif
149       clip_star.gtk_sel_atom = GDK_SELECTION_PRIMARY;
150       clip_plus.gtk_sel_atom = gdk_atom_intern("CLIPBOARD", FALSE);
151   
152 ***************
153 *** 5128,5134 ****
154         char_u *p;
155   
156         for (p = s; p < s + len; ++p)
157 !           if (*p & 0x80) goto not_ascii;
158   
159         pango_glyph_string_set_size(glyphs, len);
160   
161 --- 5188,5195 ----
162         char_u *p;
163   
164         for (p = s; p < s + len; ++p)
165 !           if (*p & 0x80)
166 !               goto not_ascii;
167   
168         pango_glyph_string_set_size(glyphs, len);
169   
170 *** ../vim-6.2.427/src/ui.c     Fri Apr  2 11:36:09 2004
171 --- src/ui.c    Fri Apr  2 12:51:57 2004
172 ***************
173 *** 1913,1918 ****
174 --- 1913,1921 ----
175   }
176   
177   static Atom   vim_atom;       /* Vim's own special selection format */
178 + #ifdef FEAT_MBYTE
179 + static Atom   vimenc_atom;    /* Vim's extended selection format */
180 + #endif
181   static Atom   compound_text_atom;
182   static Atom   text_atom;
183   static Atom   targets_atom;
184 ***************
185 *** 1922,1927 ****
186 --- 1925,1933 ----
187       Display   *dpy;
188   {
189       vim_atom         = XInternAtom(dpy, VIM_ATOM_NAME,   False);
190 + #ifdef FEAT_MBYTE
191 +     vimenc_atom              = XInternAtom(dpy, VIMENC_ATOM_NAME,False);
192 + #endif
193       compound_text_atom = XInternAtom(dpy, "COMPOUND_TEXT", False);
194       text_atom        = XInternAtom(dpy, "TEXT",          False);
195       targets_atom       = XInternAtom(dpy, "TARGETS",       False);
196 ***************
197 *** 1952,1957 ****
198 --- 1958,1966 ----
199       char_u    *p;
200       char      **text_list = NULL;
201       VimClipboard      *cbd;
202 + #ifdef FEAT_MBYTE
203 +     char_u    *tmpbuf = NULL;
204 + #endif
205   
206       if (*sel_atom == clip_plus.sel_atom)
207         cbd = &clip_plus;
208 ***************
209 *** 1972,1977 ****
210 --- 1981,2017 ----
211         motion_type = *p++;
212         len--;
213       }
214
215 + #ifdef FEAT_MBYTE
216 +     else if (*type == vimenc_atom)
217 +     {
218 +       char_u          *enc;
219 +       vimconv_T       conv;
220 +       int             convlen;
221
222 +       motion_type = *p++;
223 +       --len;
224
225 +       enc = p;
226 +       p += STRLEN(p) + 1;
227 +       len -= p - enc;
228
229 +       /* If the encoding of the text is different from 'encoding', attempt
230 +        * converting it. */
231 +       conv.vc_type = CONV_NONE;
232 +       convert_setup(&conv, enc, p_enc);
233 +       if (conv.vc_type != CONV_NONE)
234 +       {
235 +           convlen = len;      /* Need to use an int here. */
236 +           tmpbuf = string_convert(&conv, p, &convlen);
237 +           len = convlen;
238 +           if (tmpbuf != NULL)
239 +               p = tmpbuf;
240 +           convert_setup(&conv, NULL, NULL);
241 +       }
242 +     }
243 + #endif
244
245       else if (*type == compound_text_atom || (
246   #ifdef FEAT_MBYTE
247                 enc_dbcs != 0 &&
248 ***************
249 *** 2000,2006 ****
250   
251       if (text_list != NULL)
252         XFreeStringList(text_list);
253
254       XtFree((char *)value);
255       *(int *)success = TRUE;
256   }
257 --- 2040,2048 ----
258   
259       if (text_list != NULL)
260         XFreeStringList(text_list);
261 ! #ifdef FEAT_MBYTE
262 !     vim_free(tmpbuf);
263 ! #endif
264       XtFree((char *)value);
265       *(int *)success = TRUE;
266   }
267 ***************
268 *** 2018,2030 ****
269       int               nbytes = 0;
270       char_u    *buffer;
271   
272 !     for (i = 0; i < 4; i++)
273       {
274         switch (i)
275         {
276 !           case 0:  type = vim_atom;   break;
277 !           case 1:  type = compound_text_atom; break;
278 !           case 2:  type = text_atom;  break;
279             default: type = XA_STRING;
280         }
281         XtGetSelectionValue(myShell, cbd->sel_atom, type,
282 --- 2060,2081 ----
283       int               nbytes = 0;
284       char_u    *buffer;
285   
286 !     for (i =
287 ! #ifdef FEAT_MBYTE
288 !           0
289 ! #else
290 !           1
291 ! #endif
292 !           ; i < 5; i++)
293       {
294         switch (i)
295         {
296 ! #ifdef FEAT_MBYTE
297 !           case 0:  type = vimenc_atom;        break;
298 ! #endif
299 !           case 1:  type = vim_atom;           break;
300 !           case 2:  type = compound_text_atom; break;
301 !           case 3:  type = text_atom;          break;
302             default: type = XA_STRING;
303         }
304         XtGetSelectionValue(myShell, cbd->sel_atom, type,
305 ***************
306 *** 2084,2089 ****
307 --- 2138,2144 ----
308       char_u    *result;
309       int               motion_type;
310       VimClipboard      *cbd;
311 +     int               i;
312   
313       if (*sel_atom == clip_plus.sel_atom)
314         cbd = &clip_plus;
315 ***************
316 *** 2098,2120 ****
317       {
318         Atom *array;
319   
320 !       if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 5))) == NULL)
321             return False;
322         *value = (XtPointer)array;
323 !       array[0] = XA_STRING;
324 !       array[1] = targets_atom;
325 !       array[2] = vim_atom;
326 !       array[3] = text_atom;
327 !       array[4] = compound_text_atom;
328         *type = XA_ATOM;
329         /* This used to be: *format = sizeof(Atom) * 8; but that caused
330          * crashes on 64 bit machines. (Peter Derr) */
331         *format = 32;
332 !       *length = 5;
333         return True;
334       }
335   
336       if (       *target != XA_STRING
337             && *target != vim_atom
338             && *target != text_atom
339             && *target != compound_text_atom)
340 --- 2153,2182 ----
341       {
342         Atom *array;
343   
344 !       if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 6))) == NULL)
345             return False;
346         *value = (XtPointer)array;
347 !       i = 0;
348 !       array[i++] = XA_STRING;
349 !       array[i++] = targets_atom;
350 ! #ifdef FEAT_MBYTE
351 !       array[i++] = vimenc_atom;
352 ! #endif
353 !       array[i++] = vim_atom;
354 !       array[i++] = text_atom;
355 !       array[i++] = compound_text_atom;
356         *type = XA_ATOM;
357         /* This used to be: *format = sizeof(Atom) * 8; but that caused
358          * crashes on 64 bit machines. (Peter Derr) */
359         *format = 32;
360 !       *length = i;
361         return True;
362       }
363   
364       if (       *target != XA_STRING
365 + #ifdef FEAT_MBYTE
366 +           && *target != vimenc_atom
367 + #endif
368             && *target != vim_atom
369             && *target != text_atom
370             && *target != compound_text_atom)
371 ***************
372 *** 2129,2134 ****
373 --- 2191,2202 ----
374       if (*target == vim_atom)
375         (*length)++;
376   
377 + #ifdef FEAT_MBYTE
378 +     /* Our own format with encoding: motion 'encoding' NUL text */
379 +     if (*target == vimenc_atom)
380 +       *length += STRLEN(p_enc) + 2;
381 + #endif
382
383       *value = XtMalloc((Cardinal)*length);
384       result = (char_u *)*value;
385       if (result == NULL)
386 ***************
387 *** 2159,2164 ****
388 --- 2227,2245 ----
389         *length = text_prop.nitems;
390         *type = compound_text_atom;
391       }
392
393 + #ifdef FEAT_MBYTE
394 +     else if (*target == vimenc_atom)
395 +     {
396 +       int l = STRLEN(p_enc);
397
398 +       result[0] = motion_type;
399 +       STRCPY(result + 1, p_enc);
400 +       mch_memmove(result + l + 2, string, (size_t)(*length - l - 2));
401 +       *type = vimenc_atom;
402 +     }
403 + #endif
404
405       else
406       {
407         result[0] = motion_type;
408 *** ../vim-6.2.427/src/vim.h    Thu Mar 18 14:39:31 2004
409 --- src/vim.h   Fri Apr  2 12:34:09 2004
410 ***************
411 *** 1473,1480 ****
412   
413   #ifdef FEAT_CLIPBOARD
414   
415 ! /* Vim-specific selection type for X11 */
416   #define VIM_ATOM_NAME "_VIM_TEXT"
417   
418   /* Selection states for modeless selection */
419   # define SELECT_CLEARED               0
420 --- 1473,1483 ----
421   
422   #ifdef FEAT_CLIPBOARD
423   
424 ! /* VIM_ATOM_NAME is the older Vim-specific selection type for X11.  Still
425 !  * supported for when a mix of Vim versions is used. VIMENC_ATOM_NAME includes
426 !  * the encoding to support Vims using different 'encoding' values. */
427   #define VIM_ATOM_NAME "_VIM_TEXT"
428 + #define VIMENC_ATOM_NAME "_VIMENC_TEXT"
429   
430   /* Selection states for modeless selection */
431   # define SELECT_CLEARED               0
432 *** ../vim-6.2.427/src/version.c        Fri Apr  2 11:36:09 2004
433 --- src/version.c       Fri Apr  2 14:05:46 2004
434 ***************
435 *** 639,640 ****
436 --- 639,642 ----
437   {   /* Add new patch number below this line */
438 + /**/
439 +     428,
440   /**/
441
442 -- 
443 You can tune a file system, but you can't tuna fish
444                                                         -- man tunefs
445
446  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
447 ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
448 \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
449  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
This page took 0.063418 seconds and 3 git commands to generate.