=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.87 retrieving revision 1.88 diff -c -r1.87 -r1.88 *** src/usr.bin/tmux/tty.c 2010/06/05 16:32:22 1.87 --- src/usr.bin/tmux/tty.c 2010/06/05 16:47:11 1.88 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.87 2010/06/05 16:32:22 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.88 2010/06/05 16:47:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 73,106 **** tty->term_flags = 0; } ! void tty_resize(struct tty *tty) { struct winsize ws; if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) { ! tty->sx = ws.ws_col; ! tty->sy = ws.ws_row; } ! if (tty->sx == 0) ! tty->sx = 80; ! if (tty->sy == 0) ! tty->sy = 24; tty->cx = UINT_MAX; tty->cy = UINT_MAX; tty->rupper = UINT_MAX; tty->rlower = UINT_MAX; } int tty_open(struct tty *tty, const char *overrides, char **cause) { int fd; if (debug_level > 3) { ! fd = open("tmux.out", O_WRONLY|O_CREAT|O_TRUNC, 0644); if (fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) fatal("fcntl failed"); tty->log_fd = fd; --- 73,127 ---- tty->term_flags = 0; } ! int tty_resize(struct tty *tty) { struct winsize ws; + u_int sx, sy; if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) { ! sx = ws.ws_col; ! if (sx == 0) ! sx = 80; ! sy = ws.ws_row; ! if (sy == 0) ! sy = 24; ! } else { ! sx = 80; ! sy = 24; } ! if (sx == tty->sx && sy == tty->sy) ! return (0); ! tty->sx = sx; ! tty->sy = sy; tty->cx = UINT_MAX; tty->cy = UINT_MAX; tty->rupper = UINT_MAX; tty->rlower = UINT_MAX; + + /* + * If the terminal has been started, reset the actual scroll region and + * cursor position, as this may not have happened. + */ + if (tty->flags & TTY_STARTED) { + tty_cursor(tty, 0, 0); + tty_region(tty, 0, tty->sy - 1); + } + + return (1); } int tty_open(struct tty *tty, const char *overrides, char **cause) { + char out[64]; int fd; if (debug_level > 3) { ! xsnprintf(out, sizeof out, "tmux-out-%ld.log", (long) getpid()); ! fd = open(out, O_WRONLY|O_CREAT|O_TRUNC, 0644); if (fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) fatal("fcntl failed"); tty->log_fd = fd;