popup: stabilize the input panel width
This commit is contained in:
@@ -44,9 +44,8 @@ void
|
||||
popuplayout(Drawcmd *dc, int screenw, Popup *p)
|
||||
{
|
||||
char buf[32];
|
||||
vlong width;
|
||||
Str mark;
|
||||
int i, maxw, nmark, npre, roww, y;
|
||||
int nmark, npre, y;
|
||||
|
||||
memset(p, 0, sizeof *p);
|
||||
p->prey = -1;
|
||||
@@ -60,19 +59,8 @@ popuplayout(Drawcmd *dc, int screenw, Popup *p)
|
||||
if(p->n == 0 && !npre)
|
||||
return;
|
||||
|
||||
maxw = npre ? textwidth(&dc->pre) : 0;
|
||||
roww = 0;
|
||||
for(i = 0; i < p->n; i++)
|
||||
roww = max(roww, textwidth(&dc->kouho[i]));
|
||||
if(p->n != 0)
|
||||
maxw = max(maxw, PopupNumw + roww);
|
||||
p->w = min(Imgw, max(screenw, 0));
|
||||
nmark = pagemarker(buf, sizeof buf, dc->first, p->n, dc->total);
|
||||
if(nmark != 0){
|
||||
sinit(&mark, buf, nmark);
|
||||
maxw = max(maxw, textwidth(&mark));
|
||||
}
|
||||
width = (vlong)maxw + 2*PopupPad;
|
||||
p->w = min(min(max(width, 1), Imgw), max(screenw, 0));
|
||||
|
||||
y = PopupPad;
|
||||
if(npre){
|
||||
@@ -96,6 +84,7 @@ popuplayout(Drawcmd *dc, int screenw, Popup *p)
|
||||
p->textx = PopupPad + PopupNumw;
|
||||
p->textw = max(p->w - PopupPad - p->textx, 0);
|
||||
if(nmark != 0){
|
||||
sinit(&mark, buf, nmark);
|
||||
p->markw = min(textwidth(&mark), max(p->w - 2*PopupPad, 0));
|
||||
p->markx = p->w - PopupPad - p->markw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user