LukasKalbertodt / term-painter

Cross-platform Rust library for coloring and formatting terminal output

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It's not possible to set the color to "default" within `with`

LukasKalbertodt opened this issue · comments

Consider this:

Color::Red.with(||{
    println!("Red {} Red", Color::Normal.paint("Normal"));
});

One wants to reset the color to default within a with block. The code above prints all three words in red. One should be able to somehow reset it.

Resetting just the foreground color is not easy. You have to reset the whole terminal and reapply the attributes that should be preserved. There should be a method like reset_fg, but Color::Normal shouldn't do that implicitly.

A note in the documentation was added.