remove jp.c

This commit is contained in:
Hojun-Cho 2025-12-28 13:02:53 +09:00
parent e5ce5fd61e
commit 436a49c3ca
4 changed files with 4 additions and 92 deletions

1
dat.h
View File

@ -79,7 +79,6 @@ struct Lang
char *dictname;
Hmap *map;
Hmap *dict;
Emit (*trans)(Im*, Rune);
};
struct Im

1
fn.h
View File

@ -23,7 +23,6 @@ void dictthread(void*);
void drawthread(void*);
void imthread(void*);
Emit trans(Im*, Rune);
Emit jptrans(Im*, Rune);
void srvthread(void*);

80
jp.c
View File

@ -1,80 +0,0 @@
#include "dat.h"
#include "fn.h"
Emit
jptrans(Im *im, Rune c)
{
Emit e;
Str key, kana;
Hmap *h;
Rune last;
int hira;
memset(&e, 0, sizeof(e));
h = im->l->map;
hira = (im->l->lang == LangJP);
key = im->pre;
sputr(&key, c);
if(hmapget(h, &key)){
e.eat = 1;
e.next = key;
mapget(h, &key, &e.dict);
return e;
}
last = slastr(&im->pre);
if(last == 0)
goto flush;
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
sclear(&key);
sputr(&key, last);
sputr(&key, c);
if(hmapget(h, &key)){
e.eat = 1;
e.s = kana;
sputr(&e.next, last);
sputr(&e.next, c);
mapget(h, &e.next, &e.dict);
return e;
}
}
if(c == 'n' && last == 'n'){
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
e.eat = 1;
e.s = kana;
sputr(&e.s, hira ? 0x3093 : 0x30F3);
sputr(&e.next, c);
mapget(h, &e.next, &e.dict);
return e;
}
}
if(c == last && strchr("kgsztdbpmjfchryw", c)){
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
e.eat = 1;
e.s = kana;
sputr(&e.s, hira ? 0x3063 : 0x30C3);
sputr(&e.next, c);
mapget(h, &e.next, &e.dict);
return e;
}
}
flush:
mapget(h, &im->pre, &e.s);
sclear(&key);
sputr(&key, c);
if(hmapget(h, &key) == nil){
e.flush = 1;
sputr(&e.s, c);
return e;
}
e.eat = 1;
sputr(&e.next, c);
mapget(h, &e.next, &e.dict);
return e;
}

View File

@ -4,9 +4,9 @@
static Im im;
Lang langs[] = {
{LangJP, "hira", "kanji", nil, nil, jptrans},
{LangJPK, "kata", "kanji", nil, nil, jptrans},
{LangKO, "hangul", nil, nil, nil, trans},
{LangJP, "hira", "kanji", nil, nil},
{LangJPK, "kata", "kanji", nil, nil},
{LangKO, "hangul", nil, nil, nil},
};
int nlang = nelem(langs);
@ -89,8 +89,7 @@ dotrans(Rune c, Str *com)
Emit e;
Dictreq req;
e = im.l->trans(&im, c);
e = trans(&im, c);
if(e.s.n > 0)
sappend(com, &e.s);
sclear(&im.pre);
@ -101,7 +100,6 @@ dotrans(Rune c, Str *com)
req.pre = im.pre;
channbsend(dictreqc, &req);
}
return e.eat;
}
@ -133,11 +131,9 @@ trans(Im *im, Rune c)
mapget(h, &key, &e.dict);
return e;
}
last = slastr(&im->pre);
if(last == 0)
goto flush;
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
@ -156,7 +152,6 @@ trans(Im *im, Rune c)
flush:
mapget(h, &im->pre, &e.s);
sclear(&key);
sputr(&key, c);
if(hmapget(h, &key) == nil){
@ -164,7 +159,6 @@ flush:
sputr(&e.s, c);
return e;
}
e.eat = 1;
sputr(&e.next, c);
mapget(h, &e.next, &e.dict);