-
Notifications
You must be signed in to change notification settings - Fork 242
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
Native VT support in Windows #197
Comments
Be aware that before Windows 10 build 1809 you could crash the console with certain ANSI codes. |
Well worth knowing before I invest too much time into this. Thanks. In case you're interested, I've found that all the sample code is running fine in WSL (using a Linux Python installation). It's nice to (finally) see the animated Julia set running full colour in Windows! |
@peterbrittain a fix has been delivered in 1809, you can probably start looking into this now :) |
In case it helps, this is a minimal working example of enabling the support: import platform
if platform.system() == 'Windows':
from ctypes import windll
kernel32 = windll.kernel32
try:
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), kernel32.GetConsoleMode()|7)
except Exception as e:
raise OSError("Could not enable color handling") from e |
According to a dev blog (https://blogs.msdn.microsoft.com/commandline/2018/12/10/new-experimental-console-features/), Windows 10 natively supports ANSI escape codes sufficiently well to run most Linux curses apps inside WSL. That should mean that we can get a much better experience for Windows 10 users if we create a new Screen sub-class that simply uses the ANSI escape codes instead of the win32 console API.
A quick trial shows that ANSI escape codes inside CMD.exe do indeed work and provide at least 256 colour support. Nice!
The idea here is that we give Windows 10 users a much better experience by spotting this at the time the Screen is opened and giving an ANSI terminal instead. In theory this is almost exactly the existing _CursesScreen implementation (for colours and cursor movement), but with hard-coded ANSI escape codes.
The text was updated successfully, but these errors were encountered: