Ctrl+H took the pending syllable as the query, but the keys typed after it started a composition of their own: gk, Ctrl+H, s showed 하ㄴ, and r, Ctrl+H, k showed ㄱㅏ. transstr now composes from a pending text, so the search goes on where the syllable left off. Escape ended the search and dropped the syllable it had taken; it puts it back as pending text.
79 lines
1.6 KiB
C
79 lines
1.6 KiB
C
#include "dat.h"
|
|
#include "fn.h"
|
|
#include "test.h"
|
|
|
|
static void
|
|
typevi(struct ct *t, char *keys, char *want)
|
|
{
|
|
Str out, raw;
|
|
|
|
raw = mkstr(keys);
|
|
transstr(&testvi, nil, &raw, &out);
|
|
checkstr(t, keys, want, &out);
|
|
}
|
|
|
|
void
|
|
vietnamese_transitions(struct ct *t)
|
|
{
|
|
static const struct { char *keys, *want; } cases[] = {
|
|
{ "as", "á" },
|
|
{ "As", "Á" },
|
|
{ "ans", "án" },
|
|
{ "Ans", "Án" },
|
|
{ "aws", "ắ" },
|
|
{ "asw", "ắ" },
|
|
{ "aww", "aw" },
|
|
{ "ddd", "dd" },
|
|
{ "ddas", "đá" },
|
|
{ "dds", "đs" },
|
|
{ "quas", "quá" },
|
|
{ "quaf", "quà" },
|
|
{ "quar", "quả" },
|
|
{ "quax", "quã" },
|
|
{ "quaj", "quạ" },
|
|
{ "Quas", "Quá" },
|
|
{ "gias", "giá" },
|
|
{ "Gias", "Giá" },
|
|
{ "gif", "gì" },
|
|
{ "cuar", "của" },
|
|
{ "vowis", "với" },
|
|
{ "cuwar", "cửa" },
|
|
{ "nguyeenx", "nguyễn" },
|
|
{ "dduwowngf", "đường" },
|
|
{ "\\s", "s" },
|
|
{ "a\\s", "as" },
|
|
};
|
|
int i;
|
|
|
|
for(i = 0; i < nelem(cases); i++)
|
|
typevi(t, cases[i].keys, cases[i].want);
|
|
}
|
|
|
|
void
|
|
vietnamese_backspace(struct ct *t)
|
|
{
|
|
static const struct {
|
|
char *pre, *raw, *rawafter, *after;
|
|
} cases[] = {
|
|
{ "as", "as", "a", "a" },
|
|
{ "quá", "quas", "qua", "qua" },
|
|
{ "à", "asf", "as", "á" },
|
|
{ "a", "asz", "as", "á" },
|
|
{ "quà", "quasf", "quas", "quá" },
|
|
};
|
|
Im state;
|
|
Str shown;
|
|
int i;
|
|
|
|
for(i = 0; i < nelem(cases); i++){
|
|
memset(&state, 0, sizeof state);
|
|
state.l = &testvi;
|
|
state.pre = mkstr(cases[i].pre);
|
|
state.raw = mkstr(cases[i].raw);
|
|
backvi(&state);
|
|
checkstr(t, cases[i].raw, cases[i].rawafter, &state.raw);
|
|
impre(&state, &shown);
|
|
checkstr(t, cases[i].raw, cases[i].after, &shown);
|
|
}
|
|
}
|