-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add keyboard protocol support (the kitty one) #11509
Comments
Is there a particular gap that |
These are based on VT Also most notably, notcurses has support for the kitty keyboard protocol and minimum support for XTMODKey (it'll likely be re-iterated as time permits). Also see #4999 (comment), which is basically this particular request. |
#11264 also would reveal the need for this, if we want to do independent things from conhost (which you seemed to have wanted from the your reply to the comment linked above). |
I guess the best proposol would be to re-work the input mode so that the win32 input would convert to one of the 2 proposed keyboard protocols. Easier would be to simply have 2 different ones, but that's asking for bad code health and inefficiencies, when much of what's already there can likely be re-used. |
Sure okay, so this is on the client read input side, not the terminal write input side. Just "add support for {whatever} VT Input mode". That's fine, just a little different encoding from the other VT input types we have. Thanks for helping clarify! |
I'm only interested in implementing the standard ones, like Also, I think the XTerm protocol is closely related to #8719 (possibly intended to be the same thing, but I was under the impression that they weren't strictly compatible). |
Yes Iterm is slightly incompatible with Xterm's implementation, which is why I'd rather we opted for Kitty's instead as the most robust one existing and upon which the terminal working group was discussing as a base to which certain changes were encouraged by some terminal authors. Never got to resolution though and though it's the first one in the gitlab, it's also the longest standing one still awaiting a standard. I do know there are a number of TUI applications that make use of Kitty's keyboard protocol as issues were raised about it in the past, so we'd be getting the support of those applications automatically. We could also adopt both but that makes little sense as they aim to do the same thing, just one does it better than the other. |
If you read the whole terminal-wg thread, most people seem to be opposed to the Kitty protocol and were arguing for some version of the |
Yea frankly, |
The problem with the |
So far, these terminal emulators have implemented the protocol:
I think that with these recent additions, not opting for the kitty enhanced keyboard protocol has become a more contentious path than when this issue was opened. |
In case I'm not the only one that wasn't aware of this, it's worth noting that the current kitty keyboard protocol which everyone is implementing is not the same as the one that was originally proposed in terminal-wg. I think the switch actually happened years ago, but I only found out about the new version fairly recently. I haven't looked at it in much detail, but from my initial impression I'd now be more inclined to pick kitty over libticket/xtmodkeys if we were going to implement one of them. That said, this is still not something I'm personally interested in at this point in time. |
Despite the fact that the kitty keyboard protocol seems overly complicated and difficult to implement, writing its implementation turned out to be quite easy. Here is the implementation code I wrote for far2l, I am releasing this code snippet under the Public Domain license so that anyone can use it. This is not a complete implementation, but it can be easily extended to become a full one. However, this implementation is sufficient for all the applications I have tested (far2l file manager, turbo text editor, Free Pascal’s Free Vision sample app with kitty keyboard protocol support patch from their GitLab). At the very least, this implementation can be used as a reference. This code generates kitty protocol ESC sequences from Windows-compatible Key Event Record structure and can be easily adapted for use in the Microsoft terminal. |
This comment was marked as off-topic.
This comment was marked as off-topic.
As for me, win32 input mode is fine, and we already support it in far2l. As for alternate layout feature, virtual key code field can be used for that. Btw, it is important to understand that a protocol without applications that use it makes no sense, and the kitty's protocol already has a certain set of applications that work with it. |
This comment was marked as abuse.
This comment was marked as abuse.
Libraries implementing kitty keyboard protocol: The notcurses library |
This comment was marked as off-topic.
This comment was marked as off-topic.
Thanks for the reference implementation! If there was an enterprising individual out there that was really interested in contributing this, I'd take a look at https://github.com/microsoft/terminal/blob/main/src/terminal/input/terminalInput.hpp
|
Regarding the disadvandages of the kitty protocol, I see only two at the moment. The specification seems overly complex. The real issue here lies in how the specification is written, rather than the protocol itself. I'll explain its essence to you in just a few words. Each key event message in this protocol contains 7 parameters (first 5 are of type int, next goes one or more ints separated by colons and the last parameter is of type char), of which only the first and last ones are mandatory. Messages have the following structure:
Example:
The presence of certain fields is determined by, on one hand, their non-zero value, and on the other, by the flags set when activating the protocol.
That's it! The protocol is actually so simple that you already understand how it works. The specification for the Considering all this, as well as the highest number of implementations in applications, I believe that this protocol has the best chance of becoming the de facto standard for full keyboard input support in terminals. |
Description of the new feature/enhancement
Provide a keyboard protocol for reporting raw keyboard input, preferably the Kitty keyboard protocol but at the very least XTMODKey, which Xterm supports.
Also see https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/1
Proposed technical implementation details (optional)
The text was updated successfully, but these errors were encountered: