libghostty(formatter): enable kitty gfx for vt#12182
Open
neurosnap wants to merge 3 commits intoghostty-org:mainfrom
Open
libghostty(formatter): enable kitty gfx for vt#12182neurosnap wants to merge 3 commits intoghostty-org:mainfrom
neurosnap wants to merge 3 commits intoghostty-org:mainfrom
Conversation
490a64f to
135ce88
Compare
This adds support for printing kitty graphics using the `terminal.Formatter` through a new `terminal.ScreenFormatter.Extra` option `kitty_graphics`. This only implements kitty gfx for the `vt` format option. References: https://discord.com/channels/1005603569187160125/1420009803173859449/1446588699952287849
135ce88 to
d26cc3b
Compare
neurosnap
commented
Apr 8, 2026
neurosnap
commented
Apr 8, 2026
mitchellh
requested changes
Apr 8, 2026
src/terminal/formatter.zig
Outdated
|
|
||
| if (self.images.imageById(key.image_id)) |image| { | ||
| const grid = placement.gridSize(image, self.terminal); | ||
| // Create newlines for the entire image height |
Contributor
There was a problem hiding this comment.
Do we have to do this? I thought the Kitty protocol handlers do this automatically. The VT formatter should try to just emit the VT sequences that result in the same behaviors, no?
Contributor
Author
There was a problem hiding this comment.
Ah! Good catch. I was experimenting with different implementations and had left the C=1 in the placement escape code which disables automatic cursor advancement. Updated.
This allows the cursor to advance after the image and now we don't have to manually add newlines after placement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for printing kitty graphics using the
terminal.Formatterthrough a newterminal.ScreenFormatter.Extraoptionkitty_graphics.This only implements kitty gfx for the
vtformat option.This enables kitty gfx support for
zmxwhen we restore terminal scrollback on re-attach: neurosnap/zmx#14References: https://discord.com/channels/1005603569187160125/1420009803173859449/1446588699952287849
The tricky part was getting the spacing correct when mixing images and content which I made sure to lock down inside a test.
To get the spacing correct I needed to thread the
Terminalobject through the formatters so I could runplacement.gridSize().I wrote the bulk of the implementation and QA'd the results. I manually tested this feature
using a modified
example/zig-formatterwhich can be found in this branch: neurosnap@2b19faf./ex.sh | zig build runai disclosure
I used AI to help me: