engine: one ASCII fold, commitim through impre, no second modifier check
Four places lower-cased ASCII by hand; commitim repeated impre's three lines to compute the text it commits; and transition() began by rejecting modifier keys that imhandlekey's keymeaningful() had already turned away, kept alive only by tests calling transition() directly. The test helper now goes through the same gate.
This commit is contained in:
28
strans.c
28
strans.c
@@ -347,10 +347,7 @@ commitim(Im *p, Str *com)
|
|||||||
{
|
{
|
||||||
Str val;
|
Str val;
|
||||||
|
|
||||||
if(isjp(p))
|
impre(p, &val);
|
||||||
jpreading(p->l->map, &p->pre, &p->raw, &val);
|
|
||||||
else if(!mapget(p->l->map, &p->pre, &val))
|
|
||||||
val = p->pre;
|
|
||||||
sappend(com, &val);
|
sappend(com, &val);
|
||||||
sclear(&p->pre);
|
sclear(&p->pre);
|
||||||
sclear(&p->raw);
|
sclear(&p->raw);
|
||||||
@@ -483,21 +480,29 @@ transmap(Im *p, Rune c)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ASCII only: what the maps and dictionaries fold too. */
|
||||||
static Rune
|
static Rune
|
||||||
ctrlkey(Rune c)
|
lower(Rune c)
|
||||||
{
|
{
|
||||||
if(c >= 'A' && c <= 'Z')
|
if(c >= 'A' && c <= 'Z')
|
||||||
c += 'a' - 'A';
|
c += 'a' - 'A';
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Rune
|
||||||
|
ctrlkey(Rune c)
|
||||||
|
{
|
||||||
|
c = lower(c);
|
||||||
if(c >= 'a' && c <= 'z')
|
if(c >= 'a' && c <= 'z')
|
||||||
return c - 'a' + 1;
|
return c - 'a' + 1;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Caps Lock does not shift a Korean key; Shift does. */
|
||||||
static Rune
|
static Rune
|
||||||
kokey(Rune c, u32int mod)
|
kokey(Rune c, u32int mod)
|
||||||
{
|
{
|
||||||
if(c >= 'A' && c <= 'Z')
|
c = lower(c);
|
||||||
c += 'a' - 'A';
|
|
||||||
if((mod & Mshift) && c >= 'a' && c <= 'z')
|
if((mod & Mshift) && c >= 'a' && c <= 'z')
|
||||||
c -= 'a' - 'A';
|
c -= 'a' - 'A';
|
||||||
return c;
|
return c;
|
||||||
@@ -522,8 +527,7 @@ foldascii(Str *s)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < s->n; i++)
|
for(i = 0; i < s->n; i++)
|
||||||
if(s->r[i] >= 'A' && s->r[i] <= 'Z')
|
s->r[i] = lower(s->r[i]);
|
||||||
s->r[i] += 'a' - 'A';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -748,12 +752,10 @@ transition(u32int ks, u32int mod, Str *com)
|
|||||||
int n;
|
int n;
|
||||||
Rune c;
|
Rune c;
|
||||||
|
|
||||||
if(ismodkey(ks))
|
|
||||||
return 0;
|
|
||||||
if(im.l->lang == LangKO)
|
if(im.l->lang == LangKO)
|
||||||
ks = kokey(ks, mod);
|
ks = kokey(ks, mod);
|
||||||
else if(isjp(&im) && ks >= 'A' && ks <= 'Z')
|
else if(isjp(&im))
|
||||||
ks += 'a' - 'A'; /* romaji is case-blind, Caps Lock included */
|
ks = lower(ks); /* romaji is case-blind, Caps Lock included */
|
||||||
/* The Korean keyboard's 한/영 and 한자 keys are Ctrl+S or Ctrl+T, and Ctrl+H. */
|
/* The Korean keyboard's 한/영 and 한자 keys are Ctrl+S or Ctrl+T, and Ctrl+H. */
|
||||||
if(ks == Khangul){
|
if(ks == Khangul){
|
||||||
ks = im.l->lang == LangKO ? 't' : 's';
|
ks = im.l->lang == LangKO ? 't' : 's';
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ keystroke(u32int ks, u32int mod, Str *com)
|
|||||||
{
|
{
|
||||||
int eaten;
|
int eaten;
|
||||||
|
|
||||||
eaten = transition(ks, mod, com);
|
eaten = keymeaningful(ks) && transition(ks, mod, com);
|
||||||
redraw();
|
redraw();
|
||||||
return eaten;
|
return eaten;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user