home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 5.6.036
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- ------------
-
- Patch 5.6.036
- Problem: GTK GUI: Copy/paste text doesn't work between gvim and Eterm.
- Solution: Support TEXT and COMPOUND_TEXT selection targets. (Sung-Hyun Nam)
- Files: src/gui_gtk_x11.c
-
-
- *** ../vim-5.6.35/src/gui_gtk_x11.c Fri Jan 21 20:44:10 2000
- --- src/gui_gtk_x11.c Tue Mar 28 11:21:06 2000
- ***************
- *** 43,48 ****
- --- 43,50 ----
- enum {
- SELECTION_TYPE_NONE,
- SELECTION_STRING,
- + SELECTION_TEXT,
- + SELECTION_COMPOUND_TEXT,
- SELECTION_CLIPBOARD
- };
-
- ***************
- *** 670,678 ****
- static void
- selection_received_event(GtkWidget * widget, GtkSelectionData * data)
- {
- ! int motion_type;
- ! long_u len;
- ! char_u *p;
-
- if ((!data->data) || (data->length <= 0)) {
- received_selection = RS_FAIL;
- --- 672,681 ----
- static void
- selection_received_event(GtkWidget * widget, GtkSelectionData * data)
- {
- ! int motion_type;
- ! long_u len;
- ! char_u *p;
- ! int free_p = FALSE;
-
- if ((!data->data) || (data->length <= 0)) {
- received_selection = RS_FAIL;
- ***************
- *** 684,691 ****
- }
-
- motion_type = MCHAR;
- ! p = (char_u *) data->data;
- ! len = data->length;
-
- if (data->type == clipboard.atom) {
- motion_type = *p++;
- --- 687,716 ----
- }
-
- motion_type = MCHAR;
- ! if (data->type == gdk_atom_intern("COMPOUND_TEXT", FALSE)
- ! || data->type == gdk_atom_intern("TEXT", FALSE))
- ! {
- ! int count, i;
- ! char **list;
- ! GString *str = g_string_new(NULL);
- !
- ! count = gdk_text_property_to_text_list(data->type, data->format,
- ! data->data, data->length, &list);
- ! len = 0;
- ! for (i = 0; i < count; i++)
- ! g_string_append(str, list[i]);
- !
- ! p = str->str;
- ! len = str->len;
- ! g_string_free(str, FALSE);
- ! gdk_free_text_list(list);
- ! free_p = TRUE;
- ! }
- ! else
- ! {
- ! p = (char_u *)data->data;
- ! len = data->length;
- ! }
-
- if (data->type == clipboard.atom) {
- motion_type = *p++;
- ***************
- *** 695,700 ****
- --- 720,728 ----
- received_selection = RS_OK;
- if (gtk_main_level() > 0)
- gtk_main_quit();
- +
- + if (free_p)
- + g_free(p);
- }
-
- #ifdef GTK_HAVE_FEATURES_1_1_4
- ***************
- *** 719,725 ****
- if (!clipboard.owned)
- return; /* Shouldn't ever happen */
-
- ! if (info != SELECTION_STRING && info != SELECTION_CLIPBOARD)
- return;
-
- clip_get_selection();
- --- 747,754 ----
- if (!clipboard.owned)
- return; /* Shouldn't ever happen */
-
- ! if (info != SELECTION_STRING && info != SELECTION_CLIPBOARD
- ! && info != SELECTION_COMPOUND_TEXT && info != SELECTION_TEXT)
- return;
-
- clip_get_selection();
- ***************
- *** 746,751 ****
- --- 775,798 ----
- mch_memmove(result + 1, string, (size_t)(length - 1));
- type = clipboard.atom;
- }
- + else if (info == SELECTION_COMPOUND_TEXT || info == SELECTION_TEXT)
- + {
- + char *str;
- + gint format, new_len;
- +
- + vim_free(result);
- + str = g_new(char, length + 1);
- + mch_memmove(str, string, (size_t) length);
- + vim_free(string);
- + str[length] = '\0';
- + gdk_string_to_compound_text(str, &type, &format, &result, &new_len);
- + g_free(str);
- + selection_data->type = type;
- + selection_data->format = format;
- + gtk_selection_data_set(selection_data, type, format, result, new_len);
- + gdk_free_compound_text(result);
- + return;
- + }
- else
- {
- mch_memmove(result, string, (size_t)length);
- ***************
- *** 1327,1332 ****
- --- 1374,1387 ----
- return TRUE;
- }
-
- + #define VIM_ATOM_NAME "_VIM_TEXT"
- + static const GtkTargetEntry primary_targets[] = {
- + {VIM_ATOM_NAME, 0, SELECTION_CLIPBOARD},
- + {"STRING", 0, SELECTION_STRING},
- + {"TEXT", 0, SELECTION_TEXT},
- + {"COMPOUND_TEXT", 0, SELECTION_COMPOUND_TEXT}
- + };
- +
- /*
- * Initialise the X GUI. Create all the windows, set up all the call-backs etc.
- * Returns OK for success, FAIL when the GUI can't be started.
- ***************
- *** 1443,1449 ****
- gui.def_back_pixel = gui.back_pixel;
- }
- gui.visibility = GDK_VISIBILITY_UNOBSCURED;
- ! clipboard.atom = gdk_atom_intern("_VIM_TEXT", FALSE);
- save_yourself_atom = gdk_atom_intern("WM_SAVE_YOURSELF", FALSE);
- reread_rcfiles_atom = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
-
- --- 1498,1504 ----
- gui.def_back_pixel = gui.back_pixel;
- }
- gui.visibility = GDK_VISIBILITY_UNOBSCURED;
- ! clipboard.atom = gdk_atom_intern(VIM_ATOM_NAME, FALSE);
- save_yourself_atom = gdk_atom_intern("WM_SAVE_YOURSELF", FALSE);
- reread_rcfiles_atom = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
-
- ***************
- *** 1492,1501 ****
-
- /* gtk_selection_add_target() is not in GTK 1.1.2 */
- #ifdef GTK_HAVE_FEATURES_1_1_4
- ! gtk_selection_add_target(gui.drawarea, GDK_SELECTION_PRIMARY,
- ! GDK_TARGET_STRING, SELECTION_STRING);
- ! gtk_selection_add_target(gui.drawarea, GDK_SELECTION_PRIMARY,
- ! clipboard.atom, SELECTION_CLIPBOARD);
- gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get",
- GTK_SIGNAL_FUNC(selection_get_event), NULL);
- #else
- --- 1547,1555 ----
-
- /* gtk_selection_add_target() is not in GTK 1.1.2 */
- #ifdef GTK_HAVE_FEATURES_1_1_4
- ! gtk_selection_add_targets(gui.drawarea, GDK_SELECTION_PRIMARY,
- ! primary_targets,
- ! sizeof(primary_targets)/sizeof(primary_targets[0]));
- gtk_signal_connect(GTK_OBJECT(gui.drawarea), "selection_get",
- GTK_SIGNAL_FUNC(selection_get_event), NULL);
- #else
- ***************
- *** 2097,2103 ****
- if ((sdup = g_strdup((const char *)font_name)) == NULL)
- return FAIL;
-
- ! /* slipt up the whole */
- i = 0;
- for (tmp = sdup; *tmp != '\0'; ++tmp)
- if (*tmp == '-')
- --- 2151,2157 ----
- if ((sdup = g_strdup((const char *)font_name)) == NULL)
- return FAIL;
-
- ! /* split up the whole */
- i = 0;
- for (tmp = sdup; *tmp != '\0'; ++tmp)
- if (*tmp == '-')
- *** ../vim-5.6.35/src/version.c Mon Mar 27 21:53:47 2000
- --- src/version.c Tue Mar 28 11:27:27 2000
- ***************
- *** 420,421 ****
- --- 420,423 ----
- { /* Add new patch number below this line */
- + /**/
- + 36,
- /**/
-
- --
- A computer programmer is a device for turning coffee into bugs.
- Bram Moolenaar
-
- /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
- \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
-