home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 6.1.455
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- Mime-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- ------------
-
- Patch 6.1.455
- Problem: Some Unicode characters can be one or two character cells wide.
- Solution: Add the 'ambiwidth' option to tell Vim how to display these
- characters. (Jungshik Shin)
- Files: runtime/doc/options.txt, src/mbyte.c, src/option.c, src/option.h
-
-
- *** ../vim61.454/runtime/doc/options.txt Sat Mar 8 20:33:31 2003
- --- runtime/doc/options.txt Thu Apr 10 10:14:51 2003
- ***************
- *** 1,4 ****
- ! *options.txt* For Vim version 6.1. Last change: 2003 Mar 08
-
-
- VIM REFERENCE MANUAL by Bram Moolenaar
- --- 1,4 ----
- ! *options.txt* For Vim version 6.1. Last change: 2003 Apr 10
-
-
- VIM REFERENCE MANUAL by Bram Moolenaar
- ***************
- *** 586,591 ****
- --- 594,630 ----
- mode) and have default second language Farsi or Hebrew (right-to-left
- mode). See |farsi.txt|.
-
- + *'ambiwidth'* *'ambw'*
- + 'ambiwidth' 'ambw' string (default: "single")
- + global
- + {not in Vi}
- + {only available when compiled with the |+multi_byte|
- + feature}
- + Only effective when 'encoding' is "utf-8" or another Unicode encoding.
- + Tells Vim what to do with characters with East Asian Width Class
- + Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek
- + letters, Cyrillic letters).
- +
- + There are currently two possible values:
- + "single": Use the same width as characters in US-ASCII. This is
- + expected by most users.
- + "double": Use twice the width of ASCII characters.
- +
- + There are a number of CJK fonts for which the width of glyphs for
- + those characters are solely based on how many octets they take in
- + legacy/traditional CJK encodings. In those encodings, Euro,
- + Registered sign, Greek/Cyrillic letters are represented by two octets,
- + therefore those fonts have "wide" glyphs for them. This is also
- + true of some line drawing characters used to make tables in text
- + file. Therefore, when a CJK font is used for GUI vim or
- + vim is running inside a terminal (emulators) that uses a CJK font
- + (or vim is run inside an xterm invoked with "-cjkwidth" option.),
- + this option should be set to "double" to match the width perceived
- + by Vim with the width of glyphs in the font. Perhaps it also has
- + to be set to "double" under CJK Windows 9x/ME or Windows 2k/XP
- + when the system locale is set to one of CJK locales. See Unicode
- + Standard Annex #11 (http://www.unicode.org/reports/tr11).
- +
- *'autochdir'* *'acd'* *'noatuochdir'* *'noacd'*
- 'autochdir' 'acd' boolean (default off)
- global
- *** ../vim61.454/src/mbyte.c Thu Apr 10 22:38:13 2003
- --- src/mbyte.c Wed Apr 9 21:04:22 2003
- ***************
- *** 898,912 ****
- --- 898,1008 ----
- return len;
- }
-
- + struct interval
- + {
- + unsigned short first;
- + unsigned short last;
- + };
- + static int intable __ARGS((struct interval *table, size_t size, int c));
- +
- + /*
- + * Return TRUE if "c" is in "table[size / sizeof(struct interval)]".
- + */
- + static int
- + intable(table, size, c)
- + struct interval *table;
- + size_t size;
- + int c;
- + {
- + int mid, bot, top;
- +
- + /* first quick check for Latin1 etc. characters */
- + if (c < table[0].first)
- + return FALSE;
- +
- + /* binary search in table */
- + bot = 0;
- + top = size / sizeof(struct interval) - 1;
- + while (top >= bot)
- + {
- + mid = (bot + top) / 2;
- + if (table[mid].last < c)
- + bot = mid + 1;
- + else if (table[mid].first > c)
- + top = mid - 1;
- + else
- + return TRUE;
- + }
- + return FALSE;
- + }
- +
- /*
- * For UTF-8 character "c" return 2 for a double-width character, 1 for others.
- * Returns 4 or 6 for an unprintable character.
- * Is only correct for characters >= 0x80.
- + * When p_ambw is "double", return 2 for a character with East Asian Width
- + * class 'A'(mbiguous).
- */
- int
- utf_char2cells(c)
- int c;
- {
- + /* sorted list of non-overlapping intervals of East Asian Ambiguous
- + * characters, generated with "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
- + static struct interval ambiguous[] = {
- + {0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8},
- + {0x00AA, 0x00AA}, {0x00AD, 0x00AE}, {0x00B0, 0x00B4},
- + {0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6},
- + {0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1},
- + {0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED},
- + {0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA},
- + {0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101},
- + {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B},
- + {0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133},
- + {0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144},
- + {0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153},
- + {0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE},
- + {0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4},
- + {0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA},
- + {0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261},
- + {0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB},
- + {0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB},
- + {0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0391, 0x03A1},
- + {0x03A3, 0x03A9}, {0x03B1, 0x03C1}, {0x03C3, 0x03C9},
- + {0x0401, 0x0401}, {0x0410, 0x044F}, {0x0451, 0x0451},
- + {0x2010, 0x2010}, {0x2013, 0x2016}, {0x2018, 0x2019},
- + {0x201C, 0x201D}, {0x2020, 0x2022}, {0x2024, 0x2027},
- + {0x2030, 0x2030}, {0x2032, 0x2033}, {0x2035, 0x2035},
- + {0x203B, 0x203B}, {0x203E, 0x203E}, {0x2074, 0x2074},
- + {0x207F, 0x207F}, {0x2081, 0x2084}, {0x20AC, 0x20AC},
- + {0x2103, 0x2103}, {0x2105, 0x2105}, {0x2109, 0x2109},
- + {0x2113, 0x2113}, {0x2116, 0x2116}, {0x2121, 0x2122},
- + {0x2126, 0x2126}, {0x212B, 0x212B}, {0x2153, 0x2154},
- + {0x215B, 0x215E}, {0x2160, 0x216B}, {0x2170, 0x2179},
- + {0x2190, 0x2199}, {0x21B8, 0x21B9}, {0x21D2, 0x21D2},
- + {0x21D4, 0x21D4}, {0x21E7, 0x21E7}, {0x2200, 0x2200},
- + {0x2202, 0x2203}, {0x2207, 0x2208}, {0x220B, 0x220B},
- + {0x220F, 0x220F}, {0x2211, 0x2211}, {0x2215, 0x2215},
- + {0x221A, 0x221A}, {0x221D, 0x2220}, {0x2223, 0x2223},
- + {0x2225, 0x2225}, {0x2227, 0x222C}, {0x222E, 0x222E},
- + {0x2234, 0x2237}, {0x223C, 0x223D}, {0x2248, 0x2248},
- + {0x224C, 0x224C}, {0x2252, 0x2252}, {0x2260, 0x2261},
- + {0x2264, 0x2267}, {0x226A, 0x226B}, {0x226E, 0x226F},
- + {0x2282, 0x2283}, {0x2286, 0x2287}, {0x2295, 0x2295},
- + {0x2299, 0x2299}, {0x22A5, 0x22A5}, {0x22BF, 0x22BF},
- + {0x2312, 0x2312}, {0x2460, 0x24E9}, {0x24EB, 0x24FE},
- + {0x2500, 0x254B}, {0x2550, 0x2573}, {0x2580, 0x258F},
- + {0x2592, 0x2595}, {0x25A0, 0x25A1}, {0x25A3, 0x25A9},
- + {0x25B2, 0x25B3}, {0x25B6, 0x25B7}, {0x25BC, 0x25BD},
- + {0x25C0, 0x25C1}, {0x25C6, 0x25C8}, {0x25CB, 0x25CB},
- + {0x25CE, 0x25D1}, {0x25E2, 0x25E5}, {0x25EF, 0x25EF},
- + {0x2605, 0x2606}, {0x2609, 0x2609}, {0x260E, 0x260F},
- + {0x261C, 0x261C}, {0x261E, 0x261E}, {0x2640, 0x2640},
- + {0x2642, 0x2642}, {0x2660, 0x2661}, {0x2663, 0x2665},
- + {0x2667, 0x266A}, {0x266C, 0x266D}, {0x266F, 0x266F},
- + {0x273D, 0x273D}, {0x2776, 0x277F}, {0xFFFD, 0xFFFD}
- + };
- +
- if (c >= 0x100)
- {
- if (!utf_printable(c))
- ***************
- *** 931,936 ****
- --- 1027,1035 ----
- else if (c >= 0x80 && !vim_isprintc(c))
- return 4; /* unprintable, displays <xx> */
-
- + if (c >= 0x80 && *p_ambw == 'd' && intable(ambiguous, sizeof(ambiguous), c))
- + return 2;
- +
- return 1;
- }
-
- ***************
- *** 1385,1428 ****
- return 6;
- }
-
- - struct interval
- - {
- - unsigned short first;
- - unsigned short last;
- - };
- - static int intable __ARGS((struct interval *table, int size, int c));
- -
- - /*
- - * Return TRUE if "c" is in "table[size]".
- - */
- - static int
- - intable(table, size, c)
- - struct interval *table;
- - int size;
- - int c;
- - {
- - int mid, bot, top;
- -
- - /* first quick check for Latin1 etc. characters */
- - if (c < table[0].first)
- - return FALSE;
- -
- - /* binary search in table */
- - bot = 0;
- - top = size - 1;
- - while (top >= bot)
- - {
- - mid = (bot + top) / 2;
- - if (table[mid].last < c)
- - bot = mid + 1;
- - else if (table[mid].first > c)
- - top = mid - 1;
- - else
- - return TRUE;
- - }
- - return FALSE;
- - }
- -
- /*
- * Return TRUE if "c" is a composing UTF-8 character. This means it will be
- * drawn on top of the preceding character.
- --- 1484,1489 ----
- ***************
- *** 1463,1469 ****
- {0xFB1E, 0xFB1E}, {0xFE00, 0xFE0F}, {0xFE20, 0xFE23}
- };
-
- ! return intable(combining, sizeof(combining) / sizeof(struct interval), c);
- }
-
- /*
- --- 1524,1530 ----
- {0xFB1E, 0xFB1E}, {0xFE00, 0xFE0F}, {0xFE20, 0xFE23}
- };
-
- ! return intable(combining, sizeof(combining), c);
- }
-
- /*
- ***************
- *** 1483,1489 ****
- {0xfffe, 0xffff}
- };
-
- ! return !intable(nonprint, sizeof(nonprint) / sizeof(struct interval), c);
- }
-
- /*
- --- 1544,1550 ----
- {0xfffe, 0xffff}
- };
-
- ! return !intable(nonprint, sizeof(nonprint), c);
- }
-
- /*
- *** ../vim61.454/src/option.c Wed Mar 26 21:48:04 2003
- --- src/option.c Wed Apr 9 20:48:41 2003
- ***************
- *** 327,332 ****
- --- 327,341 ----
- (char_u *)NULL, PV_NONE,
- #endif
- {(char_u *)FALSE, (char_u *)0L}},
- + {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
- + #if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
- + (char_u *)&p_ambw, PV_NONE,
- + {(char_u *)"single", (char_u *)0L}
- + #else
- + (char_u *)NULL, PV_NONE,
- + {(char_u *)0L, (char_u *)0L}
- + #endif
- + },
- #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)
- {"autochdir", "acd", P_BOOL|P_VI_DEF,
- (char_u *)&p_acd, PV_NONE,
- ***************
- *** 2292,2297 ****
- --- 2301,2309 ----
-
- #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
-
- + #ifdef FEAT_MBYTE
- + static char *(p_ambw_values[]) = {"single", "double", NULL};
- + #endif
- static char *(p_bg_values[]) = {"light", "dark", NULL};
- static char *(p_bkc_values[]) = {"yes", "auto", "no", NULL};
- static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
- ***************
- *** 2741,2746 ****
- --- 2753,2763 ----
- *(int *)varp;
- }
- }
- +
- + #ifdef FEAT_EVAL
- + /* Remember where the option was set. */
- + options[opt_idx].scriptID = current_SID;
- + #endif
- }
-
- /*
- ***************
- *** 4479,4484 ****
- --- 4496,4510 ----
- }
- #endif
-
- + /* 'ambiwidth' */
- + #ifdef FEAT_MBYTE
- + else if (varp == &p_ambw)
- + {
- + if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
- + errmsg = e_invarg;
- + }
- + #endif
- +
- /* 'background' */
- else if (varp == &p_bg)
- {
- *** ../vim61.454/src/option.h Sat Mar 8 20:33:32 2003
- --- src/option.h Wed Apr 9 21:05:54 2003
- ***************
- *** 284,289 ****
- --- 284,292 ----
- #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_SUN_WORKSHOP)
- EXTERN int p_acd; /* 'autochdir' */
- #endif
- + #ifdef FEAT_MBYTE
- + EXTERN char_u *p_ambw; /* 'ambiwidth' */
- + #endif
- EXTERN int p_ar; /* 'autoread' */
- EXTERN int p_aw; /* 'autowrite' */
- EXTERN int p_awa; /* 'autowriteall' */
- *** ../vim61.454/src/version.c Thu Apr 10 22:38:13 2003
- --- src/version.c Thu Apr 10 22:56:56 2003
- ***************
- *** 613,614 ****
- --- 613,616 ----
- { /* Add new patch number below this line */
- + /**/
- + 455,
- /**/
-
- --
- If corn oil comes from corn, where does baby oil come from?
-
- /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
- /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
- \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
- \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
-