version 1.185, 2020/06/18 08:41:56 |
version 1.186, 2020/07/06 10:07:02 |
|
|
|
|
static void screen_write_collect_clear(struct screen_write_ctx *, u_int, |
static void screen_write_collect_clear(struct screen_write_ctx *, u_int, |
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); |
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_scroll(struct screen_write_ctx *); |
static void screen_write_collect_flush(struct screen_write_ctx *, int, |
static void screen_write_collect_flush(struct screen_write_ctx *, int, |
const char *); |
const char *); |
|
|
|
|
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1, 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)) { |
screen_write_collect_clear_end(ctx, s->cy, s->cx); |
ci->x = s->cx; |
ci->x = s->cx; |
ci->type = CLEAR_END; |
ci->type = CLEAR_END; |
ci->bg = bg; |
ci->bg = bg; |
TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry); |
TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry); |
ctx->item = xcalloc(1, sizeof *ctx->item); |
ctx->item = xcalloc(1, sizeof *ctx->item); |
} |
|
} |
} |
|
|
/* Clear to start of line from cursor. */ |
/* Clear to start of line from cursor. */ |
|
|
else |
else |
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg); |
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)) { |
screen_write_collect_clear_start(ctx, s->cy, s->cx); |
ci->x = s->cx; |
ci->x = s->cx; |
ci->type = CLEAR_START; |
ci->type = CLEAR_START; |
ci->bg = bg; |
ci->bg = bg; |
TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry); |
TAILQ_INSERT_TAIL(&ctx->s->write_list[s->cy].items, ci, entry); |
ctx->item = xcalloc(1, sizeof *ctx->item); |
ctx->item = xcalloc(1, sizeof *ctx->item); |
} |
|
} |
} |
|
|
/* Move cursor to px,py. */ |
/* Move cursor to px,py. */ |
|
|
} |
} |
|
|
/* Clear to start of a collected line. */ |
/* Clear to start of a collected line. */ |
static int |
static void |
screen_write_collect_clear_start(struct screen_write_ctx *ctx, u_int y, u_int x, |
screen_write_collect_clear_start(struct screen_write_ctx *ctx, u_int y, u_int x) |
u_int bg) |
|
{ |
{ |
struct screen_write_collect_item *ci, *tmp; |
struct screen_write_collect_item *ci, *tmp; |
size_t size = 0; |
size_t size = 0; |
u_int items = 0; |
u_int items = 0; |
int redundant = 0; |
|
|
|
if (TAILQ_EMPTY(&ctx->s->write_list[y].items)) |
if (TAILQ_EMPTY(&ctx->s->write_list[y].items)) |
return (0); |
return; |
TAILQ_FOREACH_SAFE(ci, &ctx->s->write_list[y].items, entry, tmp) { |
TAILQ_FOREACH_SAFE(ci, &ctx->s->write_list[y].items, entry, tmp) { |
switch (ci->type) { |
switch (ci->type) { |
case CLEAR_START: |
case CLEAR_START: |
if (ci->x >= x) { |
|
if (ci->bg == bg) |
|
redundant = 1; |
|
continue; |
|
} |
|
break; |
break; |
case CLEAR_END: |
case CLEAR_END: |
if (ci->x <= x) |
if (ci->x <= x) |
|
|
ctx->skipped += size; |
ctx->skipped += size; |
log_debug("%s: dropped %u items (%zu bytes) (line %u)", __func__, items, |
log_debug("%s: dropped %u items (%zu bytes) (line %u)", __func__, items, |
size, y); |
size, y); |
return (redundant); |
|
} |
} |
|
|
/* Clear to end of a collected line. */ |
/* Clear to end of a collected line. */ |
static int |
static void |
screen_write_collect_clear_end(struct screen_write_ctx *ctx, u_int y, u_int x, |
screen_write_collect_clear_end(struct screen_write_ctx *ctx, u_int y, u_int x) |
u_int bg) |
|
{ |
{ |
struct screen_write_collect_item *ci, *tmp; |
struct screen_write_collect_item *ci, *tmp; |
size_t size = 0; |
size_t size = 0; |
int redundant = 0; |
|
u_int items = 0; |
u_int items = 0; |
|
|
if (TAILQ_EMPTY(&ctx->s->write_list[y].items)) |
if (TAILQ_EMPTY(&ctx->s->write_list[y].items)) |
return (0); |
return; |
TAILQ_FOREACH_SAFE(ci, &ctx->s->write_list[y].items, entry, tmp) { |
TAILQ_FOREACH_SAFE(ci, &ctx->s->write_list[y].items, entry, tmp) { |
switch (ci->type) { |
switch (ci->type) { |
case CLEAR_START: |
case CLEAR_START: |
|
|
ci->x = x; |
ci->x = x; |
continue; |
continue; |
case CLEAR_END: |
case CLEAR_END: |
if (ci->x <= x) { |
|
if (ci->bg == bg) |
|
redundant = 1; |
|
continue; |
|
} |
|
break; |
break; |
case TEXT: |
case TEXT: |
if (ci->x < x) |
if (ci->x < x) |
|
|
ctx->skipped += size; |
ctx->skipped += size; |
log_debug("%s: dropped %u items (%zu bytes) (line %u)", __func__, items, |
log_debug("%s: dropped %u items (%zu bytes) (line %u)", __func__, items, |
size, y); |
size, y); |
return (redundant); |
|
} |
} |
|
|
/* Clear collected lines. */ |
/* Clear collected lines. */ |
|
|
TAILQ_FOREACH_SAFE(ci, &cl->items, entry, tmp) { |
TAILQ_FOREACH_SAFE(ci, &cl->items, entry, tmp) { |
screen_write_set_cursor(ctx, ci->x, y); |
screen_write_set_cursor(ctx, ci->x, y); |
if (ci->type == CLEAR_END) { |
if (ci->type == CLEAR_END) { |
|
log_debug("XXX %u %u", ci->x, ci->bg); |
screen_write_initctx(ctx, &ttyctx, 1); |
screen_write_initctx(ctx, &ttyctx, 1); |
ttyctx.bg = ci->bg; |
ttyctx.bg = ci->bg; |
tty_write(tty_cmd_clearendofline, &ttyctx); |
tty_write(tty_cmd_clearendofline, &ttyctx); |