colored-rs / colored

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

Colour output does not work in IntelliJ integrated run window #106

Closed JakeStanger closed 2 years ago

JakeStanger commented 2 years ago

Not sure if this is something getting incorrectly detected in this library, or a bug with the IDE, but colours set by this library don't display inside the IDE's integrated run output. This is possibly because it's internally redirected?

Repro:

use colored::*

fn main() {
  println!("{}", "hello world".blue())
}

In the IDE: image

In Kitty: image

fhars commented 2 years ago

This is most likely a case of things working as expected (given that you have to force color output for cargo, you will probably also have to do that for your program).

Things to check are:

C.f. the logic in ShouldColorize::from_env() https://github.com/mackwic/colored/blob/015f2a58bfac8da6f0db8518c6813c79ec063f7f/src/control.rs#L105

mackwic commented 2 years ago

HI @JakeStanger, thank you for reporting this. Unfortunately, I have to close it as we lack actionnable information.

Feel free to reopen with more data if you can.

Directory commented 2 years ago

what actionable information is needed?

Directory commented 2 years ago

solution

JakeStanger commented 2 years ago

Hey, sorry for ignoring this for so long! It's been on my to-list, just never quite high enough :upside_down_face:

It looks like the Jetbrains IDEs in fact do not use a terminal for the run window by default, so this is on them. Now that their rust plugin supports running under a terminal emulator (feature added in the solution linked above) it looks like we're good.

Also, since this is on them, this can definitely remain closed :)