summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-07-06 10:07:03 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-07-06 10:07:03 +0000
commit9f5bd77418f676a8a53a8ce49cfea299ff8fa97d (patch)
tree57a7d0e717eaff435a326a328bef6c838f9d77ec /usr.bin
parenta8022757870d7033fd8a3a1f96c45815e32af713 (diff)
Do not eliminate redundant clears, the code is wrong and doing it
correctly wouldn't be worth it. GitHub issue 2298.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/screen-write.c63
1 files changed, 23 insertions, 40 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 2141aef4c01..8ebbea652db 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.185 2020/06/18 08:41:56 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.186 2020/07/06 10:07:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -25,10 +25,10 @@
static void screen_write_collect_clear(struct screen_write_ctx *, u_int,
u_int);
-static int screen_write_collect_clear_end(struct screen_write_ctx *, u_int,
+static void screen_write_collect_clear_end(struct screen_write_ctx *, u_int,
+ u_int);
+static void screen_write_collect_clear_start(struct screen_write_ctx *,
u_int, u_int);
-static int screen_write_collect_clear_start(struct screen_write_ctx *,
- u_int, 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 *);
@@ -1127,13 +1127,12 @@ screen_write_clearendofline(struct screen_write_ctx *ctx, u_int bg)
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1, bg);
- if (!screen_write_collect_clear_end(ctx, s->cy, s->cx, bg)) {
- ci->x = s->cx;
- ci->type = CLEAR_END;
- ci->bg = bg;
- TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry);
- ctx->item = xcalloc(1, sizeof *ctx->item);
- }
+ screen_write_collect_clear_end(ctx, s->cy, s->cx);
+ ci->x = s->cx;
+ ci->type = CLEAR_END;
+ ci->bg = bg;
+ TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry);
+ ctx->item = xcalloc(1, sizeof *ctx->item);
}
/* Clear to start of line from cursor. */
@@ -1154,13 +1153,12 @@ screen_write_clearstartofline(struct screen_write_ctx *ctx, u_int bg)
else
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg);
- if (!screen_write_collect_clear_start(ctx, s->cy, s->cx, bg)) {
- ci->x = s->cx;
- ci->type = CLEAR_START;
- ci->bg = bg;
- TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry);
- ctx->item = xcalloc(1, sizeof *ctx->item);
- }
+ screen_write_collect_clear_start(ctx, s->cy, s->cx);
+ ci->x = s->cx;
+ ci->type = CLEAR_START;
+ ci->bg = bg;
+ TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry);
+ ctx->item = xcalloc(1, sizeof *ctx->item);
}
/* Move cursor to px,py. */
@@ -1393,25 +1391,18 @@ screen_write_clearhistory(struct screen_write_ctx *ctx)
}
/* Clear to start of a collected line. */
-static int
-screen_write_collect_clear_start(struct screen_write_ctx *ctx, u_int y, u_int x,
- u_int bg)
+static void
+screen_write_collect_clear_start(struct screen_write_ctx *ctx, u_int y, u_int x)
{
struct screen_write_collect_item *ci, *tmp;
size_t size = 0;
u_int items = 0;
- int redundant = 0;
if (TAILQ_EMPTY(&ctx->s->write_list[y].items))
- return (0);
+ return;
TAILQ_FOREACH_SAFE(ci, &ctx->s->write_list[y].items, entry, tmp) {
switch (ci->type) {
case CLEAR_START:
- if (ci->x >= x) {
- if (ci->bg == bg)
- redundant = 1;
- continue;
- }
break;
case CLEAR_END:
if (ci->x <= x)
@@ -1430,21 +1421,18 @@ screen_write_collect_clear_start(struct screen_write_ctx *ctx, u_int y, u_int x,
ctx->skipped += size;
log_debug("%s: dropped %u items (%zu bytes) (line %u)", __func__, items,
size, y);
- return (redundant);
}
/* Clear to end of a collected line. */
-static int
-screen_write_collect_clear_end(struct screen_write_ctx *ctx, u_int y, u_int x,
- u_int bg)
+static void
+screen_write_collect_clear_end(struct screen_write_ctx *ctx, u_int y, u_int x)
{
struct screen_write_collect_item *ci, *tmp;
size_t size = 0;
- int redundant = 0;
u_int items = 0;
if (TAILQ_EMPTY(&ctx->s->write_list[y].items))
- return (0);
+ return;
TAILQ_FOREACH_SAFE(ci, &ctx->s->write_list[y].items, entry, tmp) {
switch (ci->type) {
case CLEAR_START:
@@ -1452,11 +1440,6 @@ screen_write_collect_clear_end(struct screen_write_ctx *ctx, u_int y, u_int x,
ci->x = x;
continue;
case CLEAR_END:
- if (ci->x <= x) {
- if (ci->bg == bg)
- redundant = 1;
- continue;
- }
break;
case TEXT:
if (ci->x < x)
@@ -1471,7 +1454,6 @@ screen_write_collect_clear_end(struct screen_write_ctx *ctx, u_int y, u_int x,
ctx->skipped += size;
log_debug("%s: dropped %u items (%zu bytes) (line %u)", __func__, items,
size, y);
- return (redundant);
}
/* Clear collected lines. */
@@ -1566,6 +1548,7 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only,
TAILQ_FOREACH_SAFE(ci, &cl->items, entry, tmp) {
screen_write_set_cursor(ctx, ci->x, y);
if (ci->type == CLEAR_END) {
+ log_debug("XXX %u %u", ci->x, ci->bg);
screen_write_initctx(ctx, &ttyctx, 1);
ttyctx.bg = ci->bg;
tty_write(tty_cmd_clearendofline, &ttyctx);