Encoding helpers for the Kitty terminal graphics protocol. More...
Static Public Member Functions | |
| static string | BuildDetectProbe () |
| Build a Kitty capability-query probe sequence. | |
| static KittyPayload | CreatePayload (byte[] pngBytes, TerminalCapabilities? capabilities=null) |
| Create a KittyPayload wrapping pngBytes . | |
| static uint | ImageIdFromBytes (ReadOnlySpan< byte > data) |
| Derive a stable non-zero image-id from PNG bytes using FNV-1a. | |
| static bool | ParseDetectResponse (string response) |
| Returns true if response is a Kitty OK reply to the probe. | |
Static Public Attributes | |
| const int | MaxChunkBase64Chars = 4096 |
| Maximum base64 characters per APC chunk (Kitty spec limit). | |
Encoding helpers for the Kitty terminal graphics protocol.
Images are transmitted as base64-encoded PNG data inside APC sequences (ESC _ G … ESC </c>), chunked to ≤4096 base64 chars each.
Format: f=100 (PNG — terminal reads dimensions from the header).
Multiplexer note (tmux): With allow-passthrough on, tmux forwards APC sequences directly to the outer terminal. However, CSI cursor-move sequences are handled by tmux internally and may be flushed to the outer terminal at a different time, causing the image to appear at the wrong position. The fix is to embed the cursor-positioning escape inside the DCS passthrough block alongside the first APC chunk — WezTerm (or any outer terminal) then receives cursor-move + image as one atomic unit and positions correctly.
|
static |
Build a Kitty capability-query probe sequence.
Send this to the terminal before entering raw mode, then read the response and pass it to ParseDetectResponse.
|
static |
Create a KittyPayload wrapping pngBytes .
Pass capabilities so the payload can apply the correct pane-offset when building DCS cursor-move sequences for tmux.
Cheap to call every frame: the encoding of pngBytes is cached against the array instance and reused.
|
static |
Derive a stable non-zero image-id from PNG bytes using FNV-1a.
Kitty image IDs are uint32, non-zero. Deterministic — same bytes → same ID, so no static counter (and no mutable state) is needed.