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.1.455 < prev    next >
Encoding:
Internet Message Format  |  2003-04-09  |  11.5 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.455
  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.1.455
  11. Problem:    Some Unicode characters can be one or two character cells wide.
  12. Solution:   Add the 'ambiwidth' option to tell Vim how to display these
  13.         characters. (Jungshik Shin)
  14. Files:        runtime/doc/options.txt, src/mbyte.c, src/option.c, src/option.h
  15.  
  16.  
  17. *** ../vim61.454/runtime/doc/options.txt    Sat Mar  8 20:33:31 2003
  18. --- runtime/doc/options.txt    Thu Apr 10 10:14:51 2003
  19. ***************
  20. *** 1,4 ****
  21. ! *options.txt*   For Vim version 6.1.  Last change: 2003 Mar 08
  22.   
  23.   
  24.             VIM REFERENCE MANUAL    by Bram Moolenaar
  25. --- 1,4 ----
  26. ! *options.txt*   For Vim version 6.1.  Last change: 2003 Apr 10
  27.   
  28.   
  29.             VIM REFERENCE MANUAL    by Bram Moolenaar
  30. ***************
  31. *** 586,591 ****
  32. --- 594,630 ----
  33.       mode) and have default second language Farsi or Hebrew (right-to-left
  34.       mode).  See |farsi.txt|.
  35.   
  36. +                         *'ambiwidth'* *'ambw'*
  37. + 'ambiwidth' 'ambw'    string (default: "single")
  38. +             global
  39. +             {not in Vi}
  40. +             {only available when compiled with the |+multi_byte|
  41. +             feature}
  42. +     Only effective when 'encoding' is "utf-8" or another Unicode encoding.
  43. +     Tells Vim what to do with characters with East Asian Width Class
  44. +     Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek
  45. +     letters, Cyrillic letters).
  46. +     There are currently two possible values:
  47. +     "single":    Use the same width as characters in US-ASCII. This is
  48. +             expected by most users.
  49. +     "double":    Use twice the width of ASCII characters.
  50. +     There are a number of CJK fonts for which the width of glyphs for
  51. +     those characters are solely based on how many octets they take in 
  52. +     legacy/traditional CJK encodings.  In those encodings, Euro,
  53. +     Registered sign, Greek/Cyrillic letters are represented by two octets,
  54. +     therefore those fonts have "wide" glyphs for them. This is also
  55. +     true of some line drawing characters used to make tables in text
  56. +     file. Therefore, when a CJK font is used for GUI vim or
  57. +     vim is running inside a terminal (emulators) that uses a CJK font
  58. +     (or vim is run inside an xterm invoked with "-cjkwidth" option.),
  59. +     this option should be set to "double" to match the width perceived
  60. +     by Vim with the width of glyphs in the font.  Perhaps it also has 
  61. +     to be set to "double" under CJK Windows 9x/ME or Windows 2k/XP 
  62. +     when the system locale is set to one of CJK locales.  See Unicode 
  63. +     Standard Annex #11 (http://www.unicode.org/reports/tr11).
  64.               *'autochdir'* *'acd'* *'noatuochdir'* *'noacd'*
  65.   'autochdir' 'acd'    boolean (default off)
  66.               global
  67. *** ../vim61.454/src/mbyte.c    Thu Apr 10 22:38:13 2003
  68. --- src/mbyte.c    Wed Apr  9 21:04:22 2003
  69. ***************
  70. *** 898,912 ****
  71. --- 898,1008 ----
  72.       return len;
  73.   }
  74.   
  75. + struct interval
  76. + {
  77. +     unsigned short first;
  78. +     unsigned short last;
  79. + };
  80. + static int intable __ARGS((struct interval *table, size_t size, int c));
  81. + /*
  82. +  * Return TRUE if "c" is in "table[size / sizeof(struct interval)]".
  83. +  */
  84. +     static int
  85. + intable(table, size, c)
  86. +     struct interval    *table;
  87. +     size_t        size;
  88. +     int            c;
  89. + {
  90. +     int mid, bot, top;
  91. +     /* first quick check for Latin1 etc. characters */
  92. +     if (c < table[0].first)
  93. +     return FALSE;
  94. +     /* binary search in table */
  95. +     bot = 0;
  96. +     top = size / sizeof(struct interval) - 1;
  97. +     while (top >= bot)
  98. +     {
  99. +     mid = (bot + top) / 2;
  100. +     if (table[mid].last < c)
  101. +         bot = mid + 1;
  102. +     else if (table[mid].first > c)
  103. +         top = mid - 1;
  104. +     else
  105. +         return TRUE;
  106. +     }
  107. +     return FALSE;
  108. + }
  109.   /*
  110.    * For UTF-8 character "c" return 2 for a double-width character, 1 for others.
  111.    * Returns 4 or 6 for an unprintable character.
  112.    * Is only correct for characters >= 0x80.
  113. +  * When p_ambw is "double", return 2 for a character with East Asian Width
  114. +  * class 'A'(mbiguous).
  115.    */
  116.       int
  117.   utf_char2cells(c)
  118.       int        c;
  119.   {
  120. +     /* sorted list of non-overlapping intervals of East Asian Ambiguous
  121. +      * characters, generated with "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
  122. +     static struct interval ambiguous[] = {
  123. +     {0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8},
  124. +     {0x00AA, 0x00AA}, {0x00AD, 0x00AE}, {0x00B0, 0x00B4},
  125. +     {0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6},
  126. +     {0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1},
  127. +     {0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED},
  128. +     {0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA},
  129. +     {0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101},
  130. +     {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B},
  131. +     {0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133},
  132. +     {0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144},
  133. +     {0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153},
  134. +     {0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE},
  135. +     {0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4},
  136. +     {0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA},
  137. +     {0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261},
  138. +     {0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB},
  139. +     {0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB},
  140. +     {0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0391, 0x03A1},
  141. +     {0x03A3, 0x03A9}, {0x03B1, 0x03C1}, {0x03C3, 0x03C9},
  142. +     {0x0401, 0x0401}, {0x0410, 0x044F}, {0x0451, 0x0451},
  143. +     {0x2010, 0x2010}, {0x2013, 0x2016}, {0x2018, 0x2019},
  144. +     {0x201C, 0x201D}, {0x2020, 0x2022}, {0x2024, 0x2027},
  145. +     {0x2030, 0x2030}, {0x2032, 0x2033}, {0x2035, 0x2035},
  146. +     {0x203B, 0x203B}, {0x203E, 0x203E}, {0x2074, 0x2074},
  147. +     {0x207F, 0x207F}, {0x2081, 0x2084}, {0x20AC, 0x20AC},
  148. +     {0x2103, 0x2103}, {0x2105, 0x2105}, {0x2109, 0x2109},
  149. +     {0x2113, 0x2113}, {0x2116, 0x2116}, {0x2121, 0x2122},
  150. +     {0x2126, 0x2126}, {0x212B, 0x212B}, {0x2153, 0x2154},
  151. +     {0x215B, 0x215E}, {0x2160, 0x216B}, {0x2170, 0x2179},
  152. +     {0x2190, 0x2199}, {0x21B8, 0x21B9}, {0x21D2, 0x21D2},
  153. +     {0x21D4, 0x21D4}, {0x21E7, 0x21E7}, {0x2200, 0x2200},
  154. +     {0x2202, 0x2203}, {0x2207, 0x2208}, {0x220B, 0x220B},
  155. +     {0x220F, 0x220F}, {0x2211, 0x2211}, {0x2215, 0x2215},
  156. +     {0x221A, 0x221A}, {0x221D, 0x2220}, {0x2223, 0x2223},
  157. +     {0x2225, 0x2225}, {0x2227, 0x222C}, {0x222E, 0x222E},
  158. +     {0x2234, 0x2237}, {0x223C, 0x223D}, {0x2248, 0x2248},
  159. +     {0x224C, 0x224C}, {0x2252, 0x2252}, {0x2260, 0x2261},
  160. +     {0x2264, 0x2267}, {0x226A, 0x226B}, {0x226E, 0x226F},
  161. +     {0x2282, 0x2283}, {0x2286, 0x2287}, {0x2295, 0x2295},
  162. +     {0x2299, 0x2299}, {0x22A5, 0x22A5}, {0x22BF, 0x22BF},
  163. +     {0x2312, 0x2312}, {0x2460, 0x24E9}, {0x24EB, 0x24FE},
  164. +     {0x2500, 0x254B}, {0x2550, 0x2573}, {0x2580, 0x258F},
  165. +     {0x2592, 0x2595}, {0x25A0, 0x25A1}, {0x25A3, 0x25A9},
  166. +     {0x25B2, 0x25B3}, {0x25B6, 0x25B7}, {0x25BC, 0x25BD},
  167. +     {0x25C0, 0x25C1}, {0x25C6, 0x25C8}, {0x25CB, 0x25CB},
  168. +     {0x25CE, 0x25D1}, {0x25E2, 0x25E5}, {0x25EF, 0x25EF},
  169. +     {0x2605, 0x2606}, {0x2609, 0x2609}, {0x260E, 0x260F},
  170. +     {0x261C, 0x261C}, {0x261E, 0x261E}, {0x2640, 0x2640},
  171. +     {0x2642, 0x2642}, {0x2660, 0x2661}, {0x2663, 0x2665},
  172. +     {0x2667, 0x266A}, {0x266C, 0x266D}, {0x266F, 0x266F},
  173. +     {0x273D, 0x273D}, {0x2776, 0x277F}, {0xFFFD, 0xFFFD}
  174. +     };
  175.       if (c >= 0x100)
  176.       {
  177.       if (!utf_printable(c))
  178. ***************
  179. *** 931,936 ****
  180. --- 1027,1035 ----
  181.       else if (c >= 0x80 && !vim_isprintc(c))
  182.       return 4;        /* unprintable, displays <xx> */
  183.   
  184. +     if (c >= 0x80 && *p_ambw == 'd' && intable(ambiguous, sizeof(ambiguous), c))
  185. +     return 2;
  186.       return 1;
  187.   }
  188.   
  189. ***************
  190. *** 1385,1428 ****
  191.       return 6;
  192.   }
  193.   
  194. - struct interval
  195. - {
  196. -     unsigned short first;
  197. -     unsigned short last;
  198. - };
  199. - static int intable __ARGS((struct interval *table, int size, int c));
  200. - /*
  201. -  * Return TRUE if "c" is in "table[size]".
  202. -  */
  203. -     static int
  204. - intable(table, size, c)
  205. -     struct interval    *table;
  206. -     int            size;
  207. -     int            c;
  208. - {
  209. -     int mid, bot, top;
  210. -     /* first quick check for Latin1 etc. characters */
  211. -     if (c < table[0].first)
  212. -     return FALSE;
  213. -     /* binary search in table */
  214. -     bot = 0;
  215. -     top = size - 1;
  216. -     while (top >= bot)
  217. -     {
  218. -     mid = (bot + top) / 2;
  219. -     if (table[mid].last < c)
  220. -         bot = mid + 1;
  221. -     else if (table[mid].first > c)
  222. -         top = mid - 1;
  223. -     else
  224. -         return TRUE;
  225. -     }
  226. -     return FALSE;
  227. - }
  228.   /*
  229.    * Return TRUE if "c" is a composing UTF-8 character.  This means it will be
  230.    * drawn on top of the preceding character.
  231. --- 1484,1489 ----
  232. ***************
  233. *** 1463,1469 ****
  234.       {0xFB1E, 0xFB1E}, {0xFE00, 0xFE0F}, {0xFE20, 0xFE23}
  235.       };
  236.   
  237. !     return intable(combining, sizeof(combining) / sizeof(struct interval), c);
  238.   }
  239.   
  240.   /*
  241. --- 1524,1530 ----
  242.       {0xFB1E, 0xFB1E}, {0xFE00, 0xFE0F}, {0xFE20, 0xFE23}
  243.       };
  244.   
  245. !     return intable(combining, sizeof(combining), c);
  246.   }
  247.   
  248.   /*
  249. ***************
  250. *** 1483,1489 ****
  251.       {0xfffe, 0xffff}
  252.       };
  253.   
  254. !     return !intable(nonprint, sizeof(nonprint) / sizeof(struct interval), c);
  255.   }
  256.   
  257.   /*
  258. --- 1544,1550 ----
  259.       {0xfffe, 0xffff}
  260.       };
  261.   
  262. !     return !intable(nonprint, sizeof(nonprint), c);
  263.   }
  264.   
  265.   /*
  266. *** ../vim61.454/src/option.c    Wed Mar 26 21:48:04 2003
  267. --- src/option.c    Wed Apr  9 20:48:41 2003
  268. ***************
  269. *** 327,332 ****
  270. --- 327,341 ----
  271.                   (char_u *)NULL, PV_NONE,
  272.   #endif
  273.                   {(char_u *)FALSE, (char_u *)0L}},
  274. +     {"ambiwidth",  "ambw",  P_STRING|P_VI_DEF|P_RCLR,
  275. + #if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
  276. +                 (char_u *)&p_ambw, PV_NONE,
  277. +                 {(char_u *)"single", (char_u *)0L}
  278. + #else
  279. +                 (char_u *)NULL, PV_NONE,
  280. +                 {(char_u *)0L, (char_u *)0L}
  281. + #endif
  282. +                 },
  283.   #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)
  284.       {"autochdir",  "acd",   P_BOOL|P_VI_DEF,
  285.                   (char_u *)&p_acd, PV_NONE,
  286. ***************
  287. *** 2292,2297 ****
  288. --- 2301,2309 ----
  289.   
  290.   #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
  291.   
  292. + #ifdef FEAT_MBYTE
  293. + static char *(p_ambw_values[]) = {"single", "double", NULL};
  294. + #endif
  295.   static char *(p_bg_values[]) = {"light", "dark", NULL};
  296.   static char *(p_bkc_values[]) = {"yes", "auto", "no", NULL};
  297.   static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
  298. ***************
  299. *** 2741,2746 ****
  300. --- 2753,2763 ----
  301.                                   *(int *)varp;
  302.       }
  303.       }
  304. + #ifdef FEAT_EVAL
  305. +     /* Remember where the option was set. */
  306. +     options[opt_idx].scriptID = current_SID;
  307. + #endif
  308.   }
  309.   
  310.   /*
  311. ***************
  312. *** 4479,4484 ****
  313. --- 4496,4510 ----
  314.       }
  315.   #endif
  316.   
  317. +     /* 'ambiwidth' */
  318. + #ifdef FEAT_MBYTE
  319. +     else if (varp == &p_ambw)
  320. +     {
  321. +     if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
  322. +         errmsg = e_invarg;
  323. +     }
  324. + #endif
  325.       /* 'background' */
  326.       else if (varp == &p_bg)
  327.       {
  328. *** ../vim61.454/src/option.h    Sat Mar  8 20:33:32 2003
  329. --- src/option.h    Wed Apr  9 21:05:54 2003
  330. ***************
  331. *** 284,289 ****
  332. --- 284,292 ----
  333.   #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)
  334.   EXTERN int    p_acd;        /* 'autochdir' */
  335.   #endif
  336. + #ifdef FEAT_MBYTE
  337. + EXTERN char_u    *p_ambw;    /* 'ambiwidth' */
  338. + #endif
  339.   EXTERN int    p_ar;        /* 'autoread' */
  340.   EXTERN int    p_aw;        /* 'autowrite' */
  341.   EXTERN int    p_awa;        /* 'autowriteall' */
  342. *** ../vim61.454/src/version.c    Thu Apr 10 22:38:13 2003
  343. --- src/version.c    Thu Apr 10 22:56:56 2003
  344. ***************
  345. *** 613,614 ****
  346. --- 613,616 ----
  347.   {   /* Add new patch number below this line */
  348. + /**/
  349. +     455,
  350.   /**/
  351.  
  352. -- 
  353. If corn oil comes from corn, where does baby oil come from?
  354.  
  355.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  356. ///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
  357. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  358.  \\\     Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
  359.