termtab-0.1.0.0: TUI guitar tablature and score editor
Safe HaskellNone
LanguageGHC2021

Termtab.Graphics.Kitty

Description

Kitty graphics protocol encoder.

Serializes an RGBA image into the APC escape sequences the Kitty graphics protocol uses (supported by Kitty, WezTerm, and Ghostty). Raw 32-bit RGBA is transmitted (f=32) and displayed at the cursor (a=T); the base64 payload is split into <=4096-byte chunks framed with m=1/m=0 per the protocol.

This module is pure: it produces the exact bytes to write to the terminal. It performs no IO and does not know about vty — the caller decides where the cursor is and when to emit.

Synopsis

Documentation

encodeImage :: Image PixelRGBA8 -> ByteString Source #

Encode an image for direct placement at the cursor (a=T) — used by the one-shot demo.

encodeRGBA :: Int -> Int -> ByteString -> ByteString Source #

Encode raw row-major RGBA bytes (w*h*4 bytes) for direct placement at the cursor.

encodeVirtual :: Int -> Int -> Int -> Image PixelRGBA8 -> ByteString Source #

Encode an image as a *virtual* placement (U=1) for display via Unicode placeholders: transmit it under image id imgId occupying cols×rows terminal cells. The image is not shown until placeholder cells referencing imgId are drawn (see Termtab.Graphics.KittyPlacement). q=2 suppresses the terminal's acknowledgement so it cannot corrupt input.

encodeDirect :: Int -> Int -> Int -> Image PixelRGBA8 -> ByteString Source #

Encode an image for direct placement at the cursor, scaled to cols×rows cells, under image id imgId / placement id 1. Re-emitting with the same ids replaces the placement (no buildup). C=1 leaves the cursor where it is; q=2 suppresses the acknowledgement. Used to blit the notation over a reserved region whose screen position the caller has moved the cursor to.

deleteImage :: Int -> ByteString Source #

Delete image imgId (data and all its placements). Emitted before a re-blit so Kitty actually refreshes the pixels instead of assuming an unchanged placement is still current.