=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen.c,v retrieving revision 1.53 retrieving revision 1.54 diff -c -r1.53 -r1.54 *** src/usr.bin/tmux/screen.c 2019/01/15 09:56:31 1.53 --- src/usr.bin/tmux/screen.c 2019/03/20 19:19:11 1.54 *************** *** 1,4 **** ! /* $OpenBSD: screen.c,v 1.53 2019/01/15 09:56:31 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: screen.c,v 1.54 2019/03/20 19:19:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 48,54 **** }; TAILQ_HEAD(screen_titles, screen_title_entry); - static void screen_resize_x(struct screen *, u_int); static void screen_resize_y(struct screen *, u_int); static void screen_reflow(struct screen *, u_int); --- 48,53 ---- *************** *** 207,219 **** sy = 1; if (sx != screen_size_x(s)) { ! screen_resize_x(s, sx); ! ! /* ! * It is unclear what should happen to tabs on resize. xterm ! * seems to try and maintain them, rxvt resets them. Resetting ! * is simpler and more reliable so let's do that. ! */ screen_reset_tabs(s); } else reflow = 0; --- 206,212 ---- sy = 1; if (sx != screen_size_x(s)) { ! s->grid->sx = sx; screen_reset_tabs(s); } else reflow = 0; *************** *** 226,253 **** } static void - screen_resize_x(struct screen *s, u_int sx) - { - struct grid *gd = s->grid; - - if (sx == 0) - fatalx("zero size"); - - /* - * 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 increased. - * - * 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; - } - - static void screen_resize_y(struct screen *s, u_int sy) { struct grid *gd = s->grid; --- 219,224 ---- *************** *** 493,497 **** static void screen_reflow(struct screen *s, u_int new_x) { ! grid_reflow(s->grid, new_x, &s->cy); } --- 464,493 ---- static void screen_reflow(struct screen *s, u_int new_x) { ! u_int offset, cx = s->cx, cy = s->grid->hsize + s->cy; ! struct timeval start, tv; ! ! gettimeofday(&start, NULL); ! ! offset = grid_to_offset(s->grid, cx, cy); ! log_debug("%s: cursor %u,%u offset is %u", __func__, cx, cy, offset); ! ! grid_reflow(s->grid, new_x); ! ! grid_from_offset(s->grid, offset, &cx, &cy); ! log_debug("%s: new cursor is %u,%u", __func__, cx, cy); ! ! if (cy >= s->grid->hsize) { ! s->cx = cx; ! s->cy = cy - s->grid->hsize; ! } else { ! s->cx = 0; ! s->cy = 0; ! } ! ! gettimeofday(&tv, NULL); ! timersub(&tv, &start, &tv); ! ! log_debug("%s: reflow took %llu.%06u seconds", __func__, ! (unsigned long long)tv.tv_sec, (u_int)tv.tv_usec); }