From f0216004ee10401539b9b1bb1fda955c187dd7dd Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Sat, 8 Aug 2026 10:40:56 +0100 Subject: [PATCH] Shorten image and SIXEL names --- image-sixel.c | 28 ++++++++++++++-------------- image.c | 26 +++++++++++++------------- tmux.h | 18 +++++++++--------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/image-sixel.c b/image-sixel.c index c25e69cdf..bd9ba8d9c 100644 --- a/image-sixel.c +++ b/image-sixel.c @@ -88,7 +88,7 @@ struct sixel_output { uint64_t age; }; -struct sixel_histogram { +struct sixel_hgram { u_int count; uint64_t red; uint64_t green; @@ -818,9 +818,9 @@ sixel_print(struct sixel_image *si, struct sixel_image *map, size_t *size) /* Split a 5-bit RGB histogram into an adaptive palette using median cut. */ static void -sixel_box_update(struct sixel_box *box, struct sixel_histogram *histogram) +sixel_box_update(struct sixel_box *box, struct sixel_hgram *histogram) { - struct sixel_histogram *entry; + struct sixel_hgram *entry; u_int red, green, blue, index; u_int red_min = SIXEL_HISTOGRAM_LEVELS; u_int green_min = SIXEL_HISTOGRAM_LEVELS; @@ -865,7 +865,7 @@ sixel_box_update(struct sixel_box *box, struct sixel_histogram *histogram) /* Split a histogram box at its weighted median. */ static int sixel_box_split(struct sixel_box *box, struct sixel_box *new, - struct sixel_histogram *histogram) + struct sixel_hgram *histogram) { u_int levels[SIXEL_HISTOGRAM_LEVELS] = { 0 }; u_int red, green, blue, index, channel, first, last, level; @@ -932,7 +932,7 @@ sixel_box_split(struct sixel_box *box, struct sixel_box *new, /* Build an adaptive palette from an RGB histogram. */ static u_int -sixel_make_palette(struct sixel_histogram *histogram, +sixel_make_palette(struct sixel_hgram *histogram, struct sixel_rgb *palette) { struct sixel_box boxes[SIXEL_PALETTE_SIZE], new; @@ -1053,7 +1053,7 @@ sixel_from_image(struct image *im, u_int ox, u_int oy, u_int cells_x, { struct sixel_image *si; struct sixel_source source; - struct sixel_histogram *histogram, *entry; + struct sixel_hgram *histogram, *entry; struct sixel_rgb palette[SIXEL_PALETTE_SIZE]; const u_char *pixel; uint16_t *cache; @@ -1067,10 +1067,10 @@ sixel_from_image(struct image *im, u_int ox, u_int oy, u_int cells_x, /* Work out the requested cell crop in destination pixel coordinates. */ source.pixels = image_get_pixels(im, &source.stride, NULL); - image_get_dimensions(im, &source.width, &source.height); - image_get_canvas_dimensions(im, &source.canvas_width, + image_get_size(im, &source.width, &source.height); + image_get_canvas_size(im, &source.canvas_width, &source.canvas_height); - image_get_cell_dimensions(im, &source.sx, &source.sy); + image_get_cell_size(im, &source.sx, &source.sy); destination_width = (uint64_t)source.sx * xpixel; destination_height = (uint64_t)source.sy * ypixel; if (destination_width > UINT_MAX || destination_height > UINT_MAX) @@ -1100,7 +1100,7 @@ sixel_from_image(struct image *im, u_int ox, u_int oy, u_int cells_x, return (NULL); /* Map the requested cell crop to the source image's pixel rectangle. */ - image_get_pixel_rectangle(im, ox, oy, cells_x, cells_y, &sourcex0, + image_get_pixel_rect(im, ox, oy, cells_x, cells_y, &sourcex0, &sourcey0, &sourcewidth, &sourceheight); if (sourcewidth == 0 || sourceheight == 0) return (NULL); @@ -1311,7 +1311,7 @@ sixel_render_image(struct image *im, u_int xpixel, u_int ypixel) struct sixel_image *original; u_int sx, sy; - image_get_cell_dimensions(im, &sx, &sy); + image_get_cell_size(im, &sx, &sy); /* Preserve SIXEL's original palette and indexed pixels when possible. */ original = image_get_sixel(im); if (original != NULL) @@ -1388,7 +1388,7 @@ sixel_image_is_cached(struct tty *tty, struct sixel_image *si) /* Draw an image rectangle with SIXEL output. */ void -sixel_draw_rectangle(struct tty *tty, const struct image_rectangle *rectangle, +sixel_draw_rect(struct tty *tty, const struct image_rect *rectangle, __unused const struct tty_style_ctx *style_ctx) { struct sixel_image *si, *crop; @@ -1397,10 +1397,10 @@ sixel_draw_rectangle(struct tty *tty, const struct image_rectangle *rectangle, u_int source_x, source_y, width, height; u_int destination_x, destination_y; - si = sixel_get_image(tty, image_rectangle_get_image(rectangle)); + si = sixel_get_image(tty, image_rect_get_image(rectangle)); if (si == NULL) return; - image_rectangle_get_coordinates(rectangle, &source_x, &source_y, &width, + image_rect_get_coords(rectangle, &source_x, &source_y, &width, &height, &destination_x, &destination_y); crop = sixel_scale(si, tty->xpixel, tty->ypixel, source_x, source_y, width, height, 1); diff --git a/image.c b/image.c index 4ce8ad7c3..f05c93e02 100644 --- a/image.c +++ b/image.c @@ -65,7 +65,7 @@ struct image { RB_HEAD(images, image); /* A cell-aligned part of an image to draw at a terminal position. */ -struct image_rectangle { +struct image_rect { struct image *image; struct grid_cell cell; u_int source_x; @@ -84,8 +84,8 @@ static struct image *image_grid_ids[USHRT_MAX + 1]; struct image_backend { const char *name; int flags; - void (*draw_rectangle)(struct tty *, - const struct image_rectangle *, const struct tty_style_ctx *); + void (*draw_rect)(struct tty *, + const struct image_rect *, const struct tty_style_ctx *); void (*free)(struct tty *, int); void (*geometry_changed)(struct tty *); }; @@ -94,7 +94,7 @@ static const struct image_backend image_backend_ascii = { "ascii", IMAGE_BACKEND_SCROLLS, NULL, NULL, NULL }; static const struct image_backend image_backend_sixel = { - "sixel", IMAGE_BACKEND_GRAPHICAL, sixel_draw_rectangle, + "sixel", IMAGE_BACKEND_GRAPHICAL, sixel_draw_rect, sixel_free_output, sixel_geometry_changed }; @@ -263,7 +263,7 @@ image_get_id(const struct image *im) /* Return an image's pixel dimensions. */ void -image_get_dimensions(const struct image *im, u_int *width, u_int *height) +image_get_size(const struct image *im, u_int *width, u_int *height) { if (width != NULL) *width = im->width; @@ -273,7 +273,7 @@ image_get_dimensions(const struct image *im, u_int *width, u_int *height) /* Return an image canvas's pixel dimensions. */ void -image_get_canvas_dimensions(const struct image *im, u_int *width, +image_get_canvas_size(const struct image *im, u_int *width, u_int *height) { if (width != NULL) @@ -284,7 +284,7 @@ image_get_canvas_dimensions(const struct image *im, u_int *width, /* Return an image's cell dimensions. */ void -image_get_cell_dimensions(const struct image *im, u_int *sx, u_int *sy) +image_get_cell_size(const struct image *im, u_int *sx, u_int *sy) { if (sx != NULL) *sx = im->sx; @@ -319,14 +319,14 @@ image_set_sixel(struct image *im, struct sixel_image *si) /* Return the image for a drawing rectangle. */ struct image * -image_rectangle_get_image(const struct image_rectangle *rectangle) +image_rect_get_image(const struct image_rect *rectangle) { return (rectangle->image); } /* Return the source and destination coordinates of a drawing rectangle. */ void -image_rectangle_get_coordinates(const struct image_rectangle *rectangle, +image_rect_get_coords(const struct image_rect *rectangle, u_int *source_x, u_int *source_y, u_int *width, u_int *height, u_int *destination_x, u_int *destination_y) { @@ -500,7 +500,7 @@ image_set_cell(struct grid_cell *gc, struct image *im, u_int x, u_int y) /* Convert a cell-aligned image rectangle into source pixel coordinates. */ void -image_get_pixel_rectangle(const struct image *im, u_int x, u_int y, +image_get_pixel_rect(const struct image *im, u_int x, u_int y, u_int width, u_int height, u_int *px, u_int *py, u_int *pwidth, u_int *pheight) { @@ -608,7 +608,7 @@ image_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, u_int atx, u_int aty, const struct tty_style_ctx *style_ctx) { const struct image_backend *backend; - struct image_rectangle rectangle; + struct image_rect rectangle; struct grid_cell gc, next; struct image *im; u_int i, run; @@ -645,7 +645,7 @@ image_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, rectangle.height = 1; rectangle.destination_x = atx + i; rectangle.destination_y = aty; - backend->draw_rectangle(tty, &rectangle, style_ctx); + backend->draw_rect(tty, &rectangle, style_ctx); } } @@ -662,7 +662,7 @@ image_write(struct screen_write_ctx *ctx, struct image *im, u_int bg) u_int cx = s->cx, cy = s->cy; u_int x, y, sx, sy, lines; - image_get_cell_dimensions(im, &sx, &sy); + image_get_cell_size(im, &sx, &sy); if (sx > screen_size_x(s) - cx) sx = screen_size_x(s) - cx; if (sy > screen_size_y(s) - 1) diff --git a/tmux.h b/tmux.h index 27134bf7b..ce1c8b86f 100644 --- a/tmux.h +++ b/tmux.h @@ -78,7 +78,7 @@ struct session; #ifdef ENABLE_IMAGES struct image; struct image_backend; -struct image_rectangle; +struct image_rect; #endif #ifdef ENABLE_IMAGES struct sixel_image; @@ -4217,9 +4217,9 @@ struct image *image_find(u_int); u_int image_get_id(const struct image *); u_short image_get_grid_id(u_int); u_int image_get_id_by_grid_id(u_short); -void image_get_dimensions(const struct image *, u_int *, u_int *); -void image_get_canvas_dimensions(const struct image *, u_int *, u_int *); -void image_get_cell_dimensions(const struct image *, u_int *, u_int *); +void image_get_size(const struct image *, u_int *, u_int *); +void image_get_canvas_size(const struct image *, u_int *, u_int *); +void image_get_cell_size(const struct image *, u_int *, u_int *); const u_char *image_get_pixels(const struct image *, size_t *, size_t *); struct sixel_image *image_get_sixel(const struct image *); void image_set_sixel(struct image *, struct sixel_image *); @@ -4228,7 +4228,7 @@ void image_free(u_int); void image_set_cell(struct grid_cell *, struct image *, u_int, u_int); void image_write(struct screen_write_ctx *, struct image *, u_int); -void image_get_pixel_rectangle(const struct image *, u_int, u_int, +void image_get_pixel_rect(const struct image *, u_int, u_int, u_int, u_int, u_int *, u_int *, u_int *, u_int *); void image_size_in_cells(u_int, u_int, u_int, u_int, u_int *, u_int *); @@ -4248,16 +4248,16 @@ u_char image_get_brightness(struct image *, u_int, u_int); void image_get_text_cell(struct tty *, struct image *, u_int, u_int, const struct grid_cell *, struct grid_cell *, const struct tty_style_ctx *); -struct image *image_rectangle_get_image(const struct image_rectangle *); -void image_rectangle_get_coordinates(const struct image_rectangle *, +struct image *image_rect_get_image(const struct image_rect *); +void image_rect_get_coords(const struct image_rect *, u_int *, u_int *, u_int *, u_int *, u_int *, u_int *); #endif #ifdef ENABLE_IMAGES /* image-sixel.c */ #define SIXEL_COLOUR_REGISTERS 1024 -void sixel_draw_rectangle(struct tty *, - const struct image_rectangle *, const struct tty_style_ctx *); +void sixel_draw_rect(struct tty *, + const struct image_rect *, const struct tty_style_ctx *); void sixel_free_output(struct tty *, int); void sixel_geometry_changed(struct tty *); struct sixel_image *sixel_parse(const char *, size_t, u_int, u_int, u_int);