libhangul, and so fcitx5-hangul, joins two lone consonants into the compound jong they make (rt → ㄳ, split again by a vowel: rtk → ㄱ사), and by default reorders a vowel typed before its consonant (kr → 가); strans committed the first jamo and started over. Backspace on a lone ㄳ leaves ㄱ, as on a syllable. The three jamo index tables and their -1 macros were the cho, jung, and jong arrays inverted by hand, bounded by a Jrange the callers had to respect; a linear scan of the arrays says the same in ten lines.
111 lines
2.5 KiB
C
111 lines
2.5 KiB
C
#include "dat.h"
|
|
#include "fn.h"
|
|
#include "test.h"
|
|
|
|
static Str
|
|
kotrans(char *keys)
|
|
{
|
|
Str out, raw;
|
|
|
|
raw = mkstr(keys);
|
|
transstr(getlang(LangKO), &raw, &out);
|
|
return out;
|
|
}
|
|
|
|
void
|
|
korean_sequences(struct ct *t)
|
|
{
|
|
static const struct { char *keys, *want; } cases[] = {
|
|
{ "r", "ㄱ" },
|
|
{ "rk", "가" },
|
|
{ "rkr", "각" },
|
|
{ "rkrk", "가가" },
|
|
{ "rkrtk", "각사" },
|
|
{ "rhk", "과" },
|
|
{ "rr", "ㄱㄱ" },
|
|
{ "Rk", "까" },
|
|
{ "rk1", "가1" },
|
|
{ "rt", "ㄳ" },
|
|
{ "rtk", "ㄱ사" },
|
|
{ "rtt", "ㄳㅅ" },
|
|
{ "kr", "가" },
|
|
{ "hkr", "과" },
|
|
{ "kk", "ㅏㅏ" },
|
|
};
|
|
Str out;
|
|
int i;
|
|
|
|
for(i = 0; i < nelem(cases); i++){
|
|
out = kotrans(cases[i].keys);
|
|
checkstr(t, cases[i].keys, cases[i].want, &out);
|
|
}
|
|
}
|
|
|
|
void
|
|
korean_compound_vowels(struct ct *t)
|
|
{
|
|
static const struct { char *keys, *want; } cases[] = {
|
|
{ "hk", "ㅘ" }, { "ho", "ㅙ" }, { "hl", "ㅚ" },
|
|
{ "nj", "ㅝ" }, { "np", "ㅞ" }, { "nl", "ㅟ" },
|
|
{ "ml", "ㅢ" },
|
|
};
|
|
Str out;
|
|
int i;
|
|
|
|
for(i = 0; i < nelem(cases); i++){
|
|
out = kotrans(cases[i].keys);
|
|
checkstr(t, cases[i].keys, cases[i].want, &out);
|
|
}
|
|
}
|
|
|
|
void
|
|
korean_compound_finals(struct ct *t)
|
|
{
|
|
static const struct { char *keys, *want, *split; } cases[] = {
|
|
{ "rkrt", "갃", "각사" }, { "rksw", "갅", "간자" },
|
|
{ "rksg", "갆", "간하" }, { "rkfr", "갉", "갈가" },
|
|
{ "rkfa", "갊", "갈마" }, { "rkfq", "갋", "갈바" },
|
|
{ "rkft", "갌", "갈사" }, { "rkfx", "갍", "갈타" },
|
|
{ "rkfv", "갎", "갈파" }, { "rkfg", "갏", "갈하" },
|
|
{ "rkqt", "값", "갑사" },
|
|
};
|
|
char keys[16];
|
|
Str out;
|
|
int i;
|
|
|
|
for(i = 0; i < nelem(cases); i++){
|
|
out = kotrans(cases[i].keys);
|
|
checkstr(t, cases[i].keys, cases[i].want, &out);
|
|
snprint(keys, sizeof keys, "%sk", cases[i].keys);
|
|
out = kotrans(keys);
|
|
checkstr(t, keys, cases[i].split, &out);
|
|
}
|
|
}
|
|
|
|
void
|
|
korean_backspace(struct ct *t)
|
|
{
|
|
static const struct { char *before, *after; } cases[] = {
|
|
{ "ㄱ", "" },
|
|
{ "ㄳ", "ㄱ" },
|
|
{ "가", "ㄱ" },
|
|
{ "과", "고" }, { "괘", "고" }, { "괴", "고" },
|
|
{ "궈", "구" }, { "궤", "구" }, { "귀", "구" },
|
|
{ "긔", "그" },
|
|
{ "각", "가" },
|
|
{ "갃", "각" }, { "갅", "간" }, { "갆", "간" },
|
|
{ "갉", "갈" }, { "갊", "갈" }, { "갋", "갈" },
|
|
{ "갌", "갈" }, { "갍", "갈" }, { "갎", "갈" },
|
|
{ "갏", "갈" }, { "값", "갑" },
|
|
};
|
|
Im state;
|
|
int i;
|
|
|
|
memset(&state, 0, sizeof state);
|
|
for(i = 0; i < nelem(cases); i++){
|
|
state.pre = mkstr(cases[i].before);
|
|
backko(&state);
|
|
checkstr(t, cases[i].before, cases[i].after, &state.pre);
|
|
}
|
|
}
|