diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-21 07:29:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-21 07:29:38 +0000 |
commit | f52b9cd281109616d44e2faad2f7cf5e0472f681 (patch) | |
tree | 068f84bd462f84e2452129121f66fa98c61360c1 | |
parent | 4ce8f7bfaf7082d8a9ee99d0839ed5fb1d17bee3 (diff) |
Fix grid_expand_line so it actually works when the required size is bigger than
2 * the current size.
-rw-r--r-- | usr.bin/tmux/grid.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 960b2e6788e..25f6acb0f56 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.12 2009/08/20 19:14:42 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.13 2009/08/21 07:29:37 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); |