mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.0.0985: libvterm has its own idea of character width
Problem: Libvterm has its own idea of character width. Solution: Use the Vim functions for character width and composing to avoid a mismatch. (idea by Yasuhiro Matsumoto)
This commit is contained in:
@@ -971,7 +971,11 @@ $(OUTDIR)/terminal.o: terminal.c $(INCL) $(TERM_DEPS)
|
|||||||
$(CC) -c $(CFLAGS) terminal.c -o $(OUTDIR)/terminal.o
|
$(CC) -c $(CFLAGS) terminal.c -o $(OUTDIR)/terminal.o
|
||||||
|
|
||||||
|
|
||||||
CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf
|
CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" \
|
||||||
|
-DVSNPRINTF=vim_vsnprintf \
|
||||||
|
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
|
||||||
|
-DWCWIDTH_FUNCTION=utf_uint2cells
|
||||||
|
|
||||||
$(OUTDIR)/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
|
$(OUTDIR)/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
|
||||||
$(CCCTERM) libvterm/src/encoding.c -o $@
|
$(CCCTERM) libvterm/src/encoding.c -o $@
|
||||||
|
|
||||||
|
@@ -1474,7 +1474,12 @@ $(OUTDIR)/dimm_i.obj: $(OUTDIR) dimm_i.c $(INCL)
|
|||||||
$(OUTDIR)/glbl_ime.obj: $(OUTDIR) glbl_ime.cpp dimm.h $(INCL)
|
$(OUTDIR)/glbl_ime.obj: $(OUTDIR) glbl_ime.cpp dimm.h $(INCL)
|
||||||
|
|
||||||
|
|
||||||
CCCTERM = $(CC) $(CFLAGS) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf -D_CRT_SECURE_NO_WARNINGS
|
CCCTERM = $(CC) $(CFLAGS) -Ilibvterm/include -DINLINE="" \
|
||||||
|
-DVSNPRINTF=vim_vsnprintf \
|
||||||
|
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
|
||||||
|
-DWCWIDTH_FUNCTION=utf_uint2cells \
|
||||||
|
-D_CRT_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
$(OUTDIR)/term_encoding.obj: $(OUTDIR) libvterm/src/encoding.c $(TERM_DEPS)
|
$(OUTDIR)/term_encoding.obj: $(OUTDIR) libvterm/src/encoding.c $(TERM_DEPS)
|
||||||
$(CCCTERM) -Fo$@ libvterm/src/encoding.c
|
$(CCCTERM) -Fo$@ libvterm/src/encoding.c
|
||||||
|
|
||||||
|
@@ -3296,7 +3296,11 @@ objects/channel.o: channel.c
|
|||||||
Makefile:
|
Makefile:
|
||||||
@echo The name of the makefile MUST be "Makefile" (with capital M)!!!!
|
@echo The name of the makefile MUST be "Makefile" (with capital M)!!!!
|
||||||
|
|
||||||
CCCTERM = $(CCC) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf
|
CCCTERM = $(CCC) -Ilibvterm/include -DINLINE="" \
|
||||||
|
-DVSNPRINTF=vim_vsnprintf \
|
||||||
|
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
|
||||||
|
-DWCWIDTH_FUNCTION=utf_uint2cells
|
||||||
|
|
||||||
objects/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
|
objects/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
|
||||||
$(CCCTERM) -o $@ libvterm/src/encoding.c
|
$(CCCTERM) -o $@ libvterm/src/encoding.c
|
||||||
|
|
||||||
|
@@ -68,6 +68,7 @@
|
|||||||
* Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
|
* Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(IS_COMBINING_FUNCTION) || !defined(WCWIDTH_FUNCTION)
|
||||||
struct interval {
|
struct interval {
|
||||||
int first;
|
int first;
|
||||||
int last;
|
int last;
|
||||||
@@ -126,7 +127,6 @@ static const struct interval combining[] = {
|
|||||||
{ 0xE0100, 0xE01EF }
|
{ 0xE0100, 0xE01EF }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* auxiliary function for binary search in interval table */
|
/* auxiliary function for binary search in interval table */
|
||||||
static int bisearch(uint32_t ucs, const struct interval *table, int max) {
|
static int bisearch(uint32_t ucs, const struct interval *table, int max) {
|
||||||
int min = 0;
|
int min = 0;
|
||||||
@@ -146,6 +146,7 @@ static int bisearch(uint32_t ucs, const struct interval *table, int max) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* The following two functions define the column width of an ISO 10646
|
/* The following two functions define the column width of an ISO 10646
|
||||||
@@ -180,6 +181,11 @@ static int bisearch(uint32_t ucs, const struct interval *table, int max) {
|
|||||||
* in ISO 10646.
|
* in ISO 10646.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef WCWIDTH_FUNCTION
|
||||||
|
/* use a provided wcwidth() function */
|
||||||
|
int WCWIDTH_FUNCTION(uint32_t ucs);
|
||||||
|
#else
|
||||||
|
# define WCWIDTH_FUNCTION mk_wcwidth
|
||||||
|
|
||||||
static int mk_wcwidth(uint32_t ucs)
|
static int mk_wcwidth(uint32_t ucs)
|
||||||
{
|
{
|
||||||
@@ -211,6 +217,7 @@ static int mk_wcwidth(uint32_t ucs)
|
|||||||
(ucs >= 0x20000 && ucs <= 0x2fffd) ||
|
(ucs >= 0x20000 && ucs <= 0x2fffd) ||
|
||||||
(ucs >= 0x30000 && ucs <= 0x3fffd)));
|
(ucs >= 0x30000 && ucs <= 0x3fffd)));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0 /* unused */
|
#if 0 /* unused */
|
||||||
static int mk_wcswidth(const uint32_t *pwcs, size_t n)
|
static int mk_wcswidth(const uint32_t *pwcs, size_t n)
|
||||||
@@ -317,15 +324,28 @@ static int mk_wcswidth_cjk(const uint32_t *pwcs, size_t n)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef IS_COMBINING_FUNCTION
|
||||||
|
/* Use a provided is_combining() function. */
|
||||||
|
int IS_COMBINING_FUNCTION(uint32_t codepoint);
|
||||||
|
#else
|
||||||
|
# define IS_COMBINING_FUNCTION vterm_is_combining
|
||||||
|
static int
|
||||||
|
vterm_is_combining(uint32_t codepoint)
|
||||||
|
{
|
||||||
|
return bisearch(codepoint, combining, sizeof(combining) / sizeof(struct interval) - 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ################################
|
/* ################################
|
||||||
* ### The rest added by Paul Evans */
|
* ### The rest added by Paul Evans */
|
||||||
|
|
||||||
INTERNAL int vterm_unicode_width(uint32_t codepoint)
|
INTERNAL int vterm_unicode_width(uint32_t codepoint)
|
||||||
{
|
{
|
||||||
return mk_wcwidth(codepoint);
|
return WCWIDTH_FUNCTION(codepoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERNAL int vterm_unicode_is_combining(uint32_t codepoint)
|
INTERNAL int vterm_unicode_is_combining(uint32_t codepoint)
|
||||||
{
|
{
|
||||||
return bisearch(codepoint, combining, sizeof(combining) / sizeof(struct interval) - 1);
|
return IS_COMBINING_FUNCTION(codepoint);
|
||||||
}
|
}
|
||||||
|
22
src/mbyte.c
22
src/mbyte.c
@@ -1395,6 +1395,17 @@ static struct interval ambiguous[] =
|
|||||||
{0x100000, 0x10fffd}
|
{0x100000, 0x10fffd}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(FEAT_TERMINAL) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* utf_char2cells() with different argument type for libvterm.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
utf_uint2cells(uint32_t c)
|
||||||
|
{
|
||||||
|
return utf_char2cells((int)c);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For UTF-8 character "c" return 2 for a double-width character, 1 for others.
|
* For UTF-8 character "c" return 2 for a double-width character, 1 for others.
|
||||||
* Returns 4 or 6 for an unprintable character.
|
* Returns 4 or 6 for an unprintable character.
|
||||||
@@ -2296,6 +2307,17 @@ utf_char2bytes(int c, char_u *buf)
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(FEAT_TERMINAL) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* utf_iscomposing() with different argument type for libvterm.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
utf_iscomposing_uint(uint32_t c)
|
||||||
|
{
|
||||||
|
return utf_iscomposing((int)c);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return TRUE if "c" is a composing UTF-8 character. This means it will be
|
* Return TRUE if "c" is a composing UTF-8 character. This means it will be
|
||||||
* drawn on top of the preceding character.
|
* drawn on top of the preceding character.
|
||||||
|
@@ -10,6 +10,7 @@ int latin_char2len(int c);
|
|||||||
int latin_char2bytes(int c, char_u *buf);
|
int latin_char2bytes(int c, char_u *buf);
|
||||||
int latin_ptr2len(char_u *p);
|
int latin_ptr2len(char_u *p);
|
||||||
int latin_ptr2len_len(char_u *p, int size);
|
int latin_ptr2len_len(char_u *p, int size);
|
||||||
|
int utf_uint2cells(uint32_t c);
|
||||||
int utf_char2cells(int c);
|
int utf_char2cells(int c);
|
||||||
int latin_ptr2cells(char_u *p);
|
int latin_ptr2cells(char_u *p);
|
||||||
int utf_ptr2cells(char_u *p);
|
int utf_ptr2cells(char_u *p);
|
||||||
@@ -37,6 +38,7 @@ int utfc_ptr2len(char_u *p);
|
|||||||
int utfc_ptr2len_len(char_u *p, int size);
|
int utfc_ptr2len_len(char_u *p, int size);
|
||||||
int utf_char2len(int c);
|
int utf_char2len(int c);
|
||||||
int utf_char2bytes(int c, char_u *buf);
|
int utf_char2bytes(int c, char_u *buf);
|
||||||
|
int utf_iscomposing_uint(uint32_t c);
|
||||||
int utf_iscomposing(int c);
|
int utf_iscomposing(int c);
|
||||||
int utf_printable(int c);
|
int utf_printable(int c);
|
||||||
int utf_class(int c);
|
int utf_class(int c);
|
||||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
985,
|
||||||
/**/
|
/**/
|
||||||
984,
|
984,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user