1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-20 16:22:38 -05:00

Correct column position when displaying double width unicode character (assumed in range \u3000-\u3FFF).

This commit is contained in:
Renaud 2017-05-07 14:05:47 +08:00
parent 18cd0ba37f
commit 774475a4f6
3 changed files with 12 additions and 6 deletions

View File

@ -165,8 +165,7 @@ isearch.o: isearch.c isearch.h basic.h retcode.h buffer.h line.h utf8.h \
window.h
line.o: line.c line.h retcode.h utf8.h buffer.h estruct.h mlout.h \
window.h defines.h
lock.o: lock.c estruct.h lock.h defines.h display.h utf8.h input.h bind.h \
retcode.h pklock.h
lock.o: lock.c estruct.h lock.h
main.o: main.c estruct.h basic.h retcode.h bind.h bindable.h buffer.h \
line.h utf8.h display.h eval.h execute.h file.h lock.h mlout.h random.h \
search.h terminal.h defines.h termio.h version.h window.h
@ -176,7 +175,7 @@ names.o: names.c names.h basic.h retcode.h bind.h bindable.h buffer.h \
line.h utf8.h display.h estruct.h eval.h exec.h file.h isearch.h \
region.h random.h search.h spawn.h window.h defines.h word.h
pklock.o: pklock.c estruct.h pklock.h
posix.o: posix.c termio.h utf8.h estruct.h retcode.h
posix.o: posix.c
random.o: random.c random.h retcode.h basic.h buffer.h line.h utf8.h \
display.h estruct.h execute.h input.h bind.h search.h terminal.h \
defines.h window.h
@ -189,7 +188,7 @@ spawn.o: spawn.c spawn.h defines.h buffer.h line.h retcode.h utf8.h \
window.h
tcap.o: tcap.c terminal.h defines.h retcode.h utf8.h display.h estruct.h \
termio.h
termio.o: termio.c
termio.o: termio.c termio.h utf8.h estruct.h retcode.h
utf8.o: utf8.c utf8.h
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
basic.h display.h estruct.h execute.h terminal.h wrapper.h

View File

@ -588,6 +588,8 @@ void updpos(void)
curcol += 2 ; /* displayed as ^c */
else if( c >= 0x80 && c <= 0xA0)
curcol += 3 ; /* displayed as \xx */
else if( c >= 0x3000 && c <= 0x3FFF)
curcol += 2 ; /* double width unicode character */
else
curcol += 1 ;
}

9
utf8.c
View File

@ -20,10 +20,15 @@
unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *res)
{
unicode_t value ;
unsigned c = line[ index] & 0xFFU ;
unsigned c ;
unsigned bytes, mask, i;
*res = c;
assert( index < len) ;
#ifdef NDEBUG
if( index >= len)
return 0 ;
#endif
*res = c = line[ index] & 0xFFU ;
/*
* 0xxxxxxx is valid one byte utf8