Mercurial > vim
diff src/libvterm/src/unicode.c @ 18064:8b4f9be5db73 v8.1.2027
patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Commit: https://github.com/vim/vim/commit/57da69816872d53038e8a7e8dd4dc39a31192f0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 13 22:30:11 2019 +0200
patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Problem: MS-Windows: problem with ambiwidth characters.
Solution: handle ambiguous width characters in ConPTY on Windows 10 (1903).
(Nobuhiro Takasaki, closes #4411)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 13 Sep 2019 22:45:04 +0200 |
parents | 811a12a78164 |
children | 3be01cf0a632 |
line wrap: on
line diff
--- a/src/libvterm/src/unicode.c +++ b/src/libvterm/src/unicode.c @@ -68,12 +68,13 @@ * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c */ -#if !defined(IS_COMBINING_FUNCTION) || !defined(WCWIDTH_FUNCTION) struct interval { int first; int last; }; +#if !defined(WCWIDTH_FUNCTION) || !defined(IS_COMBINING_FUNCTION) + // sorted list of non-overlapping intervals of non-spacing characters // generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" // Replaced by the combining table from Vim. @@ -359,6 +360,7 @@ static const struct interval combining[] {0X1E944, 0X1E94A}, {0XE0100, 0XE01EF} }; +#endif // auxiliary function for binary search in interval table static int bisearch(uint32_t ucs, const struct interval *table, int max) { @@ -379,8 +381,6 @@ static int bisearch(uint32_t ucs, const return 0; } -#endif - /* The following two functions define the column width of an ISO 10646 * character as follows: @@ -478,6 +478,7 @@ static int mk_wcswidth(const uint32_t *p */ static int mk_wcwidth_cjk(uint32_t ucs) { +#endif /* sorted list of non-overlapping intervals of East Asian Ambiguous * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ static const struct interval ambiguous[] = { @@ -534,6 +535,7 @@ static int mk_wcwidth_cjk(uint32_t ucs) { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF }, { 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD } }; +#if 0 // binary search in table of non-spacing characters if (bisearch(ucs, ambiguous, @@ -557,6 +559,12 @@ static int mk_wcswidth_cjk(const uint32_ } #endif +INTERNAL int vterm_unicode_is_ambiguous(uint32_t codepoint) +{ + return (bisearch(codepoint, ambiguous, + sizeof(ambiguous) / sizeof(struct interval) - 1)) ? 1 : 0; +} + #ifdef IS_COMBINING_FUNCTION // Use a provided is_combining() function. int IS_COMBINING_FUNCTION(uint32_t codepoint); @@ -569,6 +577,17 @@ vterm_is_combining(uint32_t codepoint) } #endif +#ifdef GET_SPECIAL_PTY_TYPE_FUNCTION +int GET_SPECIAL_PTY_TYPE_FUNCTION(void); +#else +# define GET_SPECIAL_PTY_TYPE_FUNCTION vterm_get_special_pty_type_placeholder + static int +vterm_get_special_pty_type_placeholder(void) +{ + return 0; +} +#endif + // ################################ // ### The rest added by Paul Evans @@ -581,3 +600,8 @@ INTERNAL int vterm_unicode_is_combining( { return IS_COMBINING_FUNCTION(codepoint); } + +INTERNAL int vterm_get_special_pty_type(void) +{ + return GET_SPECIAL_PTY_TYPE_FUNCTION(); +}