=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.314 retrieving revision 1.315 diff -c -r1.314 -r1.315 *** src/usr.bin/tmux/tty.c 2019/03/04 09:29:40 1.314 --- src/usr.bin/tmux/tty.c 2019/03/12 23:21:45 1.315 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.314 2019/03/04 09:29:40 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.315 2019/03/12 23:21:45 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 1208,1214 **** u_int i, j, ux, sx, width; int flags, cleared = 0; char buf[512]; ! size_t len, old_len; u_int cellsize; log_debug("%s: px=%u py=%u nx=%u atx=%u aty=%u", __func__, --- 1208,1214 ---- u_int i, j, ux, sx, width; int flags, cleared = 0; char buf[512]; ! size_t len; u_int cellsize; log_debug("%s: px=%u py=%u nx=%u atx=%u aty=%u", __func__, *************** *** 1263,1270 **** tty_putcode(tty, TTYC_EL1); cleared = 1; } - if (px + sx != 0) - tty_cursor(tty, atx, aty); } else log_debug("%s: wrapped line %u", __func__, aty); --- 1263,1268 ---- *************** *** 1281,1290 **** gcp->attr != last.attr || gcp->fg != last.fg || gcp->bg != last.bg || ! ux + width + gcp->data.width >= nx || (sizeof buf) - len < gcp->data.size)) { ! tty_attributes(tty, &last, wp); ! tty_putn(tty, buf, len, width); ux += width; len = 0; --- 1279,1295 ---- gcp->attr != last.attr || gcp->fg != last.fg || gcp->bg != last.bg || ! ux + width + gcp->data.width > nx || (sizeof buf) - len < gcp->data.size)) { ! if (last.flags & GRID_FLAG_CLEARED) { ! log_debug("%s: %zu cleared", __func__, len); ! tty_clear_line(tty, wp, aty, atx + ux, width, ! last.bg); ! } else { ! tty_attributes(tty, &last, wp); ! tty_cursor(tty, atx + ux, aty); ! tty_putn(tty, buf, len, width); ! } ux += width; len = 0; *************** *** 1297,1302 **** --- 1302,1308 ---- memcpy(&last, gcp, sizeof last); if (ux + gcp->data.width > nx) { tty_attributes(tty, &last, wp); + tty_cursor(tty, atx + ux, aty); for (j = 0; j < gcp->data.width; j++) { if (ux + j > nx) break; *************** *** 1305,1310 **** --- 1311,1317 ---- } } else if (gcp->attr & GRID_ATTR_CHARSET) { tty_attributes(tty, &last, wp); + tty_cursor(tty, atx + ux, aty); for (j = 0; j < gcp->data.size; j++) tty_putc(tty, gcp->data.data[j]); ux += gc.data.width; *************** *** 1314,1337 **** width += gcp->data.width; } } ! if (len != 0) { ! if (grid_cells_equal(&last, &grid_default_cell)) { ! old_len = len; ! while (len > 0 && buf[len - 1] == ' ') { ! len--; ! width--; ! } ! log_debug("%s: trimmed %zu spaces", __func__, ! old_len - len); ! } ! if (len != 0) { tty_attributes(tty, &last, wp); tty_putn(tty, buf, len, width); - ux += width; } } if (!cleared && ux < nx) { tty_default_attributes(tty, wp, 8); tty_clear_line(tty, wp, aty, atx + ux, nx - ux, 8); } --- 1321,1341 ---- width += gcp->data.width; } } ! if (len != 0 && ((~last.flags & GRID_FLAG_CLEARED) || last.bg != 8)) { ! if (last.flags & GRID_FLAG_CLEARED) { ! log_debug("%s: %zu cleared (end)", __func__, len); ! tty_clear_line(tty, wp, aty, atx + ux, width, last.bg); ! } else { tty_attributes(tty, &last, wp); + tty_cursor(tty, atx + ux, aty); tty_putn(tty, buf, len, width); } + ux += width; } if (!cleared && ux < nx) { + log_debug("%s: %u to end of line (%zu cleared)", __func__, + nx - ux, len); tty_default_attributes(tty, wp, 8); tty_clear_line(tty, wp, aty, atx + ux, nx - ux, 8); }