rename line => pre

This commit is contained in:
Hojun-Cho 2025-12-28 12:26:28 +09:00
parent 8a2ef65379
commit e5ce5fd61e
4 changed files with 28 additions and 28 deletions

4
dat.h
View File

@ -85,7 +85,7 @@ struct Lang
struct Im
{
Lang *l;
Str line;
Str pre;
Str kouho[Maxkouho];
int nkouho;
int sel;
@ -112,7 +112,7 @@ typedef struct Dictreq Dictreq;
struct Dictreq
{
Str key;
Str line;
Str pre;
int lang;
};

2
dict.c
View File

@ -47,7 +47,7 @@ dictthread(void*)
while(channbrecv(dictreqc, &req) > 0)
;
dictlkup(&req, &res);
res.key = req.line;
res.key = req.pre;
chansend(dictresc, &res);
}
}

12
jp.c
View File

@ -13,7 +13,7 @@ jptrans(Im *im, Rune c)
memset(&e, 0, sizeof(e));
h = im->l->map;
hira = (im->l->lang == LangJP);
key = im->line;
key = im->pre;
sputr(&key, c);
if(hmapget(h, &key)){
e.eat = 1;
@ -21,10 +21,10 @@ jptrans(Im *im, Rune c)
mapget(h, &key, &e.dict);
return e;
}
last = slastr(&im->line);
last = slastr(&im->pre);
if(last == 0)
goto flush;
key = im->line;
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
sclear(&key);
@ -40,7 +40,7 @@ jptrans(Im *im, Rune c)
}
}
if(c == 'n' && last == 'n'){
key = im->line;
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
e.eat = 1;
@ -52,7 +52,7 @@ jptrans(Im *im, Rune c)
}
}
if(c == last && strchr("kgsztdbpmjfchryw", c)){
key = im->line;
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
e.eat = 1;
@ -65,7 +65,7 @@ jptrans(Im *im, Rune c)
}
flush:
mapget(h, &im->line, &e.s);
mapget(h, &im->pre, &e.s);
sclear(&key);
sputr(&key, c);
if(hmapget(h, &key) == nil){

View File

@ -36,7 +36,7 @@ show(void)
int i;
sclear(&dc.preedit);
mapget(im.l->map, &im.line, &dc.preedit);
mapget(im.l->map, &im.pre, &dc.preedit);
dc.nkouho = im.nkouho;
dc.sel = im.sel;
for(i = 0; i < dc.nkouho; i++)
@ -50,14 +50,14 @@ dictq(void)
Str dict;
Dictreq req;
if(!mapget(im.l->map, &im.line, &dict)){
if(!mapget(im.l->map, &im.pre, &dict)){
clearkouho();
show();
return;
}
req.key = dict;
req.lang = im.l->lang;
req.line = im.line;
req.pre = im.pre;
channbsend(dictreqc, &req);
}
@ -78,9 +78,9 @@ commit(Str *com)
{
Str kana;
if(mapget(im.l->map, &im.line, &kana))
if(mapget(im.l->map, &im.pre, &kana))
sappend(com, &kana);
sclear(&im.line);
sclear(&im.pre);
}
static int
@ -93,12 +93,12 @@ dotrans(Rune c, Str *com)
if(e.s.n > 0)
sappend(com, &e.s);
sclear(&im.line);
sappend(&im.line, &e.next);
sclear(&im.pre);
sappend(&im.pre, &e.next);
if(e.eat && e.dict.n > 0){
req.key = e.dict;
req.lang = im.l->lang;
req.line = im.line;
req.pre = im.pre;
channbsend(dictreqc, &req);
}
@ -125,7 +125,7 @@ trans(Im *im, Rune c)
Rune last;
h = im->l->map;
key = im->line;
key = im->pre;
sputr(&key, c);
if(hmapget(h, &key)){
e.eat = 1;
@ -134,11 +134,11 @@ trans(Im *im, Rune c)
return e;
}
last = slastr(&im->line);
last = slastr(&im->pre);
if(last == 0)
goto flush;
key = im->line;
key = im->pre;
key.n--;
if(mapget(h, &key, &kana)){
sclear(&key);
@ -155,7 +155,7 @@ trans(Im *im, Rune c)
}
flush:
mapget(h, &im->line, &e.s);
mapget(h, &im->pre, &e.s);
sclear(&key);
sputr(&key, c);
@ -174,7 +174,7 @@ flush:
static void
reset(void)
{
sclear(&im.line);
sclear(&im.pre);
clearkouho();
show();
}
@ -211,7 +211,7 @@ keystroke(u32int ks, u32int mod, Str *com)
reset();
return 1;
}
if(im.line.n > 0){
if(im.pre.n > 0){
commit(com);
reset();
return 1;
@ -219,10 +219,10 @@ keystroke(u32int ks, u32int mod, Str *com)
return 0;
}
if(ks == Kback){
if(im.line.n == 0)
if(im.pre.n == 0)
return 0;
spopr(&im.line);
if(im.line.n == 0){
spopr(&im.pre);
if(im.pre.n == 0){
reset();
return 1;
}
@ -230,7 +230,7 @@ keystroke(u32int ks, u32int mod, Str *com)
return 1;
}
if(ks == Kesc){
if(im.line.n == 0)
if(im.pre.n == 0)
return 0;
reset();
return 1;
@ -297,7 +297,7 @@ imthread(void*)
write(kr.fd, out, n);
break;
case 1:
if(scmp(&res.key, &im.line) == 0){
if(scmp(&res.key, &im.pre) == 0){
setkouho(&res);
show();
}