mirror of
https://github.com/rfivet/uemacs.git
synced 2025-01-29 03:26:23 -05:00
Accept UTF-8 sequence as keyboard input.
This commit is contained in:
parent
7da7916b28
commit
5401aec485
21
input.c
21
input.c
@ -21,6 +21,7 @@
|
|||||||
#include "exec.h"
|
#include "exec.h"
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include "utf8.h"
|
||||||
#include "wrapper.h"
|
#include "wrapper.h"
|
||||||
|
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
@ -454,6 +455,26 @@ handle_CSI:
|
|||||||
return CTLX | c;
|
return CTLX | c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( c <= 0xC1 || c > 0xF4)
|
||||||
|
return c ;
|
||||||
|
else {
|
||||||
|
char utf[ 4] ;
|
||||||
|
|
||||||
|
utf[ 0] = c ;
|
||||||
|
if( (c & 0xE0) == 0xC0)
|
||||||
|
utf[ 1] = get1key() ;
|
||||||
|
else if( (c & 0xF0) == 0xE0) {
|
||||||
|
utf[ 1] = get1key() ;
|
||||||
|
utf[ 2] = get1key() ;
|
||||||
|
} else if( (c & 0xF8) == 0xF0) {
|
||||||
|
utf[ 1] = get1key() ;
|
||||||
|
utf[ 2] = get1key() ;
|
||||||
|
utf[ 3] = get1key() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) &c) ;
|
||||||
|
}
|
||||||
|
|
||||||
/* otherwise, just return it */
|
/* otherwise, just return it */
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
2
utf8.c
2
utf8.c
@ -29,7 +29,7 @@ unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *re
|
|||||||
* 1100000x is start of overlong encoding sequence
|
* 1100000x is start of overlong encoding sequence
|
||||||
* Sequence longer than 4 bytes are invalid
|
* Sequence longer than 4 bytes are invalid
|
||||||
*/
|
*/
|
||||||
if( c <= 0xc0 || c > 0xF4 || c == 0xC1)
|
if( c <= 0xC1 || c > 0xF4)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Ok, it's 11xxxxxx, do a stupid decode */
|
/* Ok, it's 11xxxxxx, do a stupid decode */
|
||||||
|
Loading…
Reference in New Issue
Block a user