-
-
Notifications
You must be signed in to change notification settings - Fork 72
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 Enable/Disable/Detect Kitty Keyboard Protocol #159
Conversation
@@ -113,6 +113,79 @@ func (o Output) backgroundColor() Color { | |||
return ANSIColor(0) | |||
} | |||
|
|||
func (o Output) kittyKeyboardProtocolSupport() byte { |
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.
We probably want to combine both this and termStatusReport
into one routine that gets executed when the output is being initialized. Right now, both kittyKeyboardProtocolSupport
& termStatusReport
will set the tty termios and read the envs before reading the response. This results in multiple unnecessary calls to GetTermios/SetTermios
and Getenv
.
Instead, we could define an initialize
function that queries the terminal once. However, I believe this might break things since we query the terminal during the lifetime of WithColorCache
https://github.com/muesli/termenv/pull/159/files#diff-35d16970a063a59d666ecdce46f6ac3363f36d17a3e672d8ff69f9ef2056d4cbR114
cc/ @muesli
// 0b100 (04) — Report alternate keys | ||
// 0b1000 (08) — Report all keys as escape codes | ||
// 0b10000 (16) — Report associated text. | ||
func (o Output) KittyKeyboardProtocolSupport() byte { |
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.
Might be worth introducing constants for these return values.
|
||
// first, send CSI query to see whether this terminal supports the | ||
// kitty keyboard protocol | ||
fmt.Fprintf(tty, CSI+"?u") |
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.
I assume other terminals simply ignore these queries? We should test this with the common set of terminals we usually test against.
This PR allows for enabling and disabling kitty keyboard protocol.
https://sw.kovidgoyal.net/kitty/keyboard-protocol/
This PR adds for returning the progressive enhancements so that the terminal
application can detect which features are supported.
The byte returned represents the bitset of supported flags.