terminal: support pending image payloads for kitty graphics

Represent Kitty image data as a complete/pending tagged union.
Kitty images can now be completed _later_ if we have all their other
metadata up front.

This will be used by the snapshot API to transmit lightweight
information up front so that renderers of the snapshot can show
placeholders and accept mutating pty data, while the real image data
streams in later.
This commit is contained in:
Mitchell Hashimoto
2026-08-03 13:09:26 -07:00
parent 7d748097a0
commit 6760c6482b
5 changed files with 478 additions and 45 deletions

View File

@@ -390,7 +390,8 @@ typedef enum GHOSTTY_ENUM_TYPED {
/**
* Borrowed pointer to the raw pixel data. Valid as long as the
* underlying terminal is not mutated.
* underlying terminal is not mutated. Returns GHOSTTY_NO_VALUE when
* the image metadata is resident but its pixel payload is pending.
*
* The data is always fully decoded, uncompressed pixels in the
* format reported by GHOSTTY_KITTY_IMAGE_DATA_FORMAT: zlib payloads
@@ -404,7 +405,9 @@ typedef enum GHOSTTY_ENUM_TYPED {
/**
* Length of the raw pixel data in bytes. Always equal to
* width * height * bytes-per-pixel for the reported format.
* width * height * bytes-per-pixel for the reported format. For a
* pending image, this is the expected length reserved against the
* storage limit even though DATA_PTR is not available yet.
*
* Output type: size_t *
*/
@@ -421,7 +424,10 @@ typedef enum GHOSTTY_ENUM_TYPED {
* Stamps are unique and monotonically increasing process-wide and
* are drawn from the same sequence as
* GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION. Never zero for a stored
* image, so zero can be used as an "empty" sentinel by callers.
* image, so zero can be used as an "empty" sentinel by callers. Pending
* payload completion preserves this value to retain image age; consumers
* detect that completion through GHOSTTY_KITTY_GRAPHICS_DATA_GENERATION
* and retry DATA_PTR.
*
* Output type: uint64_t *
*/