rename line => pre
This commit is contained in:
parent
8a2ef65379
commit
e5ce5fd61e
4
dat.h
4
dat.h
@ -85,7 +85,7 @@ struct Lang
|
|||||||
struct Im
|
struct Im
|
||||||
{
|
{
|
||||||
Lang *l;
|
Lang *l;
|
||||||
Str line;
|
Str pre;
|
||||||
Str kouho[Maxkouho];
|
Str kouho[Maxkouho];
|
||||||
int nkouho;
|
int nkouho;
|
||||||
int sel;
|
int sel;
|
||||||
@ -112,7 +112,7 @@ typedef struct Dictreq Dictreq;
|
|||||||
struct Dictreq
|
struct Dictreq
|
||||||
{
|
{
|
||||||
Str key;
|
Str key;
|
||||||
Str line;
|
Str pre;
|
||||||
int lang;
|
int lang;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
2
dict.c
2
dict.c
@ -47,7 +47,7 @@ dictthread(void*)
|
|||||||
while(channbrecv(dictreqc, &req) > 0)
|
while(channbrecv(dictreqc, &req) > 0)
|
||||||
;
|
;
|
||||||
dictlkup(&req, &res);
|
dictlkup(&req, &res);
|
||||||
res.key = req.line;
|
res.key = req.pre;
|
||||||
chansend(dictresc, &res);
|
chansend(dictresc, &res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
jp.c
12
jp.c
@ -13,7 +13,7 @@ jptrans(Im *im, Rune c)
|
|||||||
memset(&e, 0, sizeof(e));
|
memset(&e, 0, sizeof(e));
|
||||||
h = im->l->map;
|
h = im->l->map;
|
||||||
hira = (im->l->lang == LangJP);
|
hira = (im->l->lang == LangJP);
|
||||||
key = im->line;
|
key = im->pre;
|
||||||
sputr(&key, c);
|
sputr(&key, c);
|
||||||
if(hmapget(h, &key)){
|
if(hmapget(h, &key)){
|
||||||
e.eat = 1;
|
e.eat = 1;
|
||||||
@ -21,10 +21,10 @@ jptrans(Im *im, Rune c)
|
|||||||
mapget(h, &key, &e.dict);
|
mapget(h, &key, &e.dict);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
last = slastr(&im->line);
|
last = slastr(&im->pre);
|
||||||
if(last == 0)
|
if(last == 0)
|
||||||
goto flush;
|
goto flush;
|
||||||
key = im->line;
|
key = im->pre;
|
||||||
key.n--;
|
key.n--;
|
||||||
if(mapget(h, &key, &kana)){
|
if(mapget(h, &key, &kana)){
|
||||||
sclear(&key);
|
sclear(&key);
|
||||||
@ -40,7 +40,7 @@ jptrans(Im *im, Rune c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c == 'n' && last == 'n'){
|
if(c == 'n' && last == 'n'){
|
||||||
key = im->line;
|
key = im->pre;
|
||||||
key.n--;
|
key.n--;
|
||||||
if(mapget(h, &key, &kana)){
|
if(mapget(h, &key, &kana)){
|
||||||
e.eat = 1;
|
e.eat = 1;
|
||||||
@ -52,7 +52,7 @@ jptrans(Im *im, Rune c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c == last && strchr("kgsztdbpmjfchryw", c)){
|
if(c == last && strchr("kgsztdbpmjfchryw", c)){
|
||||||
key = im->line;
|
key = im->pre;
|
||||||
key.n--;
|
key.n--;
|
||||||
if(mapget(h, &key, &kana)){
|
if(mapget(h, &key, &kana)){
|
||||||
e.eat = 1;
|
e.eat = 1;
|
||||||
@ -65,7 +65,7 @@ jptrans(Im *im, Rune c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush:
|
flush:
|
||||||
mapget(h, &im->line, &e.s);
|
mapget(h, &im->pre, &e.s);
|
||||||
sclear(&key);
|
sclear(&key);
|
||||||
sputr(&key, c);
|
sputr(&key, c);
|
||||||
if(hmapget(h, &key) == nil){
|
if(hmapget(h, &key) == nil){
|
||||||
|
|||||||
38
strans.c
38
strans.c
@ -36,7 +36,7 @@ show(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
sclear(&dc.preedit);
|
sclear(&dc.preedit);
|
||||||
mapget(im.l->map, &im.line, &dc.preedit);
|
mapget(im.l->map, &im.pre, &dc.preedit);
|
||||||
dc.nkouho = im.nkouho;
|
dc.nkouho = im.nkouho;
|
||||||
dc.sel = im.sel;
|
dc.sel = im.sel;
|
||||||
for(i = 0; i < dc.nkouho; i++)
|
for(i = 0; i < dc.nkouho; i++)
|
||||||
@ -50,14 +50,14 @@ dictq(void)
|
|||||||
Str dict;
|
Str dict;
|
||||||
Dictreq req;
|
Dictreq req;
|
||||||
|
|
||||||
if(!mapget(im.l->map, &im.line, &dict)){
|
if(!mapget(im.l->map, &im.pre, &dict)){
|
||||||
clearkouho();
|
clearkouho();
|
||||||
show();
|
show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req.key = dict;
|
req.key = dict;
|
||||||
req.lang = im.l->lang;
|
req.lang = im.l->lang;
|
||||||
req.line = im.line;
|
req.pre = im.pre;
|
||||||
channbsend(dictreqc, &req);
|
channbsend(dictreqc, &req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +78,9 @@ commit(Str *com)
|
|||||||
{
|
{
|
||||||
Str kana;
|
Str kana;
|
||||||
|
|
||||||
if(mapget(im.l->map, &im.line, &kana))
|
if(mapget(im.l->map, &im.pre, &kana))
|
||||||
sappend(com, &kana);
|
sappend(com, &kana);
|
||||||
sclear(&im.line);
|
sclear(&im.pre);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -93,12 +93,12 @@ dotrans(Rune c, Str *com)
|
|||||||
|
|
||||||
if(e.s.n > 0)
|
if(e.s.n > 0)
|
||||||
sappend(com, &e.s);
|
sappend(com, &e.s);
|
||||||
sclear(&im.line);
|
sclear(&im.pre);
|
||||||
sappend(&im.line, &e.next);
|
sappend(&im.pre, &e.next);
|
||||||
if(e.eat && e.dict.n > 0){
|
if(e.eat && e.dict.n > 0){
|
||||||
req.key = e.dict;
|
req.key = e.dict;
|
||||||
req.lang = im.l->lang;
|
req.lang = im.l->lang;
|
||||||
req.line = im.line;
|
req.pre = im.pre;
|
||||||
channbsend(dictreqc, &req);
|
channbsend(dictreqc, &req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ trans(Im *im, Rune c)
|
|||||||
Rune last;
|
Rune last;
|
||||||
|
|
||||||
h = im->l->map;
|
h = im->l->map;
|
||||||
key = im->line;
|
key = im->pre;
|
||||||
sputr(&key, c);
|
sputr(&key, c);
|
||||||
if(hmapget(h, &key)){
|
if(hmapget(h, &key)){
|
||||||
e.eat = 1;
|
e.eat = 1;
|
||||||
@ -134,11 +134,11 @@ trans(Im *im, Rune c)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
last = slastr(&im->line);
|
last = slastr(&im->pre);
|
||||||
if(last == 0)
|
if(last == 0)
|
||||||
goto flush;
|
goto flush;
|
||||||
|
|
||||||
key = im->line;
|
key = im->pre;
|
||||||
key.n--;
|
key.n--;
|
||||||
if(mapget(h, &key, &kana)){
|
if(mapget(h, &key, &kana)){
|
||||||
sclear(&key);
|
sclear(&key);
|
||||||
@ -155,7 +155,7 @@ trans(Im *im, Rune c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush:
|
flush:
|
||||||
mapget(h, &im->line, &e.s);
|
mapget(h, &im->pre, &e.s);
|
||||||
|
|
||||||
sclear(&key);
|
sclear(&key);
|
||||||
sputr(&key, c);
|
sputr(&key, c);
|
||||||
@ -174,7 +174,7 @@ flush:
|
|||||||
static void
|
static void
|
||||||
reset(void)
|
reset(void)
|
||||||
{
|
{
|
||||||
sclear(&im.line);
|
sclear(&im.pre);
|
||||||
clearkouho();
|
clearkouho();
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ keystroke(u32int ks, u32int mod, Str *com)
|
|||||||
reset();
|
reset();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(im.line.n > 0){
|
if(im.pre.n > 0){
|
||||||
commit(com);
|
commit(com);
|
||||||
reset();
|
reset();
|
||||||
return 1;
|
return 1;
|
||||||
@ -219,10 +219,10 @@ keystroke(u32int ks, u32int mod, Str *com)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(ks == Kback){
|
if(ks == Kback){
|
||||||
if(im.line.n == 0)
|
if(im.pre.n == 0)
|
||||||
return 0;
|
return 0;
|
||||||
spopr(&im.line);
|
spopr(&im.pre);
|
||||||
if(im.line.n == 0){
|
if(im.pre.n == 0){
|
||||||
reset();
|
reset();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ keystroke(u32int ks, u32int mod, Str *com)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(ks == Kesc){
|
if(ks == Kesc){
|
||||||
if(im.line.n == 0)
|
if(im.pre.n == 0)
|
||||||
return 0;
|
return 0;
|
||||||
reset();
|
reset();
|
||||||
return 1;
|
return 1;
|
||||||
@ -297,7 +297,7 @@ imthread(void*)
|
|||||||
write(kr.fd, out, n);
|
write(kr.fd, out, n);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if(scmp(&res.key, &im.line) == 0){
|
if(scmp(&res.key, &im.pre) == 0){
|
||||||
setkouho(&res);
|
setkouho(&res);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user