Compare commits

..

4 Commits

Author SHA1 Message Date
884ba56619 optimize rendering 2026-02-08 18:10:21 +09:00
9afad8e4ff add bench 2026-02-08 17:57:23 +09:00
64d50afc6b fix kouho selection. 2026-02-08 17:43:26 +09:00
b887972fb2 vietnamese telex input 2026-02-08 16:57:52 +09:00

26
vi.c
View File

@ -31,12 +31,24 @@ static struct {
{L'Y', {L'Ý', L'', L'', L'', L''}},
};
static int tonetab[128] = {
['s'] = 1, ['f'] = 2, ['r'] = 3, ['x'] = 4, ['j'] = 5,
};
static int
istone(Rune c)
{
return c == 's' || c == 'f' || c == 'r' || c == 'x' || c == 'j';
}
#define Istone(c) ((c) < 128 && tonetab[(c)] > 0)
#define Toneidx(c) (tonetab[(c)] - 1)
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;
}
static int
isvowel(Rune c)
@ -85,7 +97,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);
@ -139,7 +151,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;