1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 15:26:23 -05:00

Compare commits

...

2 Commits

6 changed files with 659 additions and 735 deletions

View File

@ -44,10 +44,8 @@ static unsigned getgoal( line_p dlp) {
col += 2 ;
else if( c >= 0x80 && c <= 0xA0) /* \xx */
col += 3 ;
else {
int w = utf8_width( c) ; /* work around */
col += (w < 0) ? 2 : w ; /* unknown unicode width as \u */
}
else
col += utf8_width( c) ;
if( col > curgoal)
break ;

1333
display.c

File diff suppressed because it is too large Load Diff

View File

@ -21,11 +21,7 @@ BINDABLE( upscreen) ;
void vtinit( void) ;
void vtfree( void) ;
void vttidy( void) ;
int update( boolean force_f) ;
void updpos( void) ;
void upddex( void) ;
void updgar( void) ;
int updupd( int force) ;
boolean update( boolean force_f) ;
void upmode( void) ;
void movecursor( int row, int col) ;
void mlerase( void) ;

View File

@ -164,8 +164,7 @@ int getccol( int bflg) {
else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */
col += 3 ;
else {
int w = utf8_width( c) ; /* incomplete wc_width */
col += (w < 0) ? 2 : w ;
col += utf8_width( c) ;
}
}

21
utf8.c
View File

@ -7,10 +7,9 @@
#include <assert.h>
#include <wchar.h>
/*
* Display width of UTF-8 character
*/
int utf8_width( unicode_t c) {
/* Display width of UTF-8 character */
int _utf8_width( unicode_t c) {
#if CYGWIN
assert( sizeof( wchar_t) == 2) ; /* wcwidth only supports UTF-16 */
return (c < 0x10000) ? wcwidth( (wchar_t) c) : -1 ;
@ -19,8 +18,14 @@ int utf8_width( unicode_t c) {
#endif
}
/*
* utf8_to_unicode()
int utf8_width( unicode_t c) {
int w = _utf8_width( c) ;
return (w < 0) ? 2 : w ; /* display \u if can't figure out width */
}
/* utf8_to_unicode()
*
* Convert a UTF-8 sequence to its unicode value, and return the length of
* the sequence in bytes.
@ -84,8 +89,8 @@ unsigned utf8_to_unicode( const char *line, unsigned index, unsigned len,
return bytes;
}
/*
* unicode_to_utf8()
/* unicode_to_utf8()
*
* Convert a unicode value to its canonical utf-8 sequence.
*

3
utf8.h
View File

@ -4,7 +4,8 @@
typedef unsigned int unicode_t ;
int utf8_width( unicode_t c) ;
int _utf8_width( unicode_t c) ; /* straight width */
int utf8_width( unicode_t c) ; /* workaround width */
unsigned utf8_to_unicode( const char *line, unsigned index, unsigned len,
unicode_t *res) ;
unsigned utf8_revdelta( unsigned char *buf, unsigned pos) ;