Loading ...
Sorry, an error occurred while loading the content.

urp, here is the patch,

Expand Messages
  • Maiorana, Jason
    looks like the attachment was trimmed, ... +++ gui_gtk_x11.c Wed Aug 14 23:22:46 2002 @@ -83,7 +83,8 @@ SELECTION_STRING, SELECTION_TEXT,
    Message 1 of 2 , Aug 15, 2002
    • 0 Attachment
      looks like the attachment was trimmed,
      here it is inline:


      --- gui_gtk_x11.c.OLD Wed Mar 13 15:19:58 2002
      +++ gui_gtk_x11.c Wed Aug 14 23:22:46 2002
      @@ -83,7 +83,8 @@
      SELECTION_STRING,
      SELECTION_TEXT,
      SELECTION_COMPOUND_TEXT,
      - SELECTION_VIM
      + SELECTION_VIM,
      + SELECTION_UTF8_STRING
      };

      /*
      @@ -133,6 +134,7 @@
      static GdkAtom compound_text_atom = GDK_NONE;
      static GdkAtom text_atom = GDK_NONE;
      static GdkAtom vim_atom = GDK_NONE; /* Vim's own special selection
      format */
      +static GdkAtom utf8_string_atom = GDK_NONE;

      /*
      * Keycodes recognized by vim.
      @@ -941,6 +943,37 @@
      g_string_free(str, FALSE);
      free_p = TRUE;
      }
      + else if (data->type == utf8_string_atom)
      + {
      + /*convert "utf-8" to "p_enc"*/
      + vimconv_T cvrt;
      +
      +# ifdef USE_ICONV
      + cvrt.vc_fd = (iconv_t)-1;
      +# endif
      + convert_setup(&cvrt,"utf-8",p_enc);
      +
      + if (cvrt.vc_type == CONV_NONE)
      + {
      + p = (char_u *)data->data;
      + len = data->length;
      + }
      + else
      + {
      + int temp;
      +
      + p = string_convert(&cvrt, (char_u *)data->data, &temp);
      + len = (long_u)temp;
      + if(!p)
      + {
      + received_selection = RS_FAIL;
      + if (gtk_main_level() > 0)
      + gtk_main_quit();
      + return;
      + }
      + free_p = TRUE;
      + }
      + }
      else
      {
      p = (char_u *)data->data;
      @@ -990,6 +1023,7 @@

      if (info != (guint)SELECTION_STRING
      && info != (guint)SELECTION_VIM
      + && info != (guint)SELECTION_UTF8_STRING
      && info != (guint)SELECTION_COMPOUND_TEXT
      && info != (guint)SELECTION_TEXT)
      return;
      @@ -1000,47 +1034,78 @@
      if (motion_type < 0)
      return;

      - /* For our own format, the first byte contains the motion type */
      - if (info == (guint)SELECTION_VIM)
      - length++;
      -
      - result = lalloc((long_u)(2 * length), FALSE);
      - if (result == NULL)
      + if( info == (guint)SELECTION_UTF8_STRING)
      {
      - vim_free(string);
      - return;
      - }
      + /*convert "p_enc" to "utf-8" */
      + vimconv_T cvrt;
      +
      +# ifdef USE_ICONV
      + cvrt.vc_fd = (iconv_t)-1;
      +# endif
      + convert_setup(&cvrt,p_enc,"utf-8");

      - if (info == (guint)SELECTION_VIM)
      - {
      - result[0] = motion_type;
      - mch_memmove(result + 1, string, (size_t)(length - 1));
      - type = vim_atom;
      - }
      - else if (info == (guint)SELECTION_COMPOUND_TEXT
      - || info ==
      (guint)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;
      + if (cvrt.vc_type == CONV_NONE)
      + {
      + result=string;
      + string=NULL;
      + }
      + else
      + {
      + int temp = (int)length;
      + result = string_convert(&cvrt, string, &temp);
      + length = (long_u)temp;
      +
      + if(!result)
      + return;
      + }
      +
      + type = utf8_string_atom;
      }
      else
      {
      - mch_memmove(result, string, (size_t)length);
      - type = GDK_TARGET_STRING;
      + /* For our own format, the first byte contains the motion type
      */
      + if (info == (guint)SELECTION_VIM)
      + length++;
      +
      + result = lalloc((long_u)(2 * length), FALSE);
      + if (result == NULL)
      + {
      + vim_free(string);
      + return;
      + }
      +
      + if (info == (guint)SELECTION_VIM)
      + {
      + result[0] = motion_type;
      + mch_memmove(result + 1, string, (size_t)(length - 1));
      + type = vim_atom;
      + }
      + else if (info == (guint)SELECTION_COMPOUND_TEXT
      + || info ==
      (guint)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);
      + type = GDK_TARGET_STRING;
      + }
      }
      +
      selection_data->type = selection_data->target;
      selection_data->format = 8; /* 8 bits per char */

      @@ -1796,6 +1861,7 @@

      static const GtkTargetEntry primary_targets[] = {
      {VIM_ATOM_NAME, 0, SELECTION_VIM},
      + {"UTF8_STRING", 0, SELECTION_UTF8_STRING},
      {"COMPOUND_TEXT", 0, SELECTION_COMPOUND_TEXT},
      {"TEXT", 0, SELECTION_TEXT},
      {"STRING", 0, SELECTION_STRING}
      @@ -1821,6 +1887,7 @@
      /* Initialise atoms */
      compound_text_atom = gdk_atom_intern("COMPOUND_TEXT", FALSE);
      text_atom = gdk_atom_intern("TEXT", FALSE);
      + utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE);

      /* Set default foreground and background colors. */
      gui.norm_pixel = gui.def_norm_pixel;
      @@ -3534,6 +3601,17 @@
      while (received_selection == RS_NONE)
      gtk_main(); /* wait for selection_received_event */

      + //Lets use UTF8_STRING if available!!
      + if (received_selection == RS_FAIL)
      + {
      + /* Now try to get it out of the usual string selection. */
      + received_selection = RS_NONE;
      + (void)gtk_selection_convert(gui.drawarea, cbd->gtk_sel_atom,
      + gdk_atom_intern("UTF8_STRING",
      FALSE),
      + (guint32)GDK_CURRENT_TIME);
      + while (received_selection == RS_NONE)
      + gtk_main(); /* wait for selection_received_event */
      + }
      if (received_selection == RS_FAIL)
      {
      /* Now try to get it out of the usual string selection. */
    • Glenn Maynard
      ... Don t forget to free cvrt with convert_setup(&cvrt, NULL, NULL); (or perhaps , ; I forget offhand.) It needs to close iconv, at least. -- Glenn
      Message 2 of 2 , Aug 15, 2002
      • 0 Attachment
        On Thu, Aug 15, 2002 at 01:56:53PM -0400, Maiorana, Jason wrote:
        > + else if (data->type == utf8_string_atom)
        > + {
        > + /*convert "utf-8" to "p_enc"*/
        > + vimconv_T cvrt;
        > +
        > +# ifdef USE_ICONV
        > + cvrt.vc_fd = (iconv_t)-1;
        > +# endif
        > + convert_setup(&cvrt,"utf-8",p_enc);
        > +
        > + if (cvrt.vc_type == CONV_NONE)
        > + {
        > + p = (char_u *)data->data;
        > + len = data->length;
        > + }
        > + else
        > + {
        > + int temp;
        > +
        > + p = string_convert(&cvrt, (char_u *)data->data, &temp);
        > + len = (long_u)temp;
        > + if(!p)
        > + {
        > + received_selection = RS_FAIL;
        > + if (gtk_main_level() > 0)
        > + gtk_main_quit();
        > + return;
        > + }
        > + free_p = TRUE;

        Don't forget to free cvrt with convert_setup(&cvrt, NULL, NULL); (or
        perhaps "", ""; I forget offhand.) It needs to close iconv, at least.

        --
        Glenn Maynard
      Your message has been successfully submitted and would be delivered to recipients shortly.