-
-
Notifications
You must be signed in to change notification settings - Fork 529
Enable/Disable ANSI Sequences on Windows. #275
Conversation
@zmwangx @dertuxmalwieder can you guys please review this PR? |
Setting use_colors up to three times looks inefficient. It might work though. Is it designed to work with both cmd and ConEmu? (I remember having patched such for buku.) Sent with GitHawk |
@guilt please take a look at the relevant Buku code. |
Discussed here: jarun/buku#217 |
This is only designed to work with standard cmd. There's plenty of Windows applications which are non Command mode / CLI applications and they shouldn't be affected by the change. The default option, to disable color is the safest if one cannot enable the console mode. This is still IMO better than the original. |
@guilt does the patch mentioned above work for you? |
The patch above should work. But yes, what it does is disable ANSI in standard Command Prompt and only enable it in ConEmu. This one does not do ConEmu but selectively enables ANSI sequences on Command Prompt (which was historically the main problem child, warranting the creation of ConEmu/what not). This one is also not required for WSL, where things work. If there's a detection for ConEmu, I'd want someone to look into support for popular emulated environments on Windows, such as Mintty as well. Here's a comprehensive list: https://alternativeto.net/software/conemu/?platform=windows |
Anyway, my patch works for me. I'm removing my fork and keep this PR as reference. Can't spend more time on it. Sorry. |
Seems okay functionally, but code isn't very understandable (quite a few magic numbers) and I'd be cautious to include code I don't understand. Since you don't want to spend more time on this, I guess I'll rewrite it later while cross referencing colorama's win32 implementation. A brief look tells me that you might have only modified stdout (where the magic number -11 comes from) but not stderr. |
Update: please ignore the "wrong place" part of the previous comment. I only glanced at the code and somehow had the wrong impression. |
VT100 control sequences are supported in cmd and PowerShell starting from Windows 10 Anniversary Update, but only if the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is set on the screen buffer handle using SetConsoleMode. Setting this flag does not seem to negatively affect third party terminal emulators with native ANSI support such as ConEmu, so hopefully there's no regression. References: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences https://docs.microsoft.com/en-us/windows/console/setconsolemode Credits: jarun#275 tartley/colorama#139
VT100 control sequences are supported in cmd and PowerShell starting from Windows 10 Anniversary Update, but only if the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is set on the screen buffer handle using SetConsoleMode. Setting this flag does not seem to negatively affect third party terminal emulators with native ANSI support such as ConEmu, so hopefully there's no regression. References: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences https://docs.microsoft.com/en-us/windows/console/setconsolemode Credits: jarun#275 tartley/colorama#139
Similar to jarun/ddgr#87