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

Feature: Drop Jansi since Windows 10 now supports ANSI escape codes #25

Closed
dialex opened this issue Dec 20, 2019 · 4 comments · Fixed by #45
Closed

Feature: Drop Jansi since Windows 10 now supports ANSI escape codes #25

dialex opened this issue Dec 20, 2019 · 4 comments · Fixed by #45
Assignees
Milestone

Comments

@dialex
Copy link
Owner

dialex commented Dec 20, 2019

I read that Windows 10 now supports ANSI escape codes natively. (sources: 1, 2)

We currently depend on Jansi precisely because it allowed us to bypass that limitation on Windows. If that's no longer the case, we can drop that dependency. Even better, we can merge our current NixColoredPrinter and WinColoredPrinter into a single class!

@dialex
Copy link
Owner Author

dialex commented Dec 21, 2019

On a Windows 10, I executed the demo code with a NixPrinter (which doesn't use Jansi and uses ANSI escape codes directly). The screenshot is from Command Prompt, but Powershell had the same behaviour:

Capture

It seems Windows can't handle ANSI color codes as it was said... am I doing something wrong?

@dialex
Copy link
Owner Author

dialex commented Dec 21, 2019

The Windows 10 feature that allows ANSI color codes is named "Virtual Terminals" (source)

That feature is not enabled by default, there are a few viable solutions to that:

  • JCDP responsibility -- we make a native Win10 call to enable the feature (once per execution)
    • 👍 transparent to the user
    • 👎 we remove Jansi, but we must add sun.jna (code snippet)
  • user responsibility -- they enable the Win10 feature globally on their machine (one time)
    • 👍 our lib has less dependencies
    • 👎 most users will think JCDP doesn't work and give up

This win10colors.cmd is a good file to debug ANSI color codes on Windows.

@dialex
Copy link
Owner Author

dialex commented Dec 21, 2019

Weird thing, I executed the win10colors.cmd file on my Windows machine and it displayed colors, even though the script doesn't enable the feature and even though I don't have it enabled 🤷‍♂

It's been a year since that feature was released, so maybe now it's ON by default

@dialex
Copy link
Owner Author

dialex commented Dec 30, 2019

I had to go with JCDP responsibility -- we make a native Win10 call to enable the feature (once per execution), to solve PowerShell/PowerShell#11449

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

Successfully merging a pull request may close this issue.

1 participant