diff options
Diffstat (limited to 'src/libvterm/src/unicode.c')
-rw-r--r-- | src/libvterm/src/unicode.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/libvterm/src/unicode.c b/src/libvterm/src/unicode.c index 33e5f41b8..7f93763aa 100644 --- 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 struct interval *table, int max) { 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 *pwcs, size_t n) */ 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_t *pwcs, size_t n) } #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(uint32_t codepoint) { return IS_COMBINING_FUNCTION(codepoint); } + +INTERNAL int vterm_get_special_pty_type(void) +{ + return GET_SPECIAL_PTY_TYPE_FUNCTION(); +} |