diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-08-21 07:29:37 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-08-21 07:29:37 +0000 |
commit | 0198bb6bf3f1b3877ca8def6d198642a2a41d342 (patch) | |
tree | 8b47003e26a748df1fb1e98d8f78703d3c1a4b91 /grid.c | |
parent | 1501b3fbbdf405aae7dc996a60bd22a49c884110 (diff) | |
download | rtmux-0198bb6bf3f1b3877ca8def6d198642a2a41d342.tar.gz rtmux-0198bb6bf3f1b3877ca8def6d198642a2a41d342.tar.bz2 rtmux-0198bb6bf3f1b3877ca8def6d198642a2a41d342.zip |
Fix grid_expand_line so it actually works when the required size is bigger than
2 * the current size.
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -189,19 +189,22 @@ grid_scroll_line(struct grid *gd) /* Expand line to fit to cell. */ 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; - u_int xx; + u_int xx, sx; gl = &gd->linedata[py]; - if (sx <= gl->cellsize) + if (wantx <= gl->cellsize) return; if (gl->cellsize > gd->sx / 2) sx = gd->sx; - else - sx = 1 + gl->cellsize * 2; + else { + sx = gl->cellsize + 1; + while (sx < wantx) + sx *= 2; + } gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata); for (xx = gl->cellsize; xx < sx; xx++) grid_put_cell(gd, xx, py, &grid_default_cell); |