=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-write.c,v retrieving revision 1.163 retrieving revision 1.164 diff -c -r1.163 -r1.164 *** src/usr.bin/tmux/screen-write.c 2020/04/16 16:13:56 1.163 --- src/usr.bin/tmux/screen-write.c 2020/04/16 17:24:28 1.164 *************** *** 1,4 **** ! /* $OpenBSD: screen-write.c,v 1.163 2020/04/16 16:13:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: screen-write.c,v 1.164 2020/04/16 17:24:28 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 26,32 **** static void screen_write_collect_clear(struct screen_write_ctx *, u_int, u_int); static void screen_write_collect_scroll(struct screen_write_ctx *); ! static void screen_write_collect_flush(struct screen_write_ctx *, int); static int screen_write_overwrite(struct screen_write_ctx *, struct grid_cell *, u_int); --- 26,33 ---- static void screen_write_collect_clear(struct screen_write_ctx *, u_int, u_int); static void screen_write_collect_scroll(struct screen_write_ctx *); ! static void screen_write_collect_flush(struct screen_write_ctx *, int, ! const char *); static int screen_write_overwrite(struct screen_write_ctx *, struct grid_cell *, u_int); *************** *** 160,166 **** struct tty_ctx ttyctx; screen_write_collect_end(ctx); ! screen_write_collect_flush(ctx, 0); log_debug("%s: %u cells (%u written, %u skipped)", __func__, ctx->cells, ctx->written, ctx->skipped); --- 161,167 ---- struct tty_ctx ttyctx; screen_write_collect_end(ctx); ! screen_write_collect_flush(ctx, 0, __func__); log_debug("%s: %u cells (%u written, %u skipped)", __func__, ctx->cells, ctx->written, ctx->skipped); *************** *** 765,771 **** grid_view_insert_cells(s->grid, s->cx, s->cy, nx, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = nx; tty_write(tty_cmd_insertcharacter, &ttyctx); } --- 766,772 ---- grid_view_insert_cells(s->grid, s->cx, s->cy, nx, bg); ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = nx; tty_write(tty_cmd_insertcharacter, &ttyctx); } *************** *** 793,799 **** grid_view_delete_cells(s->grid, s->cx, s->cy, nx, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = nx; tty_write(tty_cmd_deletecharacter, &ttyctx); } --- 794,800 ---- grid_view_delete_cells(s->grid, s->cx, s->cy, nx, bg); ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = nx; tty_write(tty_cmd_deletecharacter, &ttyctx); } *************** *** 821,827 **** grid_view_clear(s->grid, s->cx, s->cy, nx, 1, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = nx; tty_write(tty_cmd_clearcharacter, &ttyctx); } --- 822,828 ---- grid_view_clear(s->grid, s->cx, s->cy, nx, 1, bg); ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = nx; tty_write(tty_cmd_clearcharacter, &ttyctx); } *************** *** 848,854 **** grid_view_insert_lines(gd, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = ny; tty_write(tty_cmd_insertline, &ttyctx); return; --- 849,855 ---- grid_view_insert_lines(gd, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = ny; tty_write(tty_cmd_insertline, &ttyctx); return; *************** *** 867,873 **** else grid_view_insert_lines_region(gd, s->rlower, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = ny; tty_write(tty_cmd_insertline, &ttyctx); } --- 868,875 ---- else grid_view_insert_lines_region(gd, s->rlower, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0, __func__); ! ttyctx.num = ny; tty_write(tty_cmd_insertline, &ttyctx); } *************** *** 894,900 **** grid_view_delete_lines(gd, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = ny; tty_write(tty_cmd_deleteline, &ttyctx); return; --- 896,902 ---- grid_view_delete_lines(gd, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = ny; tty_write(tty_cmd_deleteline, &ttyctx); return; *************** *** 913,919 **** else grid_view_delete_lines_region(gd, s->rlower, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = ny; tty_write(tty_cmd_deleteline, &ttyctx); } --- 915,921 ---- else grid_view_delete_lines_region(gd, s->rlower, s->cy, ny, bg); ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = ny; tty_write(tty_cmd_deleteline, &ttyctx); } *************** *** 937,943 **** grid_view_clear(s->grid, 0, s->cy, sx, 1, bg); screen_write_collect_clear(ctx, s->cy, 1); ! screen_write_collect_flush(ctx, 0); tty_write(tty_cmd_clearline, &ttyctx); } --- 939,945 ---- grid_view_clear(s->grid, 0, s->cy, sx, 1, bg); screen_write_collect_clear(ctx, s->cy, 1); ! screen_write_collect_flush(ctx, 0, __func__); tty_write(tty_cmd_clearline, &ttyctx); } *************** *** 961,967 **** if (s->cx == 0) screen_write_collect_clear(ctx, s->cy, 1); ! screen_write_collect_flush(ctx, 0); tty_write(tty_cmd_clearendofline, &ttyctx); } --- 963,969 ---- if (s->cx == 0) screen_write_collect_clear(ctx, s->cy, 1); ! screen_write_collect_flush(ctx, 0, __func__); tty_write(tty_cmd_clearendofline, &ttyctx); } *************** *** 983,989 **** if (s->cx > sx - 1) screen_write_collect_clear(ctx, s->cy, 1); ! screen_write_collect_flush(ctx, 0); tty_write(tty_cmd_clearstartofline, &ttyctx); } --- 985,991 ---- if (s->cx > sx - 1) screen_write_collect_clear(ctx, s->cy, 1); ! screen_write_collect_flush(ctx, 0, __func__); tty_write(tty_cmd_clearstartofline, &ttyctx); } *************** *** 1024,1030 **** else if (s->cy > 0) screen_write_set_cursor(ctx, -1, s->cy - 1); ! screen_write_collect_flush(ctx, 0); tty_write(tty_cmd_reverseindex, &ttyctx); } --- 1026,1032 ---- else if (s->cy > 0) screen_write_set_cursor(ctx, -1, s->cy - 1); ! screen_write_collect_flush(ctx, 0, __func__); tty_write(tty_cmd_reverseindex, &ttyctx); } *************** *** 1042,1048 **** if (rupper >= rlower) /* cannot be one line */ return; ! screen_write_collect_flush(ctx, 0); /* Cursor moves to top-left. */ screen_write_set_cursor(ctx, 0, 0); --- 1044,1050 ---- if (rupper >= rlower) /* cannot be one line */ return; ! screen_write_collect_flush(ctx, 0, __func__); /* Cursor moves to top-left. */ screen_write_set_cursor(ctx, 0, 0); *************** *** 1069,1075 **** s->rupper, s->rlower); if (bg != ctx->bg) { ! screen_write_collect_flush(ctx, 1); ctx->bg = bg; } --- 1071,1077 ---- s->rupper, s->rlower); if (bg != ctx->bg) { ! screen_write_collect_flush(ctx, 1, __func__); ctx->bg = bg; } *************** *** 1095,1101 **** lines = s->rlower - s->rupper + 1; if (bg != ctx->bg) { ! screen_write_collect_flush(ctx, 1); ctx->bg = bg; } --- 1097,1103 ---- lines = s->rlower - s->rupper + 1; if (bg != ctx->bg) { ! screen_write_collect_flush(ctx, 1, __func__); ctx->bg = bg; } *************** *** 1126,1132 **** for (i = 0; i < lines; i++) grid_view_scroll_region_down(gd, s->rupper, s->rlower, bg); ! screen_write_collect_flush(ctx, 0); ttyctx.num = lines; tty_write(tty_cmd_scrolldown, &ttyctx); } --- 1128,1134 ---- for (i = 0; i < lines; i++) grid_view_scroll_region_down(gd, s->rupper, s->rlower, bg); ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = lines; tty_write(tty_cmd_scrolldown, &ttyctx); } *************** *** 1160,1166 **** } screen_write_collect_clear(ctx, s->cy + 1, sy - (s->cy + 1)); ! screen_write_collect_flush(ctx, 0); tty_write(tty_cmd_clearendofscreen, &ttyctx); } --- 1162,1168 ---- } screen_write_collect_clear(ctx, s->cy + 1, sy - (s->cy + 1)); ! screen_write_collect_flush(ctx, 0, __func__); tty_write(tty_cmd_clearendofscreen, &ttyctx); } *************** *** 1183,1189 **** grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg); screen_write_collect_clear(ctx, 0, s->cy); ! screen_write_collect_flush(ctx, 0); tty_write(tty_cmd_clearstartofscreen, &ttyctx); } --- 1185,1191 ---- grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg); screen_write_collect_clear(ctx, 0, s->cy); ! screen_write_collect_flush(ctx, 0, __func__); tty_write(tty_cmd_clearstartofscreen, &ttyctx); } *************** *** 1257,1263 **** /* Flush collected lines. */ static void ! screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only) { struct screen *s = ctx->s; struct screen_write_collect_item *ci, *tmp; --- 1259,1266 ---- /* Flush collected lines. */ static void ! screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only, ! const char *from) { struct screen *s = ctx->s; struct screen_write_collect_item *ci, *tmp; *************** *** 1302,1308 **** } s->cx = cx; s->cy = cy; ! log_debug("%s: flushed %u items (%zu bytes)", __func__, items, written); ctx->written += written; } --- 1305,1312 ---- } s->cx = cx; s->cy = cy; ! log_debug("%s: flushed %u items (%zu bytes) (%s)", __func__, items, ! written, from); ctx->written += written; } *************** *** 1380,1386 **** collect = 0; if (!collect) { screen_write_collect_end(ctx); ! screen_write_collect_flush(ctx, 0); screen_write_cell(ctx, gc); return; } --- 1384,1390 ---- collect = 0; if (!collect) { screen_write_collect_end(ctx); ! screen_write_collect_flush(ctx, 0, __func__); screen_write_cell(ctx, gc); return; } *************** *** 1425,1431 **** /* If the width is zero, combine onto the previous character. */ if (width == 0) { ! screen_write_collect_flush(ctx, 0); if ((gc = screen_write_combine(ctx, &gc->data, &xx)) != 0) { cx = s->cx; cy = s->cy; screen_write_set_cursor(ctx, xx, s->cy); --- 1429,1435 ---- /* If the width is zero, combine onto the previous character. */ if (width == 0) { ! screen_write_collect_flush(ctx, 0, __func__); if ((gc = screen_write_combine(ctx, &gc->data, &xx)) != 0) { cx = s->cx; cy = s->cy; screen_write_set_cursor(ctx, xx, s->cy); *************** *** 1438,1444 **** } /* Flush any existing scrolling. */ ! screen_write_collect_flush(ctx, 1); /* If this character doesn't fit, ignore it. */ if ((~s->mode & MODE_WRAP) && --- 1442,1448 ---- } /* Flush any existing scrolling. */ ! screen_write_collect_flush(ctx, 1, __func__); /* If this character doesn't fit, ignore it. */ if ((~s->mode & MODE_WRAP) && *************** *** 1457,1463 **** log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy); screen_write_linefeed(ctx, 1, 8); screen_write_set_cursor(ctx, 0, -1); ! screen_write_collect_flush(ctx, 1); } /* Sanity check cursor position. */ --- 1461,1467 ---- log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy); screen_write_linefeed(ctx, 1, 8); screen_write_set_cursor(ctx, 0, -1); ! screen_write_collect_flush(ctx, 1, __func__); } /* Sanity check cursor position. */ *************** *** 1535,1541 **** /* Create space for character in insert mode. */ if (s->mode & MODE_INSERT) { ! screen_write_collect_flush(ctx, 0); ttyctx.num = width; tty_write(tty_cmd_insertcharacter, &ttyctx); } --- 1539,1545 ---- /* Create space for character in insert mode. */ if (s->mode & MODE_INSERT) { ! screen_write_collect_flush(ctx, 0, __func__); ttyctx.num = width; tty_write(tty_cmd_insertcharacter, &ttyctx); }