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 / 6.2.388 < prev    next >
Encoding:
Internet Message Format  |  2004-03-21  |  3.5 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.388
  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. Patch 6.2.388
  11. Problem:    GTK: When displaying some double-width characters they are drawn
  12.         as single-width, because of conversion to UTF-8.
  13. Solution:   Check the width that GTK uses and add a space if it's one instead
  14.         of two.
  15. Files:        src/gui_gtk_x11.c
  16.  
  17.  
  18. *** ../vim-6.2.387/src/gui_gtk_x11.c    Mon Feb  9 18:45:58 2004
  19. --- src/gui_gtk_x11.c    Sat Mar 20 13:21:41 2004
  20. ***************
  21. *** 5038,5047 ****
  22.   gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags)
  23.   {
  24.       GdkRectangle    area;            /* area for clip mask      */
  25. -     char_u        *conv_buf = NULL;   /* result of UTF-8 conversion */
  26.       PangoGlyphString    *glyphs;        /* glyphs of current item      */
  27.       int            column_offset = 0;  /* column offset in cells      */
  28.       int            i;
  29.   
  30.       if (gui.text_context == NULL || gui.drawarea->window == NULL)
  31.       return len;
  32. --- 5045,5058 ----
  33.   gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags)
  34.   {
  35.       GdkRectangle    area;            /* area for clip mask      */
  36.       PangoGlyphString    *glyphs;        /* glyphs of current item      */
  37.       int            column_offset = 0;  /* column offset in cells      */
  38.       int            i;
  39. +     char_u        *conv_buf = NULL;   /* result of UTF-8 conversion */
  40. +     char_u        *new_conv_buf;
  41. +     int            convlen;
  42. +     char_u        *sp, *bp;
  43. +     int            plen;
  44.   
  45.       if (gui.text_context == NULL || gui.drawarea->window == NULL)
  46.       return len;
  47. ***************
  48. *** 5054,5063 ****
  49.        * prohibits changing this to something else than UTF-8 if the GUI is
  50.        * in use.
  51.        */
  52. !     conv_buf = string_convert(&output_conv, s, &len);
  53. !     s = conv_buf;
  54.       g_return_val_if_fail(conv_buf != NULL, len);
  55.       }
  56.   
  57.       /*
  58. --- 5065,5101 ----
  59.        * prohibits changing this to something else than UTF-8 if the GUI is
  60.        * in use.
  61.        */
  62. !     convlen = len;
  63. !     conv_buf = string_convert(&output_conv, s, &convlen);
  64.       g_return_val_if_fail(conv_buf != NULL, len);
  65. +     /* Correct for differences in char width: some chars are
  66. +      * double-wide in 'encoding' but single-wide in utf-8.  Add a space to
  67. +      * compensate for that. */
  68. +     for (sp = s, bp = conv_buf; sp < s + len && bp < conv_buf + convlen; )
  69. +     {
  70. +         plen = utf_ptr2len_check(bp);
  71. +         if ((*mb_ptr2cells)(sp) == 2 && utf_ptr2cells(bp) == 1)
  72. +         {
  73. +         new_conv_buf = alloc(convlen + 2);
  74. +         if (new_conv_buf == NULL)
  75. +             return len;
  76. +         plen += bp - conv_buf;
  77. +         mch_memmove(new_conv_buf, conv_buf, plen);
  78. +         new_conv_buf[plen] = ' ';
  79. +         mch_memmove(new_conv_buf + plen + 1, conv_buf + plen,
  80. +                               convlen - plen + 1);
  81. +         vim_free(conv_buf);
  82. +         conv_buf = new_conv_buf;
  83. +         ++convlen;
  84. +         bp = conv_buf + plen;
  85. +         plen = 1;
  86. +         }
  87. +         sp += (*mb_ptr2len_check)(sp);
  88. +         bp += plen;
  89. +     }
  90. +     s = conv_buf;
  91. +     len = convlen;
  92.       }
  93.   
  94.       /*
  95. *** ../vim-6.2.387/src/version.c    Mon Mar 22 14:33:28 2004
  96. --- src/version.c    Mon Mar 22 14:38:38 2004
  97. ***************
  98. *** 639,640 ****
  99. --- 639,642 ----
  100.   {   /* Add new patch number below this line */
  101. + /**/
  102. +     388,
  103.   /**/
  104.  
  105. -- 
  106. hundred-and-one symptoms of being an internet addict:
  107. 92. It takes you two hours to check all 14 of your mailboxes.
  108.  
  109.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  110. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  111. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  112.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  113.