engine: the Hanja search composes from its seed, and Escape gives it back
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.
This commit is contained in:
30
strans.c
30
strans.c
@@ -526,21 +526,27 @@ foldascii(Str *s)
|
||||
s->r[i] += 'a' - 'A';
|
||||
}
|
||||
|
||||
/* What typing raw in language l would produce, composition included. */
|
||||
/*
|
||||
* What typing raw in language l would produce, composition included,
|
||||
* after pre, which may be nil, was already pending.
|
||||
*/
|
||||
void
|
||||
transstr(Lang *l, Str *raw, Str *out)
|
||||
transstr(Lang *l, Str *pre, Str *raw, Str *out)
|
||||
{
|
||||
Im q;
|
||||
Emit e;
|
||||
int i;
|
||||
|
||||
sclear(out);
|
||||
if(l->trans == nil){
|
||||
*out = *raw;
|
||||
return;
|
||||
}
|
||||
memset(&q, 0, sizeof q);
|
||||
q.l = l;
|
||||
if(pre != nil)
|
||||
q.pre = *pre;
|
||||
sclear(out);
|
||||
if(l->trans == nil){
|
||||
sappend(out, &q.pre);
|
||||
sappend(out, raw);
|
||||
return;
|
||||
}
|
||||
for(i = 0; i < raw->n; i++){
|
||||
e = l->trans(&q, raw->r[i]);
|
||||
sappend(out, &e.s);
|
||||
@@ -561,7 +567,7 @@ emojiquery(void)
|
||||
|
||||
raw = search.raw;
|
||||
foldascii(&raw);
|
||||
transstr(im.l, &search.raw, &local);
|
||||
transstr(im.l, nil, &search.raw, &local);
|
||||
foldascii(&local);
|
||||
clearkouho();
|
||||
n = dictlookup(getlang(LangEMOJI), &raw, kouho, Maxkouho);
|
||||
@@ -579,14 +585,11 @@ emojiquery(void)
|
||||
selectfirst();
|
||||
}
|
||||
|
||||
/* The keys typed since Ctrl+H go on composing from the seed. */
|
||||
static void
|
||||
hanjaquery(void)
|
||||
{
|
||||
Str key;
|
||||
|
||||
transstr(im.l, &search.raw, &key);
|
||||
search.text = search.seed;
|
||||
sappend(&search.text, &key);
|
||||
transstr(im.l, &search.seed, &search.raw, &search.text);
|
||||
clearkouho();
|
||||
im.nkouho = dictlookup(getlang(LangHANJA), &search.text, im.kouho,
|
||||
Maxkouho);
|
||||
@@ -711,6 +714,7 @@ searchkey(u32int ks, u32int mod, Str *com)
|
||||
return 1;
|
||||
}
|
||||
if(ks == Kesc){
|
||||
im.pre = search.seed; /* the syllable Ctrl+H took is pending again */
|
||||
endsearch();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user