mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Fix grid_expand_line so it actually works when the required size is bigger than
2 * the current size.
This commit is contained in:
parent
1501b3fbbd
commit
0198bb6bf3
13
grid.c
13
grid.c
@ -189,19 +189,22 @@ grid_scroll_line(struct grid *gd)
|
|||||||
|
|
||||||
/* Expand line to fit to cell. */
|
/* Expand line to fit to cell. */
|
||||||
void
|
void
|
||||||
grid_expand_line(struct grid *gd, u_int py, u_int sx)
|
grid_expand_line(struct grid *gd, u_int py, u_int wantx)
|
||||||
{
|
{
|
||||||
struct grid_line *gl;
|
struct grid_line *gl;
|
||||||
u_int xx;
|
u_int xx, sx;
|
||||||
|
|
||||||
gl = &gd->linedata[py];
|
gl = &gd->linedata[py];
|
||||||
if (sx <= gl->cellsize)
|
if (wantx <= gl->cellsize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gl->cellsize > gd->sx / 2)
|
if (gl->cellsize > gd->sx / 2)
|
||||||
sx = gd->sx;
|
sx = gd->sx;
|
||||||
else
|
else {
|
||||||
sx = 1 + gl->cellsize * 2;
|
sx = gl->cellsize + 1;
|
||||||
|
while (sx < wantx)
|
||||||
|
sx *= 2;
|
||||||
|
}
|
||||||
gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata);
|
gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata);
|
||||||
for (xx = gl->cellsize; xx < sx; xx++)
|
for (xx = gl->cellsize; xx < sx; xx++)
|
||||||
grid_put_cell(gd, xx, py, &grid_default_cell);
|
grid_put_cell(gd, xx, py, &grid_default_cell);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user