engine: a mode switch shows the mode it switched to
Ctrl+S, Ctrl+N and the rest changed the mode with nothing to see; the next key was the only way to tell. The popup now shows A, 한, あ, ア, or ă until a key is typed, beside the ☺ and 漢 a search already shows.
This commit is contained in:
@@ -17,6 +17,9 @@ compatibility mode.
|
|||||||
| `Ctrl+E` | Emoji and symbol search |
|
| `Ctrl+E` | Emoji and symbol search |
|
||||||
| `Ctrl+H` | One-shot Hanja search |
|
| `Ctrl+H` | One-shot Hanja search |
|
||||||
|
|
||||||
|
Switching mode shows the mode switched to — `A`, `한`, `あ`, `ア`, `ă` — in
|
||||||
|
the popup until the next key.
|
||||||
|
|
||||||
A Korean keyboard's 한/영 key toggles Korean and English, and its 한자 key
|
A Korean keyboard's 한/영 key toggles Korean and English, and its 한자 key
|
||||||
is `Ctrl+H`; a Japanese keyboard's 半角/全角 toggles Japanese and English,
|
is `Ctrl+H`; a Japanese keyboard's 半角/全角 toggles Japanese and English,
|
||||||
ひらがな/カタカナ switches between the two kana modes, 変換 turns Japanese
|
ひらがな/カタカナ switches between the two kana modes, 変換 turns Japanese
|
||||||
|
|||||||
20
strans.c
20
strans.c
@@ -7,6 +7,7 @@ static void *lostowner; /* the context the engine was taken from */
|
|||||||
static Str lost;
|
static Str lost;
|
||||||
static int clientpre; /* the owner draws its own preedit */
|
static int clientpre; /* the owner draws its own preedit */
|
||||||
static Caret caret;
|
static Caret caret;
|
||||||
|
static Rune modemark; /* the mode the last key switched to */
|
||||||
static Drawcmd lastdraw;
|
static Drawcmd lastdraw;
|
||||||
static Emit transjp(Im*, Rune);
|
static Emit transjp(Im*, Rune);
|
||||||
static void backjp(Im*);
|
static void backjp(Im*);
|
||||||
@@ -197,6 +198,8 @@ snapshot(Drawcmd *dc)
|
|||||||
dc->pre = pre;
|
dc->pre = pre;
|
||||||
if(search.lang && pre.n == 0) /* a search just begun shows itself */
|
if(search.lang && pre.n == 0) /* a search just begun shows itself */
|
||||||
sputr(&dc->pre, search.lang == LangEMOJI ? L'☺' : L'漢');
|
sputr(&dc->pre, search.lang == LangEMOJI ? L'☺' : L'漢');
|
||||||
|
else if(modemark != 0 && pre.n == 0 && im.nkouho == 0)
|
||||||
|
sputr(&dc->pre, modemark);
|
||||||
first = pagefirst();
|
first = pagefirst();
|
||||||
n = im.nkouho - first;
|
n = im.nkouho - first;
|
||||||
if(n > Maxdisp) n = Maxdisp;
|
if(n > Maxdisp) n = Maxdisp;
|
||||||
@@ -336,6 +339,19 @@ katakouho(void)
|
|||||||
addkouho(&k);
|
addkouho(&k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* What the popup shows for a moment when the mode changes. */
|
||||||
|
static Rune
|
||||||
|
langmark(int lang)
|
||||||
|
{
|
||||||
|
switch(lang){
|
||||||
|
case LangJP: return L'あ';
|
||||||
|
case LangJPK: return L'ア';
|
||||||
|
case LangKO: return L'한';
|
||||||
|
case LangVI: return L'ă';
|
||||||
|
}
|
||||||
|
return L'A';
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
setlang(int c)
|
setlang(int c)
|
||||||
{
|
{
|
||||||
@@ -344,6 +360,8 @@ setlang(int c)
|
|||||||
l = getlang(c);
|
l = getlang(c);
|
||||||
if(l == nil)
|
if(l == nil)
|
||||||
return 0;
|
return 0;
|
||||||
|
if(l != im.l)
|
||||||
|
modemark = langmark(l->lang);
|
||||||
im.l = l;
|
im.l = l;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -783,6 +801,7 @@ transition(u32int ks, u32int mod, Str *com)
|
|||||||
int n;
|
int n;
|
||||||
Rune c;
|
Rune c;
|
||||||
|
|
||||||
|
modemark = 0; /* any key after the switch takes its mark away */
|
||||||
if(im.l->lang == LangKO)
|
if(im.l->lang == LangKO)
|
||||||
ks = kokey(ks, mod);
|
ks = kokey(ks, mod);
|
||||||
else if(isjp(&im))
|
else if(isjp(&im))
|
||||||
@@ -897,6 +916,7 @@ init(void)
|
|||||||
im.sel = -1;
|
im.sel = -1;
|
||||||
memset(&search, 0, sizeof search);
|
memset(&search, 0, sizeof search);
|
||||||
memset(&caret, 0, sizeof caret);
|
memset(&caret, 0, sizeof caret);
|
||||||
|
modemark = 0;
|
||||||
activeowner = nil;
|
activeowner = nil;
|
||||||
lostowner = nil;
|
lostowner = nil;
|
||||||
clientpre = 0;
|
clientpre = 0;
|
||||||
|
|||||||
@@ -565,11 +565,25 @@ engine_korean_modifiers_and_backspace(struct ct *t)
|
|||||||
void
|
void
|
||||||
engine_direct_language_modes(struct ct *t)
|
engine_direct_language_modes(struct ct *t)
|
||||||
{
|
{
|
||||||
|
Drawcmd dc;
|
||||||
Str com;
|
Str com;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
draindraw(nil);
|
||||||
sclear(&com);
|
sclear(&com);
|
||||||
CT_EQ_INT(t, LangEN, im.l->lang);
|
CT_EQ_INT(t, LangEN, im.l->lang);
|
||||||
|
/* A switch shows the mode it switched to until the next key. */
|
||||||
|
CT_CHECK(t, keystroke('s', Mctrl, &com));
|
||||||
|
if(CT_CHECK(t, draindraw(&dc) > 0))
|
||||||
|
checkstr(t, "mode mark", "한", &dc.pre);
|
||||||
|
CT_CHECK(t, keystroke('t', Mctrl, &com));
|
||||||
|
if(CT_CHECK(t, draindraw(&dc) > 0))
|
||||||
|
checkstr(t, "mode mark", "A", &dc.pre);
|
||||||
|
CT_CHECK(t, !keystroke('a', 0, &com));
|
||||||
|
if(CT_CHECK(t, draindraw(&dc) > 0))
|
||||||
|
CT_EQ_INT(t, 0, dc.pre.n);
|
||||||
|
CT_CHECK(t, !keystroke('a', 0, &com));
|
||||||
|
CT_EQ_INT(t, 0, draindraw(nil));
|
||||||
CT_EQ_PTR(t, nil, im.l->mapname);
|
CT_EQ_PTR(t, nil, im.l->mapname);
|
||||||
CT_EQ_PTR(t, nil, im.l->map);
|
CT_EQ_PTR(t, nil, im.l->map);
|
||||||
CT_EQ_PTR(t, nil, im.l->trans);
|
CT_EQ_PTR(t, nil, im.l->trans);
|
||||||
|
|||||||
Reference in New Issue
Block a user