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

Coloring not working on Windows #26

Closed
HipyCas opened this issue Jan 25, 2021 · 9 comments
Closed

Coloring not working on Windows #26

HipyCas opened this issue Jan 25, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@HipyCas
Copy link
Contributor

HipyCas commented Jan 25, 2021

Describe the bug
On v0.4.2, in a Windows 10 machine, printing and listing works perfectly, but it does not get the colors out, instead, it shows �[0m at the end of each item. When switching to the WSL, the color show properly. Therefore, it is to conclude that the Windows DOS shell does not understand the Unix colour codes.
During the edition of the screenshots, I realized that in some files, at the beginning appeared �[1m�[38;2;176;114;25mA in a couple of files.

To Reproduce
Steps to reproduce the erroneous behaviour on Windows:

  1. Get on a Windows 10 Command Prompt
  2. Execute the .exe file (in my case, executed directly from the downloads folder)
  3. It takes long to start and to print each (with --no-color everything goes faster), but you will see that with the first element, it shows �[0m at the end of it.

Steps to reproduce proper behaviour on WSL (Debian):

  1. Start up the WSL (Debian in my case) in a Windows 10 Command Prompt
  2. Execute the downloaded binary for the Linux platform
  3. Takes less to start, and the characters shown in Windows do not appear, while color does.

Expected behaviour
As it is intended to do, and as it does on the WSL, it should colourize the items properly.

Screenshots
Screenshot of the first execution on Windows:
Screenshot 2021-01-25 133722

Screenshot of execution with the --no-color flag on Windows:
Screenshot 2021-01-25 135149

Screenshot of execution in Debian WSL (sh shorthand for debian run):
Screenshot 2021-01-25 135958

@HipyCas HipyCas added the bug Something isn't working label Jan 25, 2021
@The-Noah
Copy link
Owner

Can you run colortool -c and send a screenshot of the output?

If you don't have ColorTool downloaded, you can get it here.

@HipyCas
Copy link
Contributor Author

HipyCas commented Jan 26, 2021

Here goes the screenshot:
Screenshot 2021-01-26 125342

@The-Noah
Copy link
Owner

That's very strange. I was thinking colortool would output strange characters as well but it's working fine.

I'm going to assign this to @MattPlays since he wrote a lot of the color code.

@MattPlays
Copy link
Contributor

I took a stab at it and came up with absolutely nothing, it works for @The-Noah but not for me or you @HipyCas which is the confusing part.

@HipyCas
Copy link
Contributor Author

HipyCas commented Jan 26, 2021

Maybe it is due to some configuration on the Windows prompt? @The-Noah have you applied any configuration to the prompt or console?

@The-Noah
Copy link
Owner

I have no clue if I've configured cmd.

@MattPlays
Copy link
Contributor

Maybe it is due to some configuration on the Windows prompt? @The-Noah have you applied any configuration to the prompt or console?

It is, Some versions of Windows don't have ENABLE_VIRTUAL_TERMINAL_PROCESSING on by default. The only way to enable it is through Regedit
[HKEY_LOCAL_USER\Console]
"VirtualTerminalLevel"=dword:00000001
or by calling the Window's API directly which as far as i could look is not currently support in Rust without using crates(Which we want to stay far away from)

@The-Noah
Copy link
Owner

The-Noah commented Jan 26, 2021

The only way to enable it is through Regedit

[HKEY_LOCAL_USER\Console]
"VirtualTerminalLevel"=dword:00000001

I found that VirtualTerminalLevel was set to 1 and changing it to 0 breaks it, just like how y'all's is.

or by calling the Window's API directly which as far as i could look is not currently support in Rust without using crates(Which we want to stay far away from)

I think we can use an extern function to directly call the Win32 API.

@The-Noah The-Noah assigned The-Noah and unassigned MattPlays Jan 30, 2021
@The-Noah
Copy link
Owner

This has been fixed in dbbe3e0. Thank you both for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants