engine: Shift on the okurigana asks for that reading, as SKK does

kaku offers the twenty-two readings of かく before 書く, because the SKK
dictionary keys a verb by its stem and gives no frequency to rank the two
lists by.  SKK's own answer is the shift key: kaKu says where the
okurigana starts, and that split now comes first — the reading's own
candidates still follow it.  Caps Lock sends no Shift, so it marks
nothing, and a word typed without Shift is unchanged.
This commit is contained in:
2026-08-17 12:53:12 +09:00
parent 2e53627b7d
commit ae7dbae993
3 changed files with 43 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ static Str lost;
static int clientpre; /* the owner draws its own preedit */
static Caret caret;
static Rune modemark; /* the mode the last key switched to */
static int okuriat = -1; /* where Shift marked the okurigana, or -1 */
static Drawcmd lastdraw;
static Emit transjp(Im*, Rune);
static void backjp(Im*);
@@ -279,21 +280,22 @@ okuriletter(Rune r)
/*
* SKK keys a verb or adjective by its stem and the letter of the
* okurigana that follows (かk: 書, 描, ...). Every split of the reading
* is tried, longest stem first, and the okurigana is put back; a っ
* ending the stem (いっt: 言, 行) is written in kana too.
* okurigana that follows (かk: 書, 描, ...). The split the user marked
* is tried alone; otherwise every split is, longest stem first. The
* okurigana is put back, and a っ ending the stem (いっt: 言, 行) is
* written in kana too.
*/
static void
dictqokuri(Str *reading)
dictqokuri(Str *reading, int split)
{
Str key, okuri, kouho[Maxkouho];
Rune c;
int i, j, n;
for(i = reading->n - 1; i > 0; i--){
for(i = split >= 0 ? split : reading->n - 1; i > 0; i--){
c = okuriletter(reading->r[i]);
if(c == 0)
continue;
break;
key = *reading;
key.n = i;
sputr(&key, c);
@@ -305,6 +307,8 @@ dictqokuri(Str *reading)
sappend(&kouho[j], &okuri);
addkouho(&kouho[j]);
}
if(split >= 0)
break;
}
}
@@ -312,14 +316,20 @@ dictqokuri(Str *reading)
static void
dictqjp(void)
{
Str reading;
Str reading, exact[Maxkouho];
int i, n;
clearkouho();
if(!isjp(&im) || !jpreading(im.l->map, &im.pre, &im.raw, &reading) ||
reading.n == 0)
return;
im.nkouho = dictlookup(im.l->dict, &reading, im.kouho, Maxkouho);
dictqokuri(&reading);
/* What Shift marked comes first; the dictionary's own readings next. */
if(okuriat > 0 && okuriat < reading.n)
dictqokuri(&reading, okuriat);
n = dictlookup(im.l->dict, &reading, exact, Maxkouho);
for(i = 0; i < n; i++)
addkouho(&exact[i]);
dictqokuri(&reading, -1);
}
/* The reading in Katakana is the last candidate, as in every IME. */
@@ -663,6 +673,7 @@ reset(void)
{
sclear(&im.pre);
sclear(&im.raw);
okuriat = -1;
endsearch();
}
@@ -798,10 +809,16 @@ searchkey(u32int ks, u32int mod, Str *com)
static int
transition(u32int ks, u32int mod, Str *com)
{
Str mark;
int n;
Rune c;
modemark = 0; /* any key after the switch takes its mark away */
/* Shift on a romaji letter marks the okurigana, as SKK's capital does. */
if(isjp(&im) && (mod & Mshift) && ks >= 'A' && ks <= 'Z' && haspre(&im)){
impre(&im, &mark);
okuriat = mark.n;
}
if(im.l->lang == LangKO)
ks = kokey(ks, mod);
else if(isjp(&im))
@@ -917,6 +934,7 @@ init(void)
memset(&search, 0, sizeof search);
memset(&caret, 0, sizeof caret);
modemark = 0;
okuriat = -1;
activeowner = nil;
lostowner = nil;
clientpre = 0;