summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortopcat001 <anindya49@hotmail.com>2023-08-20 15:46:59 -0700
committertopcat001 <anindya49@hotmail.com>2023-08-20 15:46:59 -0700
commite6322b4196d73c975ba2e73633e6de9c46779059 (patch)
treedd24534e18d0dffe74d8a8d0bbca49d3b2673834
parent5896ac52a1f72056a75480b3e1ada328f239df9b (diff)
Fix placeholder label and clean up.
-rw-r--r--image.c36
-rw-r--r--input.c1
-rw-r--r--screen-write.c2
-rw-r--r--tmux.h1
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;
/*