mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-24 01:56:26 -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 ;
|
col += 2 ;
|
||||||
else if( c >= 0x80 && c <= 0xA0) /* \xx */
|
else if( c >= 0x80 && c <= 0xA0) /* \xx */
|
||||||
col += 3 ;
|
col += 3 ;
|
||||||
else {
|
else
|
||||||
int w = utf8_width( c) ; /* work around */
|
col += utf8_width( c) ;
|
||||||
col += (w < 0) ? 2 : w ; /* unknown unicode width as \u */
|
|
||||||
}
|
|
||||||
|
|
||||||
if( col > curgoal)
|
if( col > curgoal)
|
||||||
break ;
|
break ;
|
||||||
|
@ -21,11 +21,7 @@ BINDABLE( upscreen) ;
|
|||||||
void vtinit( void) ;
|
void vtinit( void) ;
|
||||||
void vtfree( void) ;
|
void vtfree( void) ;
|
||||||
void vttidy( void) ;
|
void vttidy( void) ;
|
||||||
int update( boolean force_f) ;
|
boolean update( boolean force_f) ;
|
||||||
void updpos( void) ;
|
|
||||||
void upddex( void) ;
|
|
||||||
void updgar( void) ;
|
|
||||||
int updupd( int force) ;
|
|
||||||
void upmode( void) ;
|
void upmode( void) ;
|
||||||
void movecursor( int row, int col) ;
|
void movecursor( int row, int col) ;
|
||||||
void mlerase( void) ;
|
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 */
|
else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */
|
||||||
col += 3 ;
|
col += 3 ;
|
||||||
else {
|
else {
|
||||||
int w = utf8_width( c) ; /* incomplete wc_width */
|
col += utf8_width( c) ;
|
||||||
col += (w < 0) ? 2 : w ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
utf8.c
21
utf8.c
@ -7,10 +7,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Display width of UTF-8 character
|
/* Display width of UTF-8 character */
|
||||||
*/
|
int _utf8_width( unicode_t c) {
|
||||||
int utf8_width( unicode_t c) {
|
|
||||||
#if CYGWIN
|
#if CYGWIN
|
||||||
assert( sizeof( wchar_t) == 2) ; /* wcwidth only supports UTF-16 */
|
assert( sizeof( wchar_t) == 2) ; /* wcwidth only supports UTF-16 */
|
||||||
return (c < 0x10000) ? wcwidth( (wchar_t) c) : -1 ;
|
return (c < 0x10000) ? wcwidth( (wchar_t) c) : -1 ;
|
||||||
@ -19,8 +18,14 @@ int utf8_width( unicode_t c) {
|
|||||||
#endif
|
#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
|
* Convert a UTF-8 sequence to its unicode value, and return the length of
|
||||||
* the sequence in bytes.
|
* the sequence in bytes.
|
||||||
@ -84,8 +89,8 @@ unsigned utf8_to_unicode( const char *line, unsigned index, unsigned len,
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* unicode_to_utf8()
|
/* unicode_to_utf8()
|
||||||
*
|
*
|
||||||
* Convert a unicode value to its canonical utf-8 sequence.
|
* 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 ;
|
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,
|
unsigned utf8_to_unicode( const char *line, unsigned index, unsigned len,
|
||||||
unicode_t *res) ;
|
unicode_t *res) ;
|
||||||
unsigned utf8_revdelta( unsigned char *buf, unsigned pos) ;
|
unsigned utf8_revdelta( unsigned char *buf, unsigned pos) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user