diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-09 22:48:21 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-09 22:48:21 +0000 |
commit | ed2c4cea39eb57cc57bc4270de882bc2a171531a (patch) | |
tree | fdaa53e01248abc7d6d0ca82533986a2682a807d /usr.bin/tmux/screen.c | |
parent | 2b856d134632dfdeff9ea4e7dca4d8958fb0f0bb (diff) |
When the terminal size is reduced horizontally, don't truncate lines to the new
width, so that if the same lines are later increased in size the content
reappears.
Diffstat (limited to 'usr.bin/tmux/screen.c')
-rw-r--r-- | usr.bin/tmux/screen.c | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c index 5cfdeb7e12e..a3077ae774e 100644 --- a/usr.bin/tmux/screen.c +++ b/usr.bin/tmux/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.6 2009/07/08 05:56:11 nicm Exp $ */ +/* $OpenBSD: screen.c,v 1.7 2009/07/09 22:48:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -122,44 +122,19 @@ void screen_resize_x(struct screen *s, u_int sx) { struct grid *gd = s->grid; - const struct grid_cell *gc; - const struct grid_utf8 *gu; - u_int xx, yy; if (sx == 0) fatalx("zero size"); - /* If getting larger, not much to do. */ - if (sx > screen_size_x(s)) { - gd->sx = sx; - return; - } - - /* If getting smaller, nuke any data in lines over the new size. */ - for (yy = gd->hsize; yy < gd->hsize + screen_size_y(s); yy++) { - /* - * If the character after the last is wide or padding, remove - * it and any leading padding. - */ - gc = &grid_default_cell; - for (xx = sx; xx > 0; xx--) { - gc = grid_peek_cell(gd, xx - 1, yy); - if (!(gc->flags & GRID_FLAG_PADDING)) - break; - grid_set_cell(gd, xx - 1, yy, &grid_default_cell); - } - if (xx > 0 && xx != sx && gc->flags & GRID_FLAG_UTF8) { - gu = grid_peek_utf8(gd, xx - 1, yy); - if (gu->width > 1) { - grid_set_cell( - gd, xx - 1, yy, &grid_default_cell); - } - } - - /* Reduce the line size. */ - grid_reduce_line(gd, yy, sx); - } - + /* + * Treat resizing horizontally simply: just ensure the cursor is + * on-screen and change the size. Don't bother to truncate any lines - + * then the data should be accessible if the size is then incrased. + * + * The only potential wrinkle is if UTF-8 double-width characters are + * left in the last column, but UTF-8 terminals should deal with this + * sanely. + */ if (s->cx >= sx) s->cx = sx - 1; gd->sx = sx; |