-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
area/addon/imagetype/enhancementFeatures or improvements to existing featuresFeatures or improvements to existing features
Description
Context
The Kitty graphics protocol supports "relative placements" — positioning an image relative to another already-placed image rather than at the current cursor position. This uses four keys: P (parent image ID), Q (parent placement ID), H (horizontal offset from parent in pixels), and V (vertical offset from parent in pixels).
Currently none of these keys are parsed or handled anywhere in the codebase.
What needs to happen
-
Parse relative placement keys in
KittyGraphicsTypes.ts:P— parent image ID (the image to position relative to)Q— parent placement ID (which placement of the parent image)H— horizontal offset in pixels from parent's top-left cornerV— vertical offset in pixels from parent's top-left corner- Add these to the
KittyKeyenum andIKittyCommandinterface
-
Implement relative positioning in
KittyGraphicsHandler._decodeAndDisplay():- When
Pis specified, look up the parent image's placement position in the buffer - Calculate the target position as parent position + (H, V) pixel offsets
- Convert pixel offsets to cell coordinates for placement
- If the parent placement is not found, respond with an error
- When
-
Track placement positions in
KittyImageStorage:- Need to store the screen position of each placement so child images can reference it
- This likely requires a placement registry mapping (imageId, placementId) → (row, col, pixelOffsetX, pixelOffsetY)
Spec reference
https://sw.kovidgoyal.net/kitty/graphics-protocol/#relative-placement
Key files
addons/addon-image/src/kitty/KittyGraphicsTypes.ts— addP,Q,H,Vkey parsingaddons/addon-image/src/kitty/KittyGraphicsHandler.ts—_decodeAndDisplay()needs relative positioning logicaddons/addon-image/src/kitty/KittyImageStorage.ts— needs placement position trackingaddons/addon-image/test/KittyGraphics.test.ts
Acceptance criteria
a=T,i=2,P=1,H=50,V=30places image 2 at 50px right and 30px down from image 1's top-lefta=T,i=2,P=1,Q=3,H=0,V=0places image 2 at the same position as placement 3 of image 1- If parent image/placement not found, respond with appropriate error
- Negative
H/Voffsets work correctly (place to the left/above parent) - Integration tests verify relative positioning accuracy
Discussion
See feature inventory §12 in #5683
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/addon/imagetype/enhancementFeatures or improvements to existing featuresFeatures or improvements to existing features