fix(engine): send clients the composed Telex text, not the keys
For Vietnamese the preedit is the map key ('as', 'oong'); only the popup
and the commit path looked it up. Clients with inline preedit therefore
showed 'as' while Enter committed 'á'. impre() now maps once for every
reader, and snapshot() no longer maps a second time.
This commit is contained in:
@@ -417,6 +417,51 @@ engine_active_owner_caret(struct ct *t)
|
||||
CT_CHECK(t, !caret.valid);
|
||||
}
|
||||
|
||||
void
|
||||
engine_vietnamese_client_preedit(struct ct *t)
|
||||
{
|
||||
static const struct {
|
||||
char *keys;
|
||||
char *shown;
|
||||
} cases[] = {
|
||||
{ "as", "á" },
|
||||
{ "aa", "â" },
|
||||
{ "ddoong", "đông" },
|
||||
{ "hoaf", "hoà" },
|
||||
{ "quas", "quá" },
|
||||
};
|
||||
Drawcmd dc;
|
||||
Keyres res;
|
||||
Str com, shown;
|
||||
char *k, owner;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < nelem(cases); i++){
|
||||
init();
|
||||
im.l = &testvi;
|
||||
draindraw(nil);
|
||||
sclear(&com);
|
||||
for(k = cases[i].keys; *k != '\0'; k++){
|
||||
res = ownerrequestcap(&owner, Cclientpreedit,
|
||||
Keypress, *k, 0);
|
||||
sappend(&com, &res.commit);
|
||||
if(!res.eaten)
|
||||
sputr(&com, *k);
|
||||
}
|
||||
/* What the client shows, what the popup shows, and what
|
||||
* Enter commits are the same composed text. */
|
||||
shown = com;
|
||||
sappend(&shown, &res.preedit);
|
||||
checkstr(t, "client preedit", cases[i].shown, &shown);
|
||||
activecap = 0;
|
||||
redraw();
|
||||
if(CT_CHECK(t, draindraw(&dc) > 0))
|
||||
CT_EQ_INT(t, 0, scmp(&dc.pre, &res.preedit));
|
||||
CT_CHECK(t, keystroke(Kret, 0, &com));
|
||||
checkstr(t, "commit", cases[i].shown, &com);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
engine_commit_contract(struct ct *t)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user