This commit is contained in:
Michael Grant
2026-08-08 22:16:24 +01:00
parent b89f8b0624
commit ed63826b15
2 changed files with 16 additions and 10 deletions

View File

@@ -861,7 +861,6 @@ kitty_place_image(struct image *source, struct kitty_state *ks, u_int xpixel,
* static images are accepted. The returned image retains immutable RGBA
* pixels for the lifetime of its placement.
*/
/* Parse Kitty graphics data and return a placed image when appropriate. */
struct image *
kitty_parse_image(void **state, const u_char *buf, size_t len, u_int xpixel,
u_int ypixel, u_int *image_id, u_int *replace_id, u_int *quiet,
@@ -1120,7 +1119,6 @@ kitty_placeholder_index(uint32_t value, u_int *index)
return (0);
}
/* Replace a Kitty Unicode placeholder with a shared image marker cell. */
/* Convert a Kitty Unicode placeholder cell into an image marker. */
int
kitty_placeholder_to_cell(void *state, struct grid_cell *gc,

24
input.c
View File

@@ -2923,6 +2923,11 @@ input_top_bit_set(struct input_ctx *ictx)
{
struct screen_write_ctx *sctx = &ictx->ctx;
struct utf8_data *ud = &ictx->utf8data;
#ifdef ENABLE_IMAGES
struct grid_cell gc, left;
const struct grid_cell *gcl;
u_int x;
#endif
ictx->flags &= ~INPUT_LAST;
@@ -2952,15 +2957,18 @@ input_top_bit_set(struct input_ctx *ictx)
#ifdef ENABLE_IMAGES
if (sctx->s->cx != 0) {
struct grid_cell gc, left;
u_int x = sctx->s->cx - 1;
x = sctx->s->cx - 1; /* cx-1 is the cell just written. */
grid_view_get_cell(sctx->s->grid, x, sctx->s->cy, &gc);
if (x != 0)
grid_view_get_cell(sctx->s->grid, x - 1, sctx->s->cy,
&left);
if (kitty_placeholder_to_cell(ictx->kitty_state, &gc,
x == 0 ? NULL : &left)) {
/* The preceding cell provides context for implicit coordinates. */
if (x == 0) {
gcl = NULL;
} else {
grid_view_get_cell(sctx->s->grid, x - 1, sctx->s->cy, &left);
gcl = &left;
}
/* Convert a recognized Kitty placeholder in gc to an image marker. */
if (kitty_placeholder_to_cell(ictx->kitty_state, &gc, gcl)) {
grid_view_set_cell(sctx->s->grid, x, sctx->s->cy, &gc);
image_redraw_area(sctx, x, sctx->s->cy, 1, 1);
}