-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
lib/std/fs/File: enable VT seq support for Windows Console #18692
lib/std/fs/File: enable VT seq support for Windows Console #18692
Conversation
Nice thorough writeup! Note, though, that this sort of thing was closed without merging before in #15206:
Note also that the API in So perhaps this logic might be better suited as a helper function in |
This is exactly what PowerShell/PowerShell#2991 does, application should save original console mode and restore it before exiting. This pull request currently doesn't implement that, since it was originally a PoC. No matter what, I think 0d2a328 is safe to merge, since it enables the user to implement save/load logic, or just ignore the risk and enable VT seq support themselves. Should I open a new PR for that? |
- From lib/libc/include/any-windows-any/wincon.h#L235 - See also https://learn.microsoft.com/en-us/windows/console/setconsolemode - Also add DISABLE_NEWLINE_AUTO_RETURN constant which will be used by SetConsoleMode in lib/std/os/windows.
* Newer versions of Windows added VT seq support not only in Windows Terminal, but also in the old-fashioned Windows Console (standalone conhost.exe), though not enabled by default. * Try setting the newer console mode flags provides better experience for Windows Console users. Co-authored-by: Kexy Biscuit <[email protected]>
cbc7aaa
to
7f875f1
Compare
Zig 0.12.0 doesn't have the SetConsoleMode function implemented in the standard library, but this PR - which was accepted recently (ziglang/zig#18692) adds it. So, I just have to wait (don't want to use Zig master)
I was wrong about this, apologies for not checking my assumptions. I've cherry picked the relevant commit from this PR into #20172, which is a revivial of the spirit of this PR. |
Rationale and changes
Examples from BiscuitTin/zig-term-colors
For Windows 10 Enterprise LTSC 2019, the app works as expected in Windows Console. Zig std library checks for (and enables) VT seq support during runtime.
For Windows 10 Enterprise LTSB 2015, Zig std library behaves just like before, no VT seq outputted at runtime.
For Windows 10 Enterprise LTSC 2016, things are a bit more complicated. cmd.exe just works like later Windows versions, but Windows PowerShell 5.1.14393.0 contains a bug, accidentally enabling VT seq support for all applications invoked inside it.
For all other (newer) Windows versions currently Microsoft supports, Windows Console behaves the same as Windows 10 Enterprise LTSC 2019, but Windows Terminal is also available, makes it pointless to guide the user opening Windows Console.