diff --git a/Makefile.am b/Makefile.am index 3ab3989c3..a1cbd76d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -248,7 +248,7 @@ endif # Enable image support. if ENABLE_IMAGES -dist_tmux_SOURCES += image.c image-sixel.c image-ascii.c +dist_tmux_SOURCES += image.c image-sixel.c endif # Add bits for fuzzing if enabled. diff --git a/image-ascii.c b/image-ascii.c deleted file mode 100644 index 781ff7708..000000000 --- a/image-ascii.c +++ /dev/null @@ -1,38 +0,0 @@ -/* $OpenBSD$ */ - -/* - * Copyright (c) 2026 Michael Grant - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include - -#include "tmux.h" - -/* Fill a grid cell with an ASCII brightness glyph. */ -void -image_get_text_cell(__unused struct tty *tty, struct image *im, u_int x, - u_int y, const struct grid_cell *gc, struct grid_cell *out, - __unused const struct tty_style_ctx *style_ctx) -{ - static const char ramp[] = " .:-=+*#%@"; - u_int level = 0; - - memcpy(out, gc, sizeof *out); - level = image_get_brightness(im, x, y) * (sizeof ramp - 2) / 255; - utf8_set(&out->data, ramp[level]); - out->flags &= ~GRID_FLAG_IMAGE; -} diff --git a/image.c b/image.c index 5ef9dfcc3..5941c88fa 100644 --- a/image.c +++ b/image.c @@ -469,10 +469,24 @@ image_get_brightness(struct image *im, u_int x, u_int y) return (cell->whole.brightness); } +/* Fill a grid cell with an ASCII brightness glyph. */ +static void +image_get_text_cell(struct image *im, u_int x, u_int y, + const struct grid_cell *gc, struct grid_cell *out) +{ + static const char ramp[] = " .:-=+*#%@"; + u_int level; + + memcpy(out, gc, sizeof *out); + level = image_get_brightness(im, x, y) * (sizeof ramp - 2) / 255; + utf8_set(&out->data, ramp[level]); + out->flags &= ~GRID_FLAG_IMAGE; +} + /* Get the terminal cell used to draw an image marker. */ int image_get_draw_cell(struct tty *tty, const struct grid_cell *gc, - struct grid_cell *out, const struct tty_style_ctx *style_ctx) + struct grid_cell *out) { struct image *im = image_find(gc->image_id); @@ -487,8 +501,7 @@ image_get_draw_cell(struct tty *tty, const struct grid_cell *gc, out->flags &= ~(GRID_FLAG_IMAGE|GRID_FLAG_IMAGE_DAMAGED); return (0); } - image_get_text_cell(tty, im, gc->image_x, gc->image_y, gc, out, - style_ctx); + image_get_text_cell(im, gc->image_x, gc->image_y, gc, out); return (0); } diff --git a/tmux.h b/tmux.h index 2462a5f5f..dd39b8ae0 100644 --- a/tmux.h +++ b/tmux.h @@ -4240,16 +4240,13 @@ void image_redraw_all(struct screen_write_ctx *); void image_redraw_scroll(struct screen_write_ctx *, u_int); int image_backend_flags(struct tty *); int image_get_draw_cell(struct tty *, const struct grid_cell *, - struct grid_cell *, const struct tty_style_ctx *); + struct grid_cell *); void image_tty_update(struct tty *); void image_tty_geometry_changed(struct tty *); void image_tty_free(struct tty *, int); void image_draw_line(struct tty *, struct screen *, u_int, u_int, u_int, u_int, u_int, int, const struct tty_style_ctx *); 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_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 *); diff --git a/tty-draw.c b/tty-draw.c index e1cc2a517..a820abd62 100644 --- a/tty-draw.c +++ b/tty-draw.c @@ -258,8 +258,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, #ifdef ENABLE_IMAGES if (gc.flags & GRID_FLAG_IMAGE) { - (void)image_get_draw_cell(tty, &gc, &image_gc, - style_ctx); + (void)image_get_draw_cell(tty, &gc, &image_gc); gcp = &image_gc; } else gcp = &gc; diff --git a/tty.c b/tty.c index db69ad483..2e9f26bec 100644 --- a/tty.c +++ b/tty.c @@ -2149,7 +2149,7 @@ tty_cell(struct tty *tty, const struct grid_cell *gc, #ifdef ENABLE_IMAGES if (gc->flags & GRID_FLAG_IMAGE) { - if (image_get_draw_cell(tty, gc, &image_gc, style_ctx)) + if (image_get_draw_cell(tty, gc, &image_gc)) return; gc = &image_gc; }