From 89a7dcc8ab0878336f319f4c69f97d2a0b7461f5 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 | 24 ++++++++++++------------ 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/image-sixel.c b/image-sixel.c index 46b8e3dc6..a47e7ece0 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; @@ -1052,7 +1052,7 @@ sixel_from_image(struct image *im, u_int ox, u_int oy, u_int cells_x, u_int cells_y, u_int xpixel, u_int ypixel) { struct sixel_image *si; - struct sixel_histogram *histogram, *entry; + struct sixel_hgram *histogram, *entry; struct sixel_rgb palette[SIXEL_PALETTE_SIZE]; struct sixel_source source; const u_char *pixel; @@ -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 1c5d67811..07933df29 100644 --- a/image.c +++ b/image.c @@ -71,7 +71,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; @@ -90,8 +90,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 *); }; @@ -104,7 +104,7 @@ static const struct image_backend image_backend_kitty = { kitty_draw_rectangle, kitty_free_output, kitty_geometry_changed }; 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 }; @@ -285,7 +285,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; @@ -295,7 +295,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) @@ -306,7 +306,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; @@ -348,21 +348,21 @@ 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 grid cell for a drawing rectangle. */ const struct grid_cell * -image_rectangle_get_cell(const struct image_rectangle *rectangle) +image_rect_get_cell(const struct image_rect *rectangle) { return (&rectangle->cell); } /* 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) { @@ -587,7 +587,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. */ /* Convert an image cell rectangle to 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) { @@ -790,7 +790,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; @@ -827,7 +827,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); } } diff --git a/tmux.h b/tmux.h index 0d5490da9..1cd9721ed 100644 --- a/tmux.h +++ b/tmux.h @@ -79,7 +79,7 @@ struct session; #ifdef ENABLE_IMAGES struct image; struct image_backend; -struct image_rectangle; +struct image_rect; #endif #ifdef ENABLE_IMAGES struct sixel_image; @@ -4246,9 +4246,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 *); void image_set_no_cursor(struct image *); struct sixel_image *image_get_sixel(const struct image *); @@ -4258,7 +4258,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 *); @@ -4281,10 +4281,10 @@ void image_draw_line(struct tty *, struct screen *, u_int, u_int, void image_get_fallback_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 *); -const struct grid_cell *image_rectangle_get_cell( - const struct image_rectangle *); -void image_rectangle_get_coordinates(const struct image_rectangle *, +struct image *image_rect_get_image(const struct image_rect *); +const struct grid_cell *image_rect_get_cell( + 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 *); void image_clear(struct screen_write_ctx *, u_int); #define KITTY_PARSE_ERROR -1 @@ -4297,7 +4297,7 @@ int kitty_placeholder_to_cell(void *, struct grid_cell *, const struct grid_cell *); void kitty_free_state(void *); void kitty_draw_rectangle(struct tty *, - const struct image_rectangle *, const struct tty_style_ctx *); + const struct image_rect *, const struct tty_style_ctx *); void kitty_redraw_start(struct tty *, u_int, u_int, u_int, u_int); void kitty_free_output(struct tty *, int); void kitty_geometry_changed(struct tty *); @@ -4306,8 +4306,8 @@ void kitty_geometry_changed(struct tty *); #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);