Remove some code that will not be needed.

This commit is contained in:
Nicholas Marriott
2026-10-14 15:12:45 +01:00
parent c642ad8804
commit 77449c0e5c
3 changed files with 15 additions and 61 deletions

View File

@@ -55,7 +55,7 @@ struct sixel_image {
u_int x; u_int x;
u_int y; u_int y;
/* Terminal cell pixel dimensions used for scaling. */ /* Terminal cell pixel size used for decoding. */
u_int xpixel; u_int xpixel;
u_int ypixel; u_int ypixel;
@@ -65,12 +65,10 @@ struct sixel_image {
u_int used_colours; u_int used_colours;
/* SIXEL raster attributes. */ /* SIXEL raster attributes. */
u_int set_ra;
u_int ra_x; u_int ra_x;
u_int ra_y; u_int ra_y;
/* DCS parameters. */ /* DCS background parameter. */
u_int p1;
u_int p2; u_int p2;
/* Current parser position and colour register. */ /* Current parser position and colour register. */
@@ -168,6 +166,8 @@ struct sixel_source {
u_int out_h; u_int out_h;
}; };
static void sixel_free(struct sixel_image *);
/* Grow a SIXEL image to contain a line. */ /* Grow a SIXEL image to contain a line. */
static int static int
sixel_parse_expand_lines(struct sixel_image *si, u_int y) sixel_parse_expand_lines(struct sixel_image *si, u_int y)
@@ -452,8 +452,7 @@ sixel_parse_repeat(struct sixel_image *si, const char *cp, const char *end)
/* Parse SIXEL data into an indexed image. */ /* Parse SIXEL data into an indexed image. */
struct sixel_image * struct sixel_image *
sixel_parse(const char *buf, size_t len, u_int p1, u_int p2, u_int xpixel, sixel_parse(const char *buf, size_t len, u_int p2, u_int xpixel, u_int ypixel)
u_int ypixel)
{ {
struct sixel_image *si; struct sixel_image *si;
const char *cp = buf, *end = buf + len; const char *cp = buf, *end = buf + len;
@@ -467,7 +466,6 @@ sixel_parse(const char *buf, size_t len, u_int p1, u_int p2, u_int xpixel,
si = xcalloc(1, sizeof *si); si = xcalloc(1, sizeof *si);
si->xpixel = xpixel; si->xpixel = xpixel;
si->ypixel = ypixel; si->ypixel = ypixel;
si->p1 = p1;
si->p2 = p2; si->p2 = p2;
while (cp != end) { while (cp != end) {
@@ -517,7 +515,7 @@ bad:
} }
/* Free a SIXEL image. */ /* Free a SIXEL image. */
void static void
sixel_free(struct sixel_image *si) sixel_free(struct sixel_image *si)
{ {
u_int y; u_int y;
@@ -541,33 +539,6 @@ sixel_size_in_cells(struct sixel_image *si, u_int *x, u_int *y)
image_size_in_cells(si->x, si->y, si->xpixel, si->ypixel, x, y); image_size_in_cells(si->x, si->y, si->xpixel, si->ypixel, x, y);
} }
/* Log a SIXEL image. */
void
sixel_log(struct sixel_image *si)
{
struct sixel_line *sl;
char s[SIXEL_WIDTH_LIMIT + 1];
u_int i, x, y, cx, cy;
sixel_size_in_cells(si, &cx, &cy);
log_debug("%s: image %ux%u (%ux%u)", __func__, si->x, si->y, cx, cy);
for (i = 0; i < si->ncolours; i++)
log_debug("%s: colour %u is %07x", __func__, i, si->colours[i]);
for (y = 0; y < si->y; y++) {
sl = &si->lines[y];
for (x = 0; x < si->x; x++) {
if (x >= sl->x)
s[x] = '_';
else if (sl->data[x] != 0)
s[x] = '0' + (sl->data[x] - 1) % 10;
else
s[x] = '.';
}
s[x] = '\0';
log_debug("%s: %4u: %s", __func__, y, s);
}
}
/* Convert one HLS component to RGB. */ /* Convert one HLS component to RGB. */
static double static double
sixel_hue(double p, double q, double t) sixel_hue(double p, double q, double t)
@@ -620,7 +591,7 @@ sixel_colour_to_rgb(u_int c, u_char *r, u_char *g, u_char *b)
} }
/* Convert a SIXEL image into the common RGBA format. */ /* Convert a SIXEL image into the common RGBA format. */
struct image * static struct image *
sixel_to_image(struct sixel_image *si) sixel_to_image(struct sixel_image *si)
{ {
struct image *im; struct image *im;
@@ -785,14 +756,11 @@ sixel_print(struct sixel_image *si, size_t *size)
len = 8192; len = 8192;
buf = xmalloc(len); buf = xmalloc(len);
tmplen = xsnprintf(tmp, sizeof tmp, "\033P%u;%uq", si->p1, si->p2); sixel_print_add(&buf, &len, &used, "\033P9;1q", 6);
sixel_print_add(&buf, &len, &used, tmp, tmplen);
if (si->set_ra) { tmplen = xsnprintf(tmp, sizeof tmp, "\"1;1;%u;%u", si->ra_x,
tmplen = xsnprintf(tmp, sizeof tmp, "\"1;1;%u;%u", si->ra_x, si->ra_y);
si->ra_y); sixel_print_add(&buf, &len, &used, tmp, tmplen);
sixel_print_add(&buf, &len, &used, tmp, tmplen);
}
/* Track colour planes containing pixels in the current six-row band. */ /* Track colour planes containing pixels in the current six-row band. */
planes = xcalloc(used_colours, sizeof *planes); planes = xcalloc(used_colours, sizeof *planes);
@@ -1221,11 +1189,6 @@ sixel_make_image(struct image *im, u_int cx, u_int cy, u_int csx, u_int csy,
/* Create the indexed image with a SIXEL RGB palette. */ /* Create the indexed image with a SIXEL RGB palette. */
si = xcalloc(1, sizeof *si); si = xcalloc(1, sizeof *si);
si->xpixel = cw;
si->ypixel = ch;
si->p1 = 9;
si->p2 = 1;
si->set_ra = 1;
si->ra_x = sx; si->ra_x = sx;
si->ra_y = sy; si->ra_y = sy;
si->ncolours = si->used_colours = nc; si->ncolours = si->used_colours = nc;
@@ -1273,7 +1236,7 @@ fail:
} }
/* Encode part of an image as SIXEL for a terminal cell size. */ /* Encode part of an image as SIXEL for a terminal cell size. */
char * static char *
sixel_from_image(struct image *im, u_int x, u_int y, u_int sx, u_int sy, sixel_from_image(struct image *im, u_int x, u_int y, u_int sx, u_int sy,
u_int cw, u_int ch, size_t *size) u_int cw, u_int ch, size_t *size)
{ {

View File

@@ -2632,7 +2632,7 @@ input_dcs_dispatch(struct input_ctx *ictx)
#ifdef ENABLE_IMAGES #ifdef ENABLE_IMAGES
struct window *w; struct window *w;
struct sixel_image *si; struct sixel_image *si;
int p1, p2; int p2;
#endif #endif
if (wp == NULL) if (wp == NULL)
@@ -2650,13 +2650,10 @@ input_dcs_dispatch(struct input_ctx *ictx)
w = wp->window; w = wp->window;
if (input_split(ictx) != 0) if (input_split(ictx) != 0)
return (0); return (0);
p1 = input_get(ictx, 0, 0, 0);
if (p1 == -1)
p1 = 0;
p2 = input_get(ictx, 1, 0, 0); p2 = input_get(ictx, 1, 0, 0);
if (p2 == -1) if (p2 == -1)
p2 = 0; p2 = 0;
si = sixel_parse(buf, len, p1, p2, w->xpixel, w->ypixel); si = sixel_parse(buf, len, p2, w->xpixel, w->ypixel);
if (si != NULL) if (si != NULL)
sixel_write(sctx, si, ictx->cell.cell.bg); sixel_write(sctx, si, ictx->cell.cell.bg);
} }

View File

@@ -146,15 +146,9 @@ const struct grid_cell *fallback_map_cell(struct tty *, struct grid *, u_int,
#define SIXEL_COLOUR_REGISTERS 1024 #define SIXEL_COLOUR_REGISTERS 1024
int sixel_select(struct tty *); int sixel_select(struct tty *);
int sixel_get_flags(struct tty *); int sixel_get_flags(struct tty *);
struct sixel_image *sixel_parse(const char *, size_t, u_int, u_int, u_int, struct sixel_image *sixel_parse(const char *, size_t, u_int, u_int, u_int);
u_int);
void sixel_free(struct sixel_image *);
void sixel_log(struct sixel_image *);
struct image *sixel_to_image(struct sixel_image *);
void sixel_write(struct screen_write_ctx *, struct sixel_image *, void sixel_write(struct screen_write_ctx *, struct sixel_image *,
u_int); u_int);
char *sixel_from_image(struct image *, u_int, u_int, u_int, u_int,
u_int, u_int, size_t *);
void sixel_draw_rect(struct tty *, struct image_rect *); void sixel_draw_rect(struct tty *, struct image_rect *);
void sixel_start_draw(struct tty *, u_int, u_int, u_int, u_int); void sixel_start_draw(struct tty *, u_int, u_int, u_int, u_int);
void sixel_free_pending(struct tty *); void sixel_free_pending(struct tty *);