feat: implement legacy console API on Windows#16
feat: implement legacy console API on Windows#16the-mikedavis merged 1 commit intohelix-editor:masterfrom
Conversation
the-mikedavis
left a comment
There was a problem hiding this comment.
This looks sweet, thanks for spending the time diving into it! I'm glad to see everything ported over to windows_sys. At a very quick scan through I think everything looks good but I will try to give this a closer look and some Windows testing in the coming days 👍
|
Side note, but it looks like kitty keyboard protocol support just got merged in to Windows Terminal. Hopefully that means there won't be a good reason to recommend using the legacy input protocol for too much longer. |
the-mikedavis
left a comment
There was a problem hiding this comment.
I finally booted onto Windows and gave this a test and it works great! Thanks for porting all of this stuff over to windows-sys.
We're shooting to make a release for Helix in early March but then soon after I'll move Windows back onto termina and force the legacy mode. Once the VTE stuff is mature enough we can add a config flag to control which one you use - being able to choose at config time rather than at build time seems like the right way to expose this to me 👍
This adds support for the legacy console API in Windows, in addition to the VTE protocol that's used currently. Since more advanced key combos will only work for terminals that implement the Kitty Keyboard Protocol when using VTE mode, there unfortunately doesn't seem to be a clear answer on which input method is better. Windows Terminal, notably, does not implement this, so Windows users who prefer Windows Terminal will likely prefer using the legacy protocol until Microsoft adds it (tracking issue). I've added a section in the README with a comparison table, although I'm sure there are additional differences that I'm not aware of.
Because of this, I made the input mode configurable at runtime by using
PlatformTerminal::with_modeinstead of making this purely a compile-time switch. The legacy protocol is still gated behind a feature flag (windows-legacy), however, so users who don't need it won't pay for the additional compilation time. I've updated theevent-readexample to demonstrate this.The implementation is almost entirely taken from
crossterm, with a few tweaks made so it fits in with the current API. I've updated the credit comments accordingly.A few other changes were necessary here:
windows-syscode requiredwindows-sys0.60, so I had to update the version requirementwindows-sys0.60 has an MSRV of 1.71, so I had to bump that as well.