colored-rs / colored

(Rust) Coloring terminal so simple you already know how to do it !
Mozilla Public License 2.0
1.74k stars 84 forks source link

Not working on windows #59

Open sk-Prime opened 5 years ago

sk-Prime commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

lovasoa commented 4 years ago

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

steelx commented 4 years ago

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

timvisee commented 3 years ago

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

kurtlawrence commented 3 years ago

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 commented 3 years ago

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

image

constituent commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 7 months ago

This is working well for me:

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

   ...
}