Fix placeholder label and clean up.

topcat001 2023-08-20 15:46:59 -07:00
parent 5896ac52a1
commit e6322b4196
4 changed files with 25 additions and 15 deletions

36
image.c
View File

@ -58,26 +58,38 @@ image_fallback(char **ret, u_int sx, u_int sy)
char *buf, *label;
u_int py, size, lsize;
/* Placeholder label. */
lsize = xasprintf(&label, "Sixel image (%ux%u)\n", sx, sy);
size = (sx + 2) * sy + 1;
if (lsize > size)
size = lsize;
/* Allocate first line. */
lsize = xasprintf(&label, "SIXEL IMAGE (%ux%u)\r\n", sx, sy) + 1;
if (sx < lsize - 3)
size = lsize - 1;
else
size = sx + 2;
/* Each placeholder line has \r\n at the end. */
/* Remaining lines. Every placeholder line has \r\n at the end. */
size += (sx + 2) * (sy - 1) + 1;
*ret = buf = xmalloc(size);
for (py = 0; py < sy; py++) {
/* Render first line. */
if (sx < lsize - 3) {
memcpy(buf, label, lsize);
buf += lsize - 1;
} else {
memcpy(buf, label, lsize - 3);
buf += lsize - 3;
memset(buf, '+', sx - lsize + 3);
buf += sx - lsize + 3;
snprintf(buf, 3, "\r\n");
buf += 2;
}
/* Remaining lines. */
for (py = 1; py < sy; py++) {
memset(buf, '+', sx);
buf += sx;
snprintf(buf, 3, "\r\n");
buf += 2;
}
/* Print the label.*/
if (size == lsize)
memcpy(*ret, label, lsize);
else
memcpy(*ret, label, lsize - 1);
free(label);
}

View File

@ -2263,7 +2263,6 @@ input_dcs_dispatch(struct input_ctx *ictx)
if (buf[0] == 'q') {
si = sixel_parse(buf, len, w->xpixel, w->ypixel);
if (si != NULL) {
sixel_log(si);
screen_write_sixelimage(sctx, si, ictx->cell.cell.bg);
}
}

View File

@ -1439,9 +1439,9 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped, u_int bg)
redraw = image_scroll_up(s, 1);
else
redraw = image_check_line(s, rupper, rlower - rupper);
#endif
if (redraw && ctx->wp != NULL)
ctx->wp->flags |= PANE_REDRAW;
#endif
grid_view_scroll_region_up(gd, s->rupper, s->rlower, bg);
screen_write_collect_scroll(ctx, bg);
ctx->scrolled++;

1
tmux.h
View File

@ -1496,7 +1496,6 @@ struct tty_ctx {
u_int num;
void *ptr;
int more;
void *ptr2;
/*