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

Windows 7 grey/white foreground swapped #263

Closed
MaulingMonkey opened this issue Sep 29, 2019 · 5 comments · Fixed by crossterm-rs/crossterm-style#5
Closed

Windows 7 grey/white foreground swapped #263

MaulingMonkey opened this issue Sep 29, 2019 · 5 comments · Fixed by crossterm-rs/crossterm-style#5

Comments

@MaulingMonkey
Copy link

MaulingMonkey commented Sep 29, 2019

crossterm-style 's WinApiColor backend applies INTENSITY to Grey instead of to White:

Foreground should be swapped around.
Background should be left alone, based on cmd.exe / powershell.exe's behavior.

Background is often - but not always - "wrong" inside of VS Code, including in VS Code's "Default Dark+" theme, but VS Code's themes are an inconsistent and incoherent mess on this front (sometimes INTENSITY makes the background darker in a dark theme, lighter in a dark theme, sometimes it's just plain ignored, sometimes other colors also get inverted brightening behavior, etc. etc. etc.)

Windows 7 (cmd.exe)

  • Foreground: Wrong
  • Background: OK

win7-cmd

The current behavior appears to be correct for backgrounds, but not for foregrounds, as it makes "white" darker than "grey". Using the same flush-heavy demo from #262

Windows 10 (cmd.exe)

  • Foreground: OK
  • Background: OK

win10-cmd

This is just provided as a reference.

Windows 7 (VS Code, Default Dark+ Theme)

  • Foreground: Wrong?
  • Background: Wrong

win7-vscode

Windows 10 (VS Code, Default Dark+ Theme)

  • Foreground: OK
  • Background: Identical

win10-vscode

Test Code

Same as #262 's flush-heavy version:

use crossterm_style::*;
use std::io::{stdout, Write};

fn main() {
    for color in &[Color::Black, Color::DarkGrey, Color::Grey, Color::White] {
        let color = *color;
        print!("{}", Colored::Fg(color));
        stdout().flush().unwrap();
        print!("fore");
        stdout().flush().unwrap();
        print!("{}", Colored::Fg(Color::Reset));
        stdout().flush().unwrap();
        print!(" ");
        stdout().flush().unwrap();
        print!("{}", Colored::Bg(color));
        stdout().flush().unwrap();
        print!("back");
        stdout().flush().unwrap();
        print!("{}", Colored::Bg(Color::Reset));
        stdout().flush().unwrap();
        print!(" {:?}", color);
        stdout().flush().unwrap();
        println!();
    }
}
@MaulingMonkey MaulingMonkey changed the title Windows 7 grey/white swapped Windows 7 grey/white foreground swapped Sep 29, 2019
@TimonPost
Copy link
Member

Did you use WinAPI for windows 10? If so, isn't this a windows interpretation problem since Windows 10 seems to be behaving correctly?

@TimonPost
Copy link
Member

Powershell windows 10 pro

image

@MaulingMonkey
Copy link
Author

Windows 10 cmd/powershell seems to be behaving OK, presumably because it's using the ANSI backend.

Windows 7 cmd/powershell isn't, presumably because it's using the WinAPI backend.

@TimonPost
Copy link
Member

As you see my comment were I disabled ansi you can see that it isn't correct as well. I think we need to swap those colors and see if that fixes the problem

@TimonPost
Copy link
Member

TimonPost commented Oct 8, 2019

Fixed by: crossterm-rs/crossterm-style#5

Powershell WinApi windows 10

image

CMD WinApi windows 10
image

CMD Windows 7 WinApi

image

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

Successfully merging a pull request may close this issue.

2 participants