mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 15:26:23 -05:00
Compare commits
2 Commits
3bce7a4751
...
79c3dfa4d9
Author | SHA1 | Date | |
---|---|---|---|
79c3dfa4d9 | |||
109e330861 |
6
basic.c
6
basic.c
@ -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 ;
|
||||
|
@ -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) ;
|
||||
|
3
random.c
3
random.c
@ -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
21
utf8.c
@ -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
3
utf8.h
@ -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) ;
|
||||
|
Loading…
Reference in New Issue
Block a user