Skip to content
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

Colors in Windows Console #548

Closed
1 task done
antiz opened this issue Oct 23, 2018 · 3 comments
Closed
1 task done

Colors in Windows Console #548

antiz opened this issue Oct 23, 2018 · 3 comments

Comments

@antiz
Copy link

antiz commented Oct 23, 2018

  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

Poetry currently suppresses ANSI color codes on Windows. (ref #159)
Modern versions of Windows do in fact support a large number of VT sequences, but applications have to opt-in to this behavior.

Details

Starting with Windows 10 TH2, also known as version 1511, virtually all commonly used VT sequences are supported. However, due to backwards compatibility, applications need to set the ENABLE_VIRTUAL_TERMINAL_PROCESSING console flag to activate this functionality.

The CPython interpreter does not set this flag automatically.
See this comment for more details on the version numbers and some confusion regarding the availability of this feature.

Side note: Build 10.0.14931 is when the console (additionally) gained support for 24-bit colors/truecolor.

Expected behavior / Enhancement

Check the Windows version upon launch (e.g. with platform.version()).
If the version is too old (e.g. Windows 7, Windows 10 TH1, etc.) continue to suppress VT sequences by default, otherwise set the appropriate console flag and emit ANSI codes/VT sequences.

Demonstration

import ctypes

print("\033[38;5;208mpeach\033[0;00m")

kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)

print("\033[38;5;208mpeach\033[0;00m")

This might serve as a more thorough example of an implementation..

The registry key HKEY_CURRENT_USER\Console\VirtualTerminalLevel controls the default behavior of this functionality (opt-in vs opt-out). Using that and poetry --ansi I can indeed get colored output.


Should this be handled in sdispater/cleo instead?

@fralik
Copy link

fralik commented Jun 5, 2019

For people using ConEmu and who still do not have colors. You have to enable settings Inject ConEmuHk and ANSI and xterm sequences in ConEmu settings. You will find it in Settings -> Features.

@sdispater
Copy link
Member

I think this should be fixed in the latest beta release.

Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants