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

Not working on windows #59

Open
sk-Prime opened this issue Aug 3, 2019 · 12 comments
Open

Not working on windows #59

sk-Prime opened this issue Aug 3, 2019 · 12 comments

Comments

@sk-Prime
Copy link

sk-Prime commented Aug 3, 2019

It is showing numbers rather than color. in this case blue
Capture

Though i have added control::set_virtual_terminal(true); in my source file.
Capture

@kurtlawrence
Copy link
Collaborator

Hi @sk-Prime,

What version of Windows are you running? Which console?

I believe the virtual terminal sequence support is only available in Windows 10.

@sk-Prime
Copy link
Author

in windows seven it doesn't work. but colour crate perfectly works. but i liked colored approach.

@lovasoa
Copy link

lovasoa commented Mar 30, 2020

Yes, I can confirm it doesn't work on windows. Could this be mentioned in the README until it's fixed ?

@steelx
Copy link

steelx commented Apr 27, 2020

im using Windows 10 with devmode on.
doesnt work on Windows Terminal neither on CMD.

@timvisee
Copy link

timvisee commented Feb 5, 2021

Same issue. Both in cmd and PowerShell. Fresh Windows 10 installation.

@kurtlawrence
Copy link
Collaborator

Hi all,

Could you please provide details about your OS, what shell/terminal you are using, an example of your code that does not work and a screenshot with the output showing it not working. Even the Rust toolchain you are using could be the issue.

I ask for this information as I am unable to reproduce on my machine, and in my experience with Rust production code, running on many machines (all Windows 10) that use colored there have been no issues when using the set_virtual_terminal flag.

@Timmmm
Copy link

Timmmm commented May 2, 2021

It works for me in the Command Prompt and Powershell. Windows 10.0.19042.928.

image

@constituent
Copy link

I have encountered the same issue.
When I run "cargo run" while developing, it works perfectly, even with cmd.exe. However, with the compiled binary, whether debug or release mode, whether cmd or powershell, the control chars are displayed instead of color.

@constituent
Copy link

Oh I think I find the answer. As the doc of ansi_term suggests, On Windows 10, the application must enable ANSI support first: let enabled = ansi_term::enable_ansi_support();

@kurtlawrence
Copy link
Collaborator

Oh I think I find the answer. As the doc of ansi_term suggests, On Windows 10, the application must enable ANSI support first: let enabled = ansi_term::enable_ansi_support();

@constituent did you try using https://docs.rs/colored/2.0.0/x86_64-pc-windows-msvc/colored/control/fn.set_virtual_terminal.html?

@constituent
Copy link

Oh I think I find the answer. As the doc of ansi_term suggests, On Windows 10, the application must enable ANSI support first: let enabled = ansi_term::enable_ansi_support();

@constituent did you try using https://docs.rs/colored/2.0.0/x86_64-pc-windows-msvc/colored/control/fn.set_virtual_terminal.html?

I can't quite remember, but probably not
And as I tried just now, set_virtual_terminal works as fine as ansi_term::enable_ansi_support for me

@hseager
Copy link

hseager commented Apr 21, 2024

This is working well for me:

fn main() {
    if cfg!(target_os = "windows") {
        control::set_virtual_terminal(true).unwrap();
    }

   ...
}

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

No branches or pull requests

8 participants