engine: Backspace deletes the last kana shown; Tab converts like Space
Backspace undid a keystroke: な became ん, かんじ became かんj, きゃ became ky. Like every Japanese IME it now deletes the last kana as shown — な goes, かんじ becomes かん, きゃ becomes き — while a romaji letter that never became kana still goes one at a time. Tab stepped through candidates in a search and committed in Japanese; it steps through them there too, with Space, and Shift+Tab steps back.
This commit is contained in:
@@ -24,11 +24,12 @@ or `Super` held it commits what is pending and goes to the application, so
|
|||||||
`Ctrl+Shift+V` still pastes.
|
`Ctrl+Shift+V` still pastes.
|
||||||
|
|
||||||
A complete Japanese reading shows its Kanji candidates with none chosen.
|
A complete Japanese reading shows its Kanji candidates with none chosen.
|
||||||
`Space` chooses the first and then steps on, wrapping (`Shift+Space` steps
|
`Space` or `Tab` chooses the first and then steps on, wrapping (with
|
||||||
back); `Up`/`Down` and `PageUp`/`PageDown` move without wrapping. An
|
`Shift`, back); `Up`/`Down` and `PageUp`/`PageDown` move without wrapping.
|
||||||
unmodified `1`-`9` commits that row of the current page. `Enter` and `Tab`
|
An unmodified `1`-`9` commits that row of the current page. `Enter`
|
||||||
commit the chosen candidate, or the reading when none is chosen, as `0`
|
commits the chosen candidate, or the reading when none is chosen, as `0`
|
||||||
always does; so does typing on, or any key that ends the composition.
|
always does; so does typing on, or any key that ends the composition.
|
||||||
|
`Backspace` deletes the last kana shown.
|
||||||
Japanese consumes the confirming key; Korean and Vietnamese pass it on to
|
Japanese consumes the confirming key; Korean and Vietnamese pass it on to
|
||||||
the application. `Space` adds the reading in Katakana as the last
|
the application. `Space` adds the reading in Katakana as the last
|
||||||
candidate, so a word the dictionary lacks converts to Katakana with one
|
candidate, so a word the dictionary lacks converts to Katakana with one
|
||||||
|
|||||||
20
strans.c
20
strans.c
@@ -356,13 +356,20 @@ commitim(Im *p, Str *com)
|
|||||||
sclear(&p->raw);
|
sclear(&p->raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Deletes the last kana as shown, not the last key: kya loses ゃ. */
|
||||||
static void
|
static void
|
||||||
backjp(Im *p)
|
backjp(Im *p)
|
||||||
{
|
{
|
||||||
if(p->raw.n != 0)
|
Str v;
|
||||||
spopr(&p->raw);
|
|
||||||
else
|
if(p->raw.n == 0)
|
||||||
spopr(&p->pre);
|
spopr(&p->pre);
|
||||||
|
else if(mapget(p->l->map, &p->raw, &v)){
|
||||||
|
spopr(&v);
|
||||||
|
sappend(&p->pre, &v);
|
||||||
|
sclear(&p->raw);
|
||||||
|
}else
|
||||||
|
spopr(&p->raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -800,9 +807,10 @@ transition(u32int ks, u32int mod, Str *com)
|
|||||||
reset();
|
reset();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(ks == ' ' && isjp(&im) && haspre(&im) && !(mod & ~Mshift)){
|
if((ks == ' ' || ks == Ktab) && isjp(&im) && haspre(&im) &&
|
||||||
/* Space converts: it steps through the candidates, Katakana
|
!(mod & ~Mshift)){
|
||||||
* last; a reading with none is committed. */
|
/* Space and Tab convert: they step through the candidates,
|
||||||
|
* Katakana last; a reading with none is committed. */
|
||||||
katakouho();
|
katakouho();
|
||||||
if(im.nkouho != 0)
|
if(im.nkouho != 0)
|
||||||
cyclekouho(mod & Mshift ? -1 : 1);
|
cyclekouho(mod & Mshift ? -1 : 1);
|
||||||
|
|||||||
@@ -120,9 +120,9 @@ engine_backspace_clears_candidates(struct ct *t)
|
|||||||
checkstr(t, "chosen candidate backspace", "na", &im.raw);
|
checkstr(t, "chosen candidate backspace", "na", &im.raw);
|
||||||
CT_CHECK(t, keystroke(Kback, 0, &com));
|
CT_CHECK(t, keystroke(Kback, 0, &com));
|
||||||
checkstr(t, "backspace commit", "", &com);
|
checkstr(t, "backspace commit", "", &com);
|
||||||
checkstr(t, "pending romaji after backspace", "n", &im.raw);
|
checkstr(t, "backspace deletes the kana shown", "", &im.raw);
|
||||||
impre(&im, &shown);
|
impre(&im, &shown);
|
||||||
checkstr(t, "shown preedit after backspace", "ん", &shown);
|
checkstr(t, "shown preedit after backspace", "", &shown);
|
||||||
CT_EQ_INT(t, 0, im.nkouho);
|
CT_EQ_INT(t, 0, im.nkouho);
|
||||||
CT_EQ_INT(t, -1, im.sel);
|
CT_EQ_INT(t, -1, im.sel);
|
||||||
}
|
}
|
||||||
@@ -852,21 +852,28 @@ engine_candidate_page_movement(struct ct *t)
|
|||||||
void
|
void
|
||||||
engine_candidate_completion(struct ct *t)
|
engine_candidate_completion(struct ct *t)
|
||||||
{
|
{
|
||||||
static Rune keys[] = { Kret, Ktab };
|
|
||||||
Str com;
|
Str com;
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; i < nelem(keys); i++){
|
init();
|
||||||
init();
|
im.l = getlang(LangJP);
|
||||||
im.l = getlang(LangJP);
|
im.pre = mkstr("reading");
|
||||||
im.pre = mkstr("reading");
|
setcandidates(1);
|
||||||
setcandidates(1);
|
sclear(&com);
|
||||||
sclear(&com);
|
CT_CHECK(t, keystroke(Kret, 0, &com));
|
||||||
CT_CHECK(t, keystroke(keys[i], 0, &com));
|
checkstr(t, "unselected candidate commits reading", "reading", &com);
|
||||||
checkstr(t, "unselected candidate commits reading",
|
CT_EQ_INT(t, 0, im.nkouho);
|
||||||
"reading", &com);
|
|
||||||
CT_EQ_INT(t, 0, im.nkouho);
|
init();
|
||||||
}
|
im.l = getlang(LangJP);
|
||||||
|
im.pre = mkstr("reading");
|
||||||
|
setcandidates(2);
|
||||||
|
sclear(&com);
|
||||||
|
CT_CHECK(t, keystroke(Ktab, 0, &com));
|
||||||
|
CT_EQ_INT(t, 0, im.sel);
|
||||||
|
CT_CHECK(t, keystroke(Ktab, Mshift, &com));
|
||||||
|
CT_EQ_INT(t, 1, im.sel);
|
||||||
|
CT_CHECK(t, keystroke(Kret, 0, &com));
|
||||||
|
checkstr(t, "Tab steps through the candidates", "c2", &com);
|
||||||
|
|
||||||
candidatebegin(2);
|
candidatebegin(2);
|
||||||
im.pre = mkstr("reading");
|
im.pre = mkstr("reading");
|
||||||
@@ -1250,8 +1257,6 @@ engine_japanese_candidates(struct ct *t)
|
|||||||
if(!typekeys(t, "kanji", &com))
|
if(!typekeys(t, "kanji", &com))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
CT_CHECK(t, keystroke(Kback, 0, &com));
|
CT_CHECK(t, keystroke(Kback, 0, &com));
|
||||||
CT_EQ_INT(t, 0, im.nkouho);
|
|
||||||
CT_CHECK(t, keystroke(Kback, 0, &com));
|
|
||||||
if(CT_EQ_INT(t, 1, im.nkouho))
|
if(CT_EQ_INT(t, 1, im.nkouho))
|
||||||
checkstr(t, "shorter reading candidate", "缶", &im.kouho[0]);
|
checkstr(t, "shorter reading candidate", "缶", &im.kouho[0]);
|
||||||
cleanup:
|
cleanup:
|
||||||
@@ -1270,13 +1275,18 @@ engine_japanese_backspace_and_boundaries(struct ct *t)
|
|||||||
if(typekeys(t, "kanji", &com)){
|
if(typekeys(t, "kanji", &com)){
|
||||||
CT_CHECK(t, keystroke(Kback, 0, &com));
|
CT_CHECK(t, keystroke(Kback, 0, &com));
|
||||||
impre(&im, &shown);
|
impre(&im, &shown);
|
||||||
checkstr(t, "backspace pending i", "かんj", &shown);
|
checkstr(t, "backspace deletes じ", "かん", &shown);
|
||||||
CT_CHECK(t, keystroke(Kback, 0, &com));
|
CT_CHECK(t, keystroke(Kback, 0, &com));
|
||||||
impre(&im, &shown);
|
impre(&im, &shown);
|
||||||
checkstr(t, "backspace pending j", "かん", &shown);
|
checkstr(t, "backspace deletes ん", "か", &shown);
|
||||||
CT_CHECK(t, keystroke(Kback, 0, &com));
|
if(typekeys(t, "kyu", &com)){
|
||||||
impre(&im, &shown);
|
CT_CHECK(t, keystroke(Kback, 0, &com));
|
||||||
checkstr(t, "backspace accumulated kana", "か", &shown);
|
impre(&im, &shown);
|
||||||
|
checkstr(t, "backspace deletes ゅ", "かき", &shown);
|
||||||
|
CT_CHECK(t, keystroke(Kback, 0, &com));
|
||||||
|
CT_CHECK(t, keystroke(Kback, 0, &com));
|
||||||
|
CT_CHECK(t, !haspre(&im));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
Reference in New Issue
Block a user