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

Support ANSI escape sequence output on more Windows consoles #11622

Merged

Conversation

HertzDevil
Copy link
Contributor

Some consoles like Windows Terminal and the integrated one in Visual Studio Code already support ANSI escape sequences, but they are disabled on the system command prompt and Windows Powershell by default:

require "colorize"

puts "red".colorize.red.on_white # => <ESC>[31;107mred<ESC>[0m
# (where <ESC> is actually \x1B)

This patch enables them, so Colorize should work on a wider variety of consoles. This should work on Windows 10 build 1511 and above. It does not enable input sequences yet (e.g. ^[[A for cursor up whenever reading from STDIN).

@HertzDevil HertzDevil added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:text labels Dec 19, 2021
@straight-shoota straight-shoota added this to the 1.3.0 milestone Dec 29, 2021
@straight-shoota straight-shoota merged commit c3ab220 into crystal-lang:master Jan 3, 2022
@HertzDevil HertzDevil deleted the feature/windows-console-esc branch January 5, 2022 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:text
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants