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:
20
strans.c
20
strans.c
@@ -7,6 +7,7 @@ static void *lostowner; /* the context the engine was taken from */
|
||||
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 Drawcmd lastdraw;
|
||||
static Emit transjp(Im*, Rune);
|
||||
static void backjp(Im*);
|
||||
@@ -197,6 +198,8 @@ snapshot(Drawcmd *dc)
|
||||
dc->pre = pre;
|
||||
if(search.lang && pre.n == 0) /* a search just begun shows itself */
|
||||
sputr(&dc->pre, search.lang == LangEMOJI ? L'☺' : L'漢');
|
||||
else if(modemark != 0 && pre.n == 0 && im.nkouho == 0)
|
||||
sputr(&dc->pre, modemark);
|
||||
first = pagefirst();
|
||||
n = im.nkouho - first;
|
||||
if(n > Maxdisp) n = Maxdisp;
|
||||
@@ -336,6 +339,19 @@ katakouho(void)
|
||||
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
|
||||
setlang(int c)
|
||||
{
|
||||
@@ -344,6 +360,8 @@ setlang(int c)
|
||||
l = getlang(c);
|
||||
if(l == nil)
|
||||
return 0;
|
||||
if(l != im.l)
|
||||
modemark = langmark(l->lang);
|
||||
im.l = l;
|
||||
return 1;
|
||||
}
|
||||
@@ -783,6 +801,7 @@ transition(u32int ks, u32int mod, Str *com)
|
||||
int n;
|
||||
Rune c;
|
||||
|
||||
modemark = 0; /* any key after the switch takes its mark away */
|
||||
if(im.l->lang == LangKO)
|
||||
ks = kokey(ks, mod);
|
||||
else if(isjp(&im))
|
||||
@@ -897,6 +916,7 @@ init(void)
|
||||
im.sel = -1;
|
||||
memset(&search, 0, sizeof search);
|
||||
memset(&caret, 0, sizeof caret);
|
||||
modemark = 0;
|
||||
activeowner = nil;
|
||||
lostowner = nil;
|
||||
clientpre = 0;
|
||||
|
||||
Reference in New Issue
Block a user