From e6322b4196d73c975ba2e73633e6de9c46779059 Mon Sep 17 00:00:00 2001 From: topcat001 Date: Sun, 20 Aug 2023 15:46:59 -0700 Subject: [PATCH] Fix placeholder label and clean up. --- image.c | 36 ++++++++++++++++++++++++------------ input.c | 1 - screen-write.c | 2 +- tmux.h | 1 - 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/image.c b/image.c index 20ef104a..43808785 100644 --- a/image.c +++ b/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); } diff --git a/input.c b/input.c index 0ca2682a..d902149f 100644 --- a/input.c +++ b/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); } } diff --git a/screen-write.c b/screen-write.c index 14583ae1..d51f4c4d 100644 --- a/screen-write.c +++ b/screen-write.c @@ -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++; diff --git a/tmux.h b/tmux.h index 1bd95ba0..444373cb 100644 --- a/tmux.h +++ b/tmux.h @@ -1496,7 +1496,6 @@ struct tty_ctx { u_int num; void *ptr; - int more; void *ptr2; /*