add eomji(ctrl+e)

TODO: Some emojis can't be displayed. A font fallback or font merge is required.
This commit is contained in:
2025-12-28 16:49:26 +09:00
parent 436a49c3ca
commit 97ae9b1709
6 changed files with 517 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ Lang langs[] = {
{LangJP, "hira", "kanji", nil, nil},
{LangJPK, "kata", "kanji", nil, nil},
{LangKO, "hangul", nil, nil, nil},
{LangEMOJI, "emoji", "emoji", nil, nil},
};
int nlang = nelem(langs);
@@ -36,7 +37,10 @@ show(void)
int i;
sclear(&dc.preedit);
mapget(im.l->map, &im.pre, &dc.preedit);
if(im.l == nil)
return;
if(!mapget(im.l->map, &im.pre, &dc.preedit))
dc.preedit = im.pre;
dc.nkouho = im.nkouho;
dc.sel = im.sel;
for(i = 0; i < dc.nkouho; i++)
@@ -44,6 +48,14 @@ show(void)
chansend(drawc, &dc);
}
static void
reset(void)
{
sclear(&im.pre);
clearkouho();
show();
}
static void
dictq(void)
{
@@ -78,6 +90,10 @@ commit(Str *com)
{
Str kana;
if(im.l == nil){
sclear(&im.pre);
return;
}
if(mapget(im.l->map, &im.pre, &kana))
sappend(com, &kana);
sclear(&im.pre);
@@ -165,14 +181,6 @@ flush:
return e;
}
static void
reset(void)
{
sclear(&im.pre);
clearkouho();
show();
}
static int
keystroke(u32int ks, u32int mod, Str *com)
{
@@ -244,13 +252,14 @@ keystroke(u32int ks, u32int mod, Str *com)
}
if(im.l == nil)
return 0;
if(ks > 0x7f || !isalpha(ks)){
if(ks > 0x7f || ks == ' '){
commit(com);
sputr(com, ks);
reset();
return 1;
}
return dotrans(ks, com);
dotrans(ks, com);
return 1;
}
static void