engine: Space offers the reading in Katakana last; 0 always commits the reading

Every Japanese IME converts a reading to Katakana on demand; strans made
the user switch to the Katakana mode and type again.  Space now adds
the reading in Katakana after the dictionary candidates, so a loanword
the dictionary lacks converts with one Space and Enter, and 漢字 users
still get 漢字 first.

0 committed the reading only while candidates showed; without them it
typed a 0 as well.  It now commits any Japanese reading, the counterpart
of 1-9 picking candidates, as the README always said.
This commit is contained in:
2026-08-17 01:18:33 +09:00
parent ab0366b7f7
commit f0498868eb
3 changed files with 81 additions and 42 deletions

View File

@@ -313,6 +313,23 @@ dictqjp(void)
dictqokuri(&reading);
}
/* The reading in Katakana is the last candidate, as in every IME. */
static void
katakouho(void)
{
Str reading, k;
int i;
if(!jpreading(im.l->map, &im.pre, &im.raw, &reading))
return;
k = reading;
for(i = 0; i < k.n; i++)
if(k.r[i] >= L'' && k.r[i] <= L'')
k.r[i] += L'' - L'';
if(scmp(&k, &reading) != 0)
addkouho(&k);
}
static int
setlang(int c)
{
@@ -755,8 +772,9 @@ transition(u32int ks, u32int mod, Str *com)
return 1;
}
if(ks == ' ' && isjp(&im) && haspre(&im) && !(mod & ~Mshift)){
/* Space converts: it steps through the candidates, or
* commits a reading that has none. */
/* Space converts: it steps through the candidates, Katakana
* last; a reading with none is committed. */
katakouho();
if(im.nkouho != 0)
cyclekouho(mod & Mshift ? -1 : 1);
else
@@ -811,8 +829,8 @@ transition(u32int ks, u32int mod, Str *com)
flush(com);
return setlang(c);
}
if(ks == '0' && im.nkouho > 0){
im.sel = -1;
if(ks == '0' && isjp(&im) && haspre(&im)){
im.sel = -1; /* 0 commits the reading, as 1-9 pick candidates */
flush(com);
return 1;
}