mirror of https://github.com/tmux/tmux.git
Fix placeholder label and clean up.
parent
5896ac52a1
commit
e6322b4196
36
image.c
36
image.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
1
input.c
1
input.c
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
|
|
Loading…
Reference in New Issue