popup: stabilize the input panel width

This commit is contained in:
2026-08-14 21:13:49 +09:00
parent f222b4d573
commit 0471d58dec
3 changed files with 22 additions and 22 deletions

View File

@@ -69,6 +69,8 @@ popup_layout(struct ct *t)
CT_EQ_INT(t, strlen(markers[i].want), n);
CT_CHECK(t, strcmp(markers[i].want, buf) == 0);
}
CT_EQ_INT(t, 12*Fontsz, PopupTextw);
CT_EQ_INT(t, 2*PopupPad + PopupNumw + PopupTextw, Imgw);
CT_EQ_INT(t, 2*PopupPad + (1 + Maxdisp + 1)*Fontsz + PopupSep,
Imgh);
@@ -137,7 +139,8 @@ popup_layout(struct ct *t)
/* Preedit only. */
dc.pre = mkstr("preedit");
popuplayout(&dc, Imgw, &p);
popuplayout(&dc, 2*Imgw, &p);
CT_EQ_INT(t, Imgw, p.w);
CT_EQ_INT(t, PopupPad, p.prey);
CT_EQ_INT(t, -1, p.sepy);
CT_EQ_INT(t, -1, p.rowsy);
@@ -150,7 +153,8 @@ popup_layout(struct ct *t)
dc.nkouho = 2;
dc.kouho[0] = mkstr("short");
dc.kouho[1] = mkstr("candidate");
popuplayout(&dc, Imgw, &p);
popuplayout(&dc, 2*Imgw, &p);
CT_EQ_INT(t, Imgw, p.w);
CT_EQ_INT(t, -1, p.prey);
CT_EQ_INT(t, -1, p.sepy);
CT_EQ_INT(t, PopupPad, p.rowsy);
@@ -158,11 +162,13 @@ popup_layout(struct ct *t)
CT_EQ_INT(t, 2*PopupPad + 2*Fontsz, p.h);
CT_EQ_INT(t, PopupPad, p.numx);
CT_EQ_INT(t, p.numx + PopupNumw, p.textx);
CT_EQ_INT(t, PopupTextw, p.textw);
CT_EQ_INT(t, p.w - PopupPad, p.textx + p.textw);
/* Preedit and candidates meet at one separator, with no empty rows. */
dc.pre = mkstr("preedit");
popuplayout(&dc, Imgw, &p);
popuplayout(&dc, 2*Imgw, &p);
CT_EQ_INT(t, Imgw, p.w);
CT_EQ_INT(t, PopupPad, p.prey);
CT_EQ_INT(t, p.prey + Fontsz, p.sepy);
CT_EQ_INT(t, p.sepy + PopupSep, p.rowsy);
@@ -183,7 +189,7 @@ popup_layout(struct ct *t)
for(i = 0; i < Maxdisp; i++)
dc.kouho[i] = mkstr(i == dc.sel ? "M" : "candidate");
dc.kouho[0] = longrow;
popuplayout(&dc, Imgw, &p);
popuplayout(&dc, 2*Imgw, &p);
CT_EQ_INT(t, Maxdisp, p.n);
CT_EQ_INT(t, PopupPad, p.prey);
CT_EQ_INT(t, p.prey + Fontsz, p.sepy);
@@ -191,8 +197,7 @@ popup_layout(struct ct *t)
CT_EQ_INT(t, p.rowsy + Maxdisp*Fontsz, p.marky);
CT_EQ_INT(t, p.marky + Fontsz + PopupPad, p.h);
CT_EQ_INT(t, Imgh, p.h);
CT_CHECK(t, p.w > 2*PopupPad + PopupNumw);
CT_CHECK(t, p.w <= Imgw);
CT_EQ_INT(t, Imgw, p.w);
CT_CHECK(t, p.h <= Imgh);
CT_EQ_INT(t, p.w - PopupPad, p.markx + p.markw);
CT_EQ_INT(t, PopupPad, p.selx);
@@ -255,7 +260,9 @@ popup_layout(struct ct *t)
dc.nkouho = 1;
dc.kouho[0] = longrow;
n = textwidth(&longrow);
popuplayout(&dc, 6*Fontsz, &p);
popuplayout(&dc, 2*Imgw, &p);
CT_EQ_INT(t, Imgw, p.w);
CT_EQ_INT(t, PopupTextw, p.textw);
CT_CHECK(t, n > p.textw);
CT_EQ_INT(t, PopupPad, p.rowsy);
CT_EQ_INT(t, p.w - PopupPad, p.textx + p.textw);
@@ -273,5 +280,8 @@ popup_layout(struct ct *t)
}
CT_CHECK(t, ink > 0);
CT_EQ_INT(t, n, textwidth(&longrow));
popuplayout(&dc, Imgw - 1, &p);
CT_EQ_INT(t, Imgw - 1, p.w);
free(img);
}