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

Colored output out of order WinApi #38

Closed
TimonPost opened this issue Oct 21, 2018 · 4 comments
Closed

Colored output out of order WinApi #38

TimonPost opened this issue Oct 21, 2018 · 4 comments
Assignees
Labels

Comments

@TimonPost
Copy link
Member

There is a problem occurring where WinaApi is the default like Windows 7,8.

Here's the code:

    let crossterm = Crossterm::new();
    ...

    println!("Currently, only Keycloak is supported as Identity Provider. When setting the");
    println!(
        "IDP URL, please note that you will have to pass {} of Keycloak.\n",
        crossterm
            .paint("the exact path to the saml client")
            .with(Color::Yellow)
    );

But it gets displayed as this:
image

As you can see, the "the exact path to the saml client" gets put to the start of the message. It also seems like the color is cleared to "white" instead of the default gray.

To print an colored text in the middle of a phrase you can call into_displayable() on a StyledObject. But with WinApi the colored text will not be at the place you have placed the formatting {} symbols. But instead, it will be printed at the start of the console.

Here you have some code to reproduce.

fn main()
{
    let screen= Screen::default();
    let crossterm = Crossterm::new(&screen);

    println!(
        "Some text line 1 \n \
          Some test line to {} and more text.\n",
        crossterm
            .style("Some yellow collored text")
            .with(Color::Yellow)
            .into_displayable(&screen)
    );
}

I don't really know what this is I think it has to be doing something with buffering of text. Like when you call into_dispayable() your text will be written with WinApi. Maybe because of that WinApi will write first before rust writes the text to the console.

@TimonPost TimonPost added the bug label Oct 21, 2018
@TimonPost TimonPost changed the title Console color bug WinApi Colored output out of order WinApi Oct 21, 2018
@TimonPost TimonPost added this to the 0.5.0 milestone Nov 14, 2018
@TimonPost TimonPost self-assigned this Nov 14, 2018
@TimonPost
Copy link
Member Author

In version 0.5 this will be partially solved. As long as you don't use alternate screen you won't have problems with it.

@TimonPost
Copy link
Member Author

TimonPost commented Nov 21, 2018

This is partially solved with #44. When you aren't working with alternate screen it is working as expected now @Rukenshia .

@TimonPost TimonPost removed this from the 0.5.0 milestone Dec 28, 2018
@TimonPost
Copy link
Member Author

This will be fully fixed in 0.9

@TimonPost
Copy link
Member Author

Fixed in #115

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

No branches or pull requests

1 participant