engine: Ctrl+H converts the pending syllable; Backspace on an empty search stays put
Ctrl+H committed the syllable being composed and opened an empty search, so converting 한 meant typing it twice; the pending syllable now seeds the query. Backspace on an already empty search ended it and then reached the application, deleting a character; it now only ends the search.
This commit is contained in:
57
strans.c
57
strans.c
@@ -10,10 +10,12 @@ static Drawcmd lastdraw;
|
||||
static Emit transjp(Im*, Rune);
|
||||
static void backjp(Im*);
|
||||
|
||||
/* seed is what Ctrl+H found pending; raw the keys typed since; text both. */
|
||||
typedef struct Search Search;
|
||||
struct Search
|
||||
{
|
||||
int lang;
|
||||
Str seed;
|
||||
Str raw;
|
||||
Str text;
|
||||
};
|
||||
@@ -228,18 +230,6 @@ redraw(void)
|
||||
channbsend(drawc, &dc);
|
||||
}
|
||||
|
||||
static void
|
||||
reset(void)
|
||||
{
|
||||
sclear(&im.pre);
|
||||
sclear(&im.raw);
|
||||
search.lang = 0;
|
||||
sclear(&search.raw);
|
||||
sclear(&search.text);
|
||||
memset(&caret, 0, sizeof caret);
|
||||
clearkouho();
|
||||
}
|
||||
|
||||
/* Kanji candidates for a complete reading. */
|
||||
static void
|
||||
dictqjp(void)
|
||||
@@ -526,9 +516,11 @@ hanjaquery(void)
|
||||
Str key;
|
||||
|
||||
transstr(im.l, &search.raw, &key);
|
||||
search.text = key;
|
||||
search.text = search.seed;
|
||||
sappend(&search.text, &key);
|
||||
clearkouho();
|
||||
im.nkouho = dictlookup(getlang(LangHANJA), &key, im.kouho, Maxkouho);
|
||||
im.nkouho = dictlookup(getlang(LangHANJA), &search.text, im.kouho,
|
||||
Maxkouho);
|
||||
selectfirst();
|
||||
}
|
||||
|
||||
@@ -551,11 +543,21 @@ static void
|
||||
endsearch(void)
|
||||
{
|
||||
search.lang = 0;
|
||||
sclear(&search.seed);
|
||||
sclear(&search.raw);
|
||||
sclear(&search.text);
|
||||
clearkouho();
|
||||
}
|
||||
|
||||
static void
|
||||
reset(void)
|
||||
{
|
||||
sclear(&im.pre);
|
||||
sclear(&im.raw);
|
||||
endsearch();
|
||||
memset(&caret, 0, sizeof caret);
|
||||
}
|
||||
|
||||
static void
|
||||
commitsearch(Str *com)
|
||||
{
|
||||
@@ -563,13 +565,27 @@ commitsearch(Str *com)
|
||||
endsearch();
|
||||
}
|
||||
|
||||
/* A search commits whatever is pending and takes over the keys. */
|
||||
/*
|
||||
* A search takes over the keys. Hanja converts the pending syllable, so
|
||||
* it becomes the query; anything else pending is committed.
|
||||
*/
|
||||
static void
|
||||
startsearch(int lang, Str *com)
|
||||
{
|
||||
commit(com);
|
||||
Str pending;
|
||||
|
||||
impre(&im, &pending);
|
||||
if(lang == LangHANJA){
|
||||
sclear(&im.pre);
|
||||
sclear(&im.raw);
|
||||
}else
|
||||
commit(com);
|
||||
commitsearch(com);
|
||||
search.lang = lang;
|
||||
if(lang == LangHANJA){
|
||||
search.seed = pending;
|
||||
searchquery();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -635,11 +651,14 @@ searchkey(u32int ks, u32int mod, Str *com)
|
||||
return 1;
|
||||
}
|
||||
if(ks == Kback){
|
||||
if(search.raw.n == 0){
|
||||
if(search.raw.n != 0)
|
||||
spopr(&search.raw);
|
||||
else if(search.seed.n != 0)
|
||||
spopr(&search.seed);
|
||||
else{
|
||||
endsearch();
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
spopr(&search.raw);
|
||||
searchquery();
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user