engine: an emoji query shows as typed and Space picks

The emoji search folded the keys for its lookup and then showed and
committed the folded copy: SMILE became smile in the text.  And it
showed the transliteration only while that alone matched, so a Korean
query flipped between 웃 and key soup as it grew.  Now the query shown
is the keys while they match anything, else what they type in the
current language, both as typed; only the lookups fold.  Space in a
search picks the highlighted result as Enter does, instead of adding a
space no alias needs.
This commit is contained in:
2026-08-17 01:44:29 +09:00
parent bab40c95a7
commit 0c4271b8b5
3 changed files with 17 additions and 10 deletions

View File

@@ -33,7 +33,7 @@ Japanese consumes the confirming key; Korean and Vietnamese pass it on to
the application. `Space` adds the reading in Katakana as the last
candidate, so a word the dictionary lacks converts to Katakana with one
`Space`. `Backspace` and `Esc` on a chosen candidate go back to the
reading. In a temporary Emoji or Hanja search, `Enter` commits the
reading. In a temporary Emoji or Hanja search, `Enter` or `Space` commits the
highlighted result and `Tab`/`Shift-Tab` wrap through the results. Leaving
the field or clicking elsewhere commits what is pending. `Esc` cancels a
Japanese reading or a search; in Korean and Vietnamese it commits the

View File

@@ -560,30 +560,34 @@ transstr(Lang *l, Str *pre, Str *raw, Str *out)
commitim(&q, out);
}
/* The typed keys and their transliteration are both emoji queries. */
/*
* The typed keys and their transliteration are both emoji queries, folded
* as the dictionary is; the query shown is the keys while they match
* something, else the transliteration, as typed.
*/
static void
emojiquery(void)
{
Str kouho[Maxkouho], raw, local;
int i, n, rawhit, localhit;
int i, n, rawhit;
raw = search.raw;
foldascii(&raw);
transstr(im.l, nil, &search.raw, &local);
transstr(im.l, nil, &search.raw, &search.text);
local = search.text;
foldascii(&local);
clearkouho();
n = dictprefix(getlang(LangEMOJI)->dict, &raw, kouho, Maxkouho);
rawhit = n != 0;
for(i = 0; i < n; i++)
addkouho(&kouho[i]);
localhit = 0;
if(scmp(&raw, &local) != 0){
n = dictprefix(getlang(LangEMOJI)->dict, &local, kouho, Maxkouho);
localhit = n != 0;
for(i = 0; i < n; i++)
addkouho(&kouho[i]);
}
search.text = rawhit || !localhit ? raw : local;
if(rawhit)
search.text = search.raw;
selectfirst();
}
@@ -706,7 +710,7 @@ searchkey(u32int ks, u32int mod, Str *com)
cyclekouho(mod & Mshift ? -1 : 1);
return 1;
}
if(ks == Kret){
if(ks == Kret || ks == ' '){
if(im.nkouho > 0)
picksearch(max(im.sel, 0), com);
else

View File

@@ -1526,6 +1526,7 @@ engine_emoji_digit_aliases(struct ct *t)
checkstr(t, "zero alias", "", &com);
sclear(&com);
im.l = getlang(LangEN);
CT_CHECK(t, keystroke('e', Mctrl, &com));
if(typekeys(t, "smile", &com)){
CT_CHECK(t, keystroke('9', 0, &com));
@@ -1582,6 +1583,7 @@ engine_search_candidate_keys(struct ct *t)
Str com;
emojibegin(&f, 0);
im.l = getlang(LangEN);
sclear(&com);
CT_CHECK(t, keystroke('e', Mctrl, &com));
if(typekeys(t, "smile", &com)){
@@ -1709,11 +1711,13 @@ engine_emoji_start_and_unknown(struct ct *t)
sclear(&com);
CT_CHECK(t, keystroke('e', Mctrl, &com));
if(typekeys(t, "xyz", &com)){
/* Keys that match nothing show what they type in the language. */
CT_CHECK(t, !keystroke(Kspec|0x51, 0, &com));
checkstr(t, "special commits shown query", "xyz", &com);
checkstr(t, "special commits shown query", "", &com);
CT_CHECK(t, !search.lang);
CT_EQ_INT(t, LangKO, im.l->lang);
}
im.l = getlang(LangEN);
/* A language switch commits the query like any other pending text. */
sclear(&com);
@@ -1723,7 +1727,6 @@ engine_emoji_start_and_unknown(struct ct *t)
checkstr(t, "language switch commits query", "xy", &com);
CT_CHECK(t, !search.lang);
CT_EQ_INT(t, LangEN, im.l->lang);
im.l = getlang(LangKO);
}
/* So do the search keys, ending or changing the search. */