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.087 < prev    next >
Encoding:
Internet Message Format  |  2000-06-04  |  7.5 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6.087
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6.087
  8. Problem:    Multi-byte: Commands and messages with multi-byte characters are
  9.         displayed wrong.
  10. Solution:   Detect double-byte characters. (Yasuhiro Matsumoto)
  11. Files:        src/ex_getln.c, src/message.c, src/misc2.c, src/screen.c
  12.  
  13.  
  14. *** ../vim-5.6.86/src/ex_getln.c    Mon Apr  3 21:11:13 2000
  15. --- src/ex_getln.c    Mon Jun  5 12:35:31 2000
  16. ***************
  17. *** 1352,1357 ****
  18. --- 1352,1363 ----
  19.       else
  20.   #endif
  21.           c = charsize(ccline.cmdbuff[i]);
  22. + #ifdef MULTI_BYTE
  23. +     /* multibyte wrap */
  24. +     if (is_dbcs && IsLeadByte(ccline.cmdbuff[i])
  25. +                  && (ccline.cmdspos % Columns + c == Columns))
  26. +         ccline.cmdspos++;
  27. + #endif
  28.       /* If the cmdline doesn't fit, put cursor on last visible char. */
  29.       if ((ccline.cmdspos += c) >= m)
  30.       {
  31. ***************
  32. *** 1687,1692 ****
  33. --- 1693,1699 ----
  34.       int        retval;
  35.       int        i;
  36.       int        m;
  37. +     int        c;
  38.   
  39.       if (len < 0)
  40.       len = STRLEN(str);
  41. ***************
  42. *** 1735,1753 ****
  43.           m = Columns * Rows;
  44.           else
  45.           m = MAXCOL;
  46. !         while (len--)
  47.           {
  48.   #ifdef CRYPTV
  49.           if (cmdline_crypt)
  50. !             i = 1;
  51.           else
  52.   #endif
  53. !             i = charsize(str[len]);
  54.           /* Stop cursor at the end of the screen */
  55. !         if (ccline.cmdspos + i >= m)
  56.               break;
  57.           ++ccline.cmdpos;
  58. !         ccline.cmdspos += i;
  59.           }
  60.       }
  61.       }
  62. --- 1742,1766 ----
  63.           m = Columns * Rows;
  64.           else
  65.           m = MAXCOL;
  66. !         for (i = 0; i < len; ++i)
  67.           {
  68.   #ifdef CRYPTV
  69.           if (cmdline_crypt)
  70. !             c = 1;
  71.           else
  72.   #endif
  73. !             c = charsize(str[i]);
  74. ! #ifdef MULTI_BYTE
  75. !         /* multibyte wrap */
  76. !         if (is_dbcs && IsLeadByte(str[i])
  77. !                    && ccline.cmdspos % Columns + c == Columns)
  78. !             ccline.cmdspos++;
  79. ! #endif
  80.           /* Stop cursor at the end of the screen */
  81. !         if (ccline.cmdspos + c >= m)
  82.               break;
  83.           ++ccline.cmdpos;
  84. !         ccline.cmdspos += c;
  85.           }
  86.       }
  87.       }
  88. *** ../vim-5.6.86/src/message.c    Mon Dec  6 17:58:35 1999
  89. --- src/message.c    Mon Jun  5 12:40:41 2000
  90. ***************
  91. *** 857,862 ****
  92. --- 857,877 ----
  93.   
  94.       while (--len >= 0)
  95.       {
  96. + #ifdef MULTI_BYTE
  97. +     /* check multibyte */
  98. +     if (is_dbcs && *(str + 1) != NUL && IsLeadByte(*str))
  99. +     {
  100. +         char_u buf[3];
  101. +         buf[0] = *str++;
  102. +         buf[1] = *str++;
  103. +         buf[2] = NUL;
  104. +         msg_puts_attr(buf, attr);
  105. +         retval += 2;
  106. +         --len;
  107. +         continue;
  108. +     }
  109. + #endif
  110.       msg_puts_attr(transchar(*str), attr);
  111.       retval += charsize(*str);
  112.       ++str;
  113. ***************
  114. *** 1229,1236 ****
  115.        *   (some terminals scroll automatically, some don't. To avoid
  116.        *   problems we scroll ourselves)
  117.        */
  118. !     if (msg_row >= Rows - 1 && (*s == '\n' || msg_col >= Columns - 1 ||
  119. !                   (*s == TAB && msg_col >= ((Columns - 1) & ~7))))
  120.       {
  121.           /* When no more prompt an no more room, truncate here */
  122.           if (msg_no_more && lines_left == 0)
  123. --- 1244,1257 ----
  124.        *   (some terminals scroll automatically, some don't. To avoid
  125.        *   problems we scroll ourselves)
  126.        */
  127. !     if (msg_row >= Rows - 1
  128. !         && (*s == '\n'
  129. !             || msg_col >= Columns - 1
  130. !             || (*s == TAB && msg_col >= ((Columns - 1) & ~7))
  131. ! #ifdef MULTI_BYTE
  132. !             || (is_dbcs && IsLeadByte(*s) && msg_col >= Columns - 2)
  133. ! #endif
  134. !             ))
  135.       {
  136.           /* When no more prompt an no more room, truncate here */
  137.           if (msg_no_more && lines_left == 0)
  138. ***************
  139. *** 1373,1378 ****
  140. --- 1394,1424 ----
  141.           msg_screen_putchar(' ', attr);
  142.           while (msg_col & 7);
  143.       }
  144. + #ifdef MULTI_BYTE
  145. +     else if (is_dbcs && *(s + 1) != NUL && IsLeadByte(*s))
  146. +     {
  147. +         if (msg_col % Columns == Columns - 1)
  148. +         {
  149. +         msg_screen_putchar('>', hl_attr(HLF_AT));
  150. +         continue;
  151. +         }
  152. +         else
  153. +         {
  154. +         char_u mbyte[3]; /* only for dbcs */
  155. +         mbyte[0] = *s;
  156. +         mbyte[1] = *(s + 1);
  157. +         mbyte[2] = NUL;
  158. +         screen_puts(mbyte, msg_row, msg_col, attr);
  159. +         if ((msg_col += 2) >= Columns)
  160. +         {
  161. +             msg_col = 0;
  162. +             ++msg_row;
  163. +         }
  164. +         ++s;
  165. +         }
  166. +     }
  167. + #endif
  168.       else
  169.           msg_screen_putchar(*s, attr);
  170.       ++s;
  171. *** ../vim-5.6.86/src/misc2.c    Sun Jun  4 20:25:26 2000
  172. --- src/misc2.c    Mon Jun  5 12:44:32 2000
  173. ***************
  174. *** 673,678 ****
  175. --- 673,686 ----
  176.       length = 1;                /* count the trailing '/' and NUL */
  177.       for (p = string; *p; p++)
  178.       {
  179. + #ifdef MULTI_BYTE
  180. +     if (is_dbcs && *(p + 1) != NUL && IsLeadByte(*p))
  181. +     {
  182. +         length += 2;
  183. +         ++p;    /* skip multibyte */
  184. +         continue;
  185. +     }
  186. + #endif
  187.       if (vim_strchr(esc_chars, *p) != NULL)
  188.           ++length;            /* count a backslash */
  189.       ++length;            /* count an ordinary char */
  190. ***************
  191. *** 683,688 ****
  192. --- 691,704 ----
  193.       p2 = escaped_string;
  194.       for (p = string; *p; p++)
  195.       {
  196. + #ifdef MULTI_BYTE
  197. +         if (is_dbcs && *(p + 1) != NUL && IsLeadByte(*p))
  198. +         {
  199. +         *p2++ = *p++;    /* skip multibyte lead  */
  200. +         *p2++ = *p;    /* skip multibyte trail */
  201. +         continue;
  202. +         }
  203. + #endif
  204.           if (vim_strchr(esc_chars, *p) != NULL)
  205.           *p2++ = '\\';
  206.           *p2++ = *p;
  207. *** ../vim-5.6.86/src/screen.c    Thu Apr 13 12:02:05 2000
  208. --- src/screen.c    Mon Jun  5 12:56:31 2000
  209. ***************
  210. *** 3211,3232 ****
  211.       int        attr;
  212.   {
  213.       char_u  *screenp;
  214.   
  215.       if (NextScreen != NULL && row < Rows)        /* safety check */
  216.       {
  217.       screenp = LinePointers[row] + col;
  218.       while (*text && col < Columns)
  219.       {
  220. !         if (*screenp != *text || *(screenp + Columns) != attr ||
  221. !                                 exmode_active)
  222.           {
  223.           *screenp = *text;
  224.           *(screenp + Columns) = attr;
  225.           screen_char(screenp, row, col);
  226.           }
  227. -         ++screenp;
  228. -         ++col;
  229. -         ++text;
  230.       }
  231.       }
  232.   }
  233. --- 3211,3265 ----
  234.       int        attr;
  235.   {
  236.       char_u  *screenp;
  237. + #ifdef MULTI_BYTE
  238. +     int        is_mbyte;
  239. + #endif
  240.   
  241.       if (NextScreen != NULL && row < Rows)        /* safety check */
  242.       {
  243.       screenp = LinePointers[row] + col;
  244.       while (*text && col < Columns)
  245.       {
  246. ! #ifdef MULTI_BYTE
  247. !         /* check if this is the first byte of a multibyte */
  248. !         if (is_dbcs && text[1] != NUL && IsLeadByte(*text))
  249. !         is_mbyte = 1;
  250. !         else
  251. !         is_mbyte = 0;
  252. ! #endif
  253. !         if (*screenp != *text
  254. ! #ifdef MULTI_BYTE
  255. !             || (is_mbyte && screenp[1] != text[1])
  256. ! #endif
  257. !             || *(screenp + Columns) != attr
  258. !             || exmode_active)
  259.           {
  260.           *screenp = *text;
  261.           *(screenp + Columns) = attr;
  262.           screen_char(screenp, row, col);
  263. + #ifdef MULTI_BYTE
  264. +         if (is_mbyte)
  265. +         {
  266. +             screenp[1] = text[1];
  267. +             screenp[Columns + 1] = attr;
  268. +             screen_char(screenp + 1, row, col + 1);
  269. +         }
  270. + #endif
  271. +         }
  272. + #ifdef MULTI_BYTE
  273. +         if (is_mbyte)
  274. +         {
  275. +         screenp += 2;
  276. +         col += 2;
  277. +         text += 2;
  278. +         }
  279. +         else
  280. + #endif
  281. +         {
  282. +         ++screenp;
  283. +         ++col;
  284. +         ++text;
  285.           }
  286.       }
  287.       }
  288.   }
  289. *** ../vim-5.6.86/src/version.c    Mon Jun  5 12:25:41 2000
  290. --- src/version.c    Mon Jun  5 13:04:55 2000
  291. ***************
  292. *** 420,421 ****
  293. --- 420,423 ----
  294.   {   /* Add new patch number below this line */
  295. + /**/
  296. +     87,
  297.   /**/
  298.  
  299. -- 
  300. CART DRIVER: Bring out your dead!
  301.    We follow the cart through a wretched, impoverished plague-ridden village.
  302.    A few starved mongrels run about in the mud scavenging.  In the open
  303.    doorway of one house perhaps we jug glimpse a pair of legs dangling from
  304.    the ceiling.  In another doorway an OLD WOMAN is beating a cat against a
  305.    wall rather like one does with a mat.  The cart passes round a dead donkey
  306.    or cow in the mud.  And a MAN tied to a cart is being hammered to death by
  307.    four NUNS with huge mallets.
  308.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  309.  
  310. /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\
  311. \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/
  312.