Skip to content

Windows: enable ANSI escape support in console - #517

Merged
asottile merged 2 commits into
pre-commit:masterfrom
hackedd:windows-color
Apr 7, 2017
Merged

asottile merged 2 commits into
pre-commit:masterfrom
hackedd:windows-color

Conversation

@hackedd

@hackedd hackedd commented Apr 1, 2017

Copy link
Copy Markdown
Contributor

As of Windows 10, the Windows console supports (some) ANSI escape sequences, but it nees to be enabled using SetConsoleMode first.

If more extensive support is needed, or you want this to work on earlier versions of Windows, it would be probably be better to use a package like colorama instead, which automatically translates ANSI escape sequences to the equivalent Windows API calls. It also contains functions to format colored text.

This fixes #198.

@asottile

asottile commented Apr 5, 2017

Copy link
Copy Markdown
Member

Oh hmm! I was under the impression that windows had its own set of color escapes -- would those be more portable to more versions of windows?

Sorry I've been so slow to get to this, I've been traveling :)

@hackedd

hackedd commented Apr 7, 2017

Copy link
Copy Markdown
Contributor Author

I'm not aware of any color escapes for the windows terminal. As far as I know, for earlier versions of Windows, text attributes can only be set by calling the SetConsoleTextAttribute function (which is what colorama does).

@asottile

asottile commented Apr 7, 2017

Copy link
Copy Markdown
Member

Ok! In that case this seems fine -- can you add the new file to the excluded files in .coveragerc

@asottile
asottile merged commit 1be4e4f into pre-commit:master Apr 7, 2017
@asottile

asottile commented Apr 7, 2017

Copy link
Copy Markdown
Member

Thanks!

@asottile

Copy link
Copy Markdown
Member

This feature is in 0.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Color support

2 participants