home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / old / 5.6.036 < prev    next >
Encoding:
Internet Message Format  |  2000-03-28  |  6.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.036
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.036
  8. Problem:    GTK GUI: Copy/paste text doesn't work between gvim and Eterm.
  9. Solution:   Support TEXT and COMPOUND_TEXT selection targets. (Sung-Hyun Nam)
  10. Files:        src/gui_gtk_x11.c
  11.  
  12.  
  13. *** ../vim-5.6.35/src/gui_gtk_x11.c    Fri Jan 21 20:44:10 2000
  14. --- src/gui_gtk_x11.c    Tue Mar 28 11:21:06 2000
  15. ***************
  16. *** 43,48 ****
  17. --- 43,50 ----
  18.   enum {
  19.       SELECTION_TYPE_NONE,
  20.       SELECTION_STRING,
  21. +     SELECTION_TEXT,
  22. +     SELECTION_COMPOUND_TEXT,
  23.       SELECTION_CLIPBOARD
  24.   };
  25.   
  26. ***************
  27. *** 670,678 ****
  28.   static void
  29.   selection_received_event(GtkWidget * widget, GtkSelectionData * data)
  30.   {
  31. !     int motion_type;
  32. !     long_u len;
  33. !     char_u *p;
  34.   
  35.       if ((!data->data) || (data->length <= 0)) {
  36.       received_selection = RS_FAIL;
  37. --- 672,681 ----
  38.   static void
  39.   selection_received_event(GtkWidget * widget, GtkSelectionData * data)
  40.   {
  41. !     int        motion_type;
  42. !     long_u    len;
  43. !     char_u    *p;
  44. !     int        free_p = FALSE;
  45.   
  46.       if ((!data->data) || (data->length <= 0)) {
  47.       received_selection = RS_FAIL;
  48. ***************
  49. *** 684,691 ****
  50.       }
  51.   
  52.       motion_type = MCHAR;
  53. !     p = (char_u *) data->data;
  54. !     len = data->length;
  55.   
  56.       if (data->type == clipboard.atom) {
  57.       motion_type = *p++;
  58. --- 687,716 ----
  59.       }
  60.   
  61.       motion_type = MCHAR;
  62. !     if (data->type == gdk_atom_intern("COMPOUND_TEXT", FALSE)
  63. !         || data->type == gdk_atom_intern("TEXT", FALSE))
  64. !     {
  65. !     int    count, i;
  66. !     char    **list;
  67. !     GString *str = g_string_new(NULL);
  68. !     count = gdk_text_property_to_text_list(data->type, data->format,
  69. !                          data->data, data->length, &list);
  70. !     len = 0;
  71. !     for (i = 0; i < count; i++)
  72. !         g_string_append(str, list[i]);
  73. !     p = str->str;
  74. !     len = str->len;
  75. !     g_string_free(str, FALSE);
  76. !     gdk_free_text_list(list);
  77. !     free_p = TRUE;
  78. !     }
  79. !     else
  80. !     {
  81. !     p = (char_u *)data->data;
  82. !     len = data->length;
  83. !     }
  84.   
  85.       if (data->type == clipboard.atom) {
  86.       motion_type = *p++;
  87. ***************
  88. *** 695,700 ****
  89. --- 720,728 ----
  90.       received_selection = RS_OK;
  91.       if (gtk_main_level() > 0)
  92.       gtk_main_quit();
  93. +     if (free_p)
  94. +     g_free(p);
  95.   }
  96.   
  97.   #ifdef GTK_HAVE_FEATURES_1_1_4
  98. ***************
  99. *** 719,725 ****
  100.       if (!clipboard.owned)
  101.       return;            /* Shouldn't ever happen */
  102.   
  103. !     if (info != SELECTION_STRING && info != SELECTION_CLIPBOARD)
  104.       return;
  105.   
  106.       clip_get_selection();
  107. --- 747,754 ----
  108.       if (!clipboard.owned)
  109.       return;            /* Shouldn't ever happen */
  110.   
  111. !     if (info != SELECTION_STRING && info != SELECTION_CLIPBOARD
  112. !         && info != SELECTION_COMPOUND_TEXT && info != SELECTION_TEXT)
  113.       return;
  114.   
  115.       clip_get_selection();
  116. ***************
  117. *** 746,751 ****
  118. --- 775,798 ----
  119.       mch_memmove(result + 1, string, (size_t)(length - 1));
  120.       type = clipboard.atom;
  121.       }
  122. +     else if (info == SELECTION_COMPOUND_TEXT || info == SELECTION_TEXT)
  123. +     {
  124. +     char *str;
  125. +     gint format, new_len;
  126. +     vim_free(result);
  127. +     str = g_new(char, length + 1);
  128. +     mch_memmove(str, string, (size_t) length);
  129. +     vim_free(string);
  130. +     str[length] = '\0';
  131. +     gdk_string_to_compound_text(str, &type, &format, &result, &new_len);
  132. +     g_free(str);
  133. +     selection_data->type = type;
  134. +     selection_data->format = format;
  135. +     gtk_selection_data_set(selection_data, type, format, result, new_len);
  136. +     gdk_free_compound_text(result);
  137. +     return;
  138. +     }
  139.       else
  140.       {
  141.       mch_memmove(result, string, (size_t)length);
  142. ***************
  143. *** 1327,1332 ****
  144. --- 1374,1387 ----
  145.       return TRUE;
  146.   }
  147.   
  148. + #define VIM_ATOM_NAME "_VIM_TEXT"
  149. + static const GtkTargetEntry primary_targets[] = {
  150. +     {VIM_ATOM_NAME, 0, SELECTION_CLIPBOARD},
  151. +     {"STRING", 0, SELECTION_STRING},
  152. +     {"TEXT", 0, SELECTION_TEXT},
  153. +     {"COMPOUND_TEXT", 0, SELECTION_COMPOUND_TEXT}
  154. + };
  155.   /*
  156.    * Initialise the X GUI.  Create all the windows, set up all the call-backs etc.
  157.    * Returns OK for success, FAIL when the GUI can't be started.
  158. ***************
  159. *** 1443,1449 ****
  160.       gui.def_back_pixel = gui.back_pixel;
  161.       }
  162.       gui.visibility = GDK_VISIBILITY_UNOBSCURED;
  163. !     clipboard.atom = gdk_atom_intern("_VIM_TEXT", FALSE);
  164.       save_yourself_atom = gdk_atom_intern("WM_SAVE_YOURSELF", FALSE);
  165.       reread_rcfiles_atom = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
  166.   
  167. --- 1498,1504 ----
  168.       gui.def_back_pixel = gui.back_pixel;
  169.       }
  170.       gui.visibility = GDK_VISIBILITY_UNOBSCURED;
  171. !     clipboard.atom = gdk_atom_intern(VIM_ATOM_NAME, FALSE);
  172.       save_yourself_atom = gdk_atom_intern("WM_SAVE_YOURSELF", FALSE);
  173.       reread_rcfiles_atom = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
  174.   
  175. ***************
  176. *** 1492,1501 ****
  177.   
  178.       /* gtk_selection_add_target() is not in GTK 1.1.2 */
  179.   #ifdef GTK_HAVE_FEATURES_1_1_4
  180. !     gtk_selection_add_target(gui.drawarea, GDK_SELECTION_PRIMARY,
  181. !                 GDK_TARGET_STRING, SELECTION_STRING);
  182. !     gtk_selection_add_target(gui.drawarea, GDK_SELECTION_PRIMARY,
  183. !                 clipboard.atom, SELECTION_CLIPBOARD);
  184.       gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get",
  185.                  GTK_SIGNAL_FUNC(selection_get_event), NULL);
  186.   #else
  187. --- 1547,1555 ----
  188.   
  189.       /* gtk_selection_add_target() is not in GTK 1.1.2 */
  190.   #ifdef GTK_HAVE_FEATURES_1_1_4
  191. !     gtk_selection_add_targets(gui.drawarea, GDK_SELECTION_PRIMARY,
  192. !                   primary_targets,
  193. !                   sizeof(primary_targets)/sizeof(primary_targets[0]));
  194.       gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get",
  195.                  GTK_SIGNAL_FUNC(selection_get_event), NULL);
  196.   #else
  197. ***************
  198. *** 2097,2103 ****
  199.       if ((sdup = g_strdup((const char *)font_name)) == NULL)
  200.           return FAIL;
  201.   
  202. !     /* slipt up the whole */
  203.       i = 0;
  204.       for (tmp = sdup; *tmp != '\0'; ++tmp)
  205.           if (*tmp == '-')
  206. --- 2151,2157 ----
  207.       if ((sdup = g_strdup((const char *)font_name)) == NULL)
  208.           return FAIL;
  209.   
  210. !     /* split up the whole */
  211.       i = 0;
  212.       for (tmp = sdup; *tmp != '\0'; ++tmp)
  213.           if (*tmp == '-')
  214. *** ../vim-5.6.35/src/version.c    Mon Mar 27 21:53:47 2000
  215. --- src/version.c    Tue Mar 28 11:27:27 2000
  216. ***************
  217. *** 420,421 ****
  218. --- 420,423 ----
  219.   {   /* Add new patch number below this line */
  220. + /**/
  221. +     36,
  222.   /**/
  223.  
  224. -- 
  225. A computer programmer is a device for turning coffee into bugs.
  226.                     Bram Moolenaar
  227.  
  228. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  229. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  230.