Add support for the kitty graphics protocol

Kitty-capable terminals (kitty, ghostty, and others) can display
inline images via APC escape sequences.

Kitty's image support uses a passthrough model: APC sequences from
programs running inside panes are relayed verbatim to the outer
terminal with cursor positioning adjusted for the pane offset.

The outer terminal handles all image rendering and therefore itself must
be kitty-aware.
This commit is contained in:
Thomas Adam
2026-02-28 21:14:32 +00:00
parent d9d2b2f1ee
commit cf6cbe430c
11 changed files with 608 additions and 2 deletions

View File

@@ -667,6 +667,16 @@ screen_redraw_screen(struct client *c)
}
if (flags & CLIENT_REDRAWWINDOW) {
log_debug("%s: redrawing panes", c->name);
#ifdef ENABLE_KITTY
/*
* Delete all kitty image placements before redrawing panes.
* This must happen unconditionally — even when the new window
* has no images — so that images from the previous window
* (or from a `reset` in the shell) are cleared from the outer
* terminal before new content is drawn over them.
*/
tty_kitty_delete_all(&c->tty);
#endif
screen_redraw_draw_panes(&ctx);
screen_redraw_draw_pane_scrollbars(&ctx);
}
@@ -697,8 +707,12 @@ screen_redraw_pane(struct client *c, struct window_pane *wp,
tty_sync_start(&c->tty);
tty_update_mode(&c->tty, c->tty.mode, NULL);
if (!redraw_scrollbar_only)
if (!redraw_scrollbar_only) {
#ifdef ENABLE_KITTY
tty_kitty_delete_all(&c->tty);
#endif
screen_redraw_draw_pane(&ctx, wp);
}
if (window_pane_show_scrollbar(wp, ctx.pane_scrollbars))
screen_redraw_draw_pane_scrollbar(&ctx, wp);