-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Kitty Color Protocol (OSC 21) #2113
Conversation
Kitty 0.36.0 added support for a new OSC escape sequence for quering, setting, and resetting the terminal colors. Details can be found [here](https://sw.kovidgoyal.net/kitty/color-stack/#setting-and-querying-colors). This fully parses the OSC 21 escape sequences, but only supports actually querying and changing the foreground color, the background color, and the cursor color because that's what Ghostty currently supports. Adding support for the other settings that Kitty supports changing ranges from easy (cursor text) to difficult (visual bell, second transparent background color).
Unmarked this as a WIP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very excellent work! Truly! I've noted some changes I'd like to see. Thank you!
- Cap the total number of requests at twice the maximum number of keys (currently 263, so 526 requests). Basically you can set and then query every key in one message. This is an absurdly high number but should prevent serious DOS attacks. - Clarify meaning of new hex color codes. - Better handle sending messages to the renderer in a way that should prevent deadlocks. - Handle 0-255 palette color requests by creatively using non-exhautive enums. - Fix an error in the query reply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I want to play around with one thing but the rest looks good.
I'm still doing some small tweaks then I plan to merge this. I'd still love to see an approach that doesn't use non-exhaustive enums but I don't think I'll pursue it in this PR. My biggest issue with non-exhaustive enums is that it gets rid of a bunch of nice compiler verification for exhaustion when switching. I try to only use non-exhaustive enums for C interop or scenarios where we want to be liberal in what we accept. This feature is neither of those. Like I said, I'll still merge it as is but I'm still making some tweaks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple more changes requested. I can get to them soon or you can, either way. They're small.
After doing the desktop notifications I think you're right about using a union to separate the two cases rather than the non-exhaustive enum. I can either update this PR now or do a follow-up PR after this merges. |
I'd appreciate a follow-up PR. I think this one is getting really close to merge-able and I don't want to delay it even more 😄 But a follow up to clean that up would be very nice! |
Kitty 0.36.0 added support for a new OSC escape sequence for quering, setting, and resetting the terminal colors. Details can be found here.
This fully parses the OSC 21 escape sequences, but only supports actually querying and changing the foreground color, the background color, and the cursor color because that's what Ghostty currently supports. Adding support for the other settings that Kitty supports changing ranges from easy (cursor text) to difficult (visual bell, second transparent background color).