engine: Backspace and Escape share their way back to the reading

This commit is contained in:
2026-08-17 01:55:57 +09:00
parent e32cea3296
commit 268b687ee6

View File

@@ -142,10 +142,11 @@ isjp(Im *p)
} }
/* /*
* Japanese keeps completed kana in pre and an ambiguous romaji syllable in * Japanese keeps completed kana, and any romaji that never became kana,
* raw. A mapped raw suffix is part of the reading even while it remains * in pre, and the romaji still being typed in raw. A mapped raw suffix
* pending (notably n, which may still grow into nya). Returns whether * is part of the reading even while it remains pending (notably n,
* the reading is complete. * which may still grow into nya). Returns whether the reading is
* complete.
*/ */
static int static int
jpreading(Trie *map, Str *pre, Str *raw, Str *s) jpreading(Trie *map, Str *pre, Str *raw, Str *s)
@@ -825,27 +826,20 @@ transition(u32int ks, u32int mod, Str *com)
/* Japanese confirms with the key; Korean and Telex let it on. */ /* Japanese confirms with the key; Korean and Telex let it on. */
return isjp(&im); return isjp(&im);
} }
if(ks == Kback){ if(ks == Kback || ks == Kesc){
if(!haspre(&im))
return 0;
if(im.sel >= 0){
im.sel = -1; /* back from the candidate to the reading */
return 1;
}
im.l->back(&im);
if(haspre(&im))
dictqjp();
else
reset();
return 1;
}
if(ks == Kesc){
if(!haspre(&im)) if(!haspre(&im))
return 0; return 0;
if(im.sel >= 0) if(im.sel >= 0)
im.sel = -1; im.sel = -1; /* back from the candidate to the reading */
else else if(ks == Kesc)
reset(); reset();
else{
im.l->back(&im);
if(haspre(&im))
dictqjp();
else
reset();
}
return 1; return 1;
} }
if(ks >= Kspec || chord(mod)){ if(ks >= Kspec || chord(mod)){