Compare commits

..

4 Commits

Author SHA1 Message Date
129b842487 optimize rendering 2026-02-09 09:10:51 +09:00
b41cf78862 add bench 2026-02-09 09:10:51 +09:00
2cfee1d36c fix kouho selection. 2026-02-09 09:10:51 +09:00
b35b81ad3d vietnamese telex input 2026-02-09 09:10:44 +09:00

26
vi.c
View File

@ -31,24 +31,12 @@ static struct {
{L'Y', {L'Ý', L'', L'', L'', L''}},
};
static int
istone(Rune c)
{
return c == 's' || c == 'f' || c == 'r' || c == 'x' || c == 'j';
}
static int tonetab[128] = {
['s'] = 1, ['f'] = 2, ['r'] = 3, ['x'] = 4, ['j'] = 5,
};
static int
toneidx(Rune c)
{
switch(c){
case 's': return 0;
case 'f': return 1;
case 'r': return 2;
case 'x': return 3;
case 'j': return 4;
}
return -1;
}
#define Istone(c) ((c) < 128 && tonetab[(c)] > 0)
#define Toneidx(c) (tonetab[(c)] - 1)
static int
isvowel(Rune c)
@ -97,7 +85,7 @@ transvi(Im *im, Rune c)
int i, tidx, vi, last, penult;
Rune v, b1, b2;
if(!istone(c) && c != 'z')
if(!Istone(c) && c != 'z')
return transmap(im, c);
memset(&e, 0, sizeof e);
@ -151,7 +139,7 @@ transvi(Im *im, Rune c)
if(c == 'z')
mapped.r[vi] = removetone(mapped.r[vi]);
else{
tidx = toneidx(c);
tidx = Toneidx(c);
mapped.r[vi] = applytone(mapped.r[vi], tidx);
}
e.eat = 1;