=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-write.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- src/usr.bin/tmux/screen-write.c 2011/01/03 23:35:21 1.45 +++ src/usr.bin/tmux/screen-write.c 2011/01/25 23:40:26 1.46 @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.45 2011/01/03 23:35:21 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.46 2011/01/25 23:40:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -931,9 +931,14 @@ sx = screen_size_x(s); sy = screen_size_y(s); - if (s->cx <= sx - 1) - grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1); - grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1)); + /* Scroll into history if it is enabled and clearing entire screen. */ + if (s->cy == 0 && s->grid->flags & GRID_HISTORY) + grid_view_clear_history(s->grid); + else { + if (s->cx <= sx - 1) + grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1); + grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1)); + } tty_write(tty_cmd_clearendofscreen, &ttyctx); } @@ -969,7 +974,13 @@ screen_write_initctx(ctx, &ttyctx, 0); - grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s)); + /* Scroll into history if it is enabled. */ + if (s->grid->flags & GRID_HISTORY) + grid_view_clear_history(s->grid); + else { + grid_view_clear( + s->grid, 0, 0, screen_size_x(s), screen_size_y(s)); + } tty_write(tty_cmd_clearscreen, &ttyctx); }