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

Colors are not reset in Windows when using Term::write #69

Closed
r-darwish opened this issue Jun 18, 2020 · 7 comments
Closed

Colors are not reset in Windows when using Term::write #69

r-darwish opened this issue Jun 18, 2020 · 7 comments

Comments

@r-darwish
Copy link
Contributor

r-darwish commented Jun 18, 2020

use console::{style, Color, Term};
use std::io::Write;

fn main() {
    let mut term = Term::stdout();
    term.write_fmt(format_args!(
        "{}",
        style("Grass green. I hate that color!\n").fg(Color::Green)
    ))
    .unwrap();
    term.write_line("Shouldn't be green");
}

The above program works as expected in Windows when used with console v0.10.1. However, with console v0.11.3 the second line is also green.

@r-darwish
Copy link
Contributor Author

Bisection suggests that eb1fa99 introduced the issue.

@pksunkara pksunkara self-assigned this Jul 1, 2020
@pksunkara
Copy link
Collaborator

I will get to this in a few days. But this should be an easy fix if you are willing to make a PR.

@pksunkara
Copy link
Collaborator

Also, what's the window version you are using?

@pksunkara pksunkara removed their assignment Jul 1, 2020
@r-darwish
Copy link
Contributor Author

Window 10 version 2004

@pksunkara
Copy link
Collaborator

  • Is the commit before that working?
  • Do you have windows-console-colors feature enabled?
  • What are the values of Term::is_msys_tty and Term::is_tty?

@mitsuhiko
Copy link
Collaborator

mitsuhiko commented Dec 25, 2020

@pksunkara definitely broken now. Looking at the code now I wonder if this is not a bit too much hackery for getting this working on an effectively unsupported windows version. At the very least we should make the windows-console-colors feature optional.

@pksunkara
Copy link
Collaborator

This is fixed in 0.14.0 of console and will be propagated to dialoguer

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

No branches or pull requests

3 participants