Canop/coolor

Crossterm Reset != Black

joshka opened this issue · 3 comments

joshka commented

Hi there. I was taking a read of the source and noticed that crossterm::Color::Reset gets translated to Black.

CC::Reset => 0.into(),

This is correct only for terminal themes that have their background color and black set to the same value (e.g. all light themes are excluded by this).

Visually, here's the output of the color example from Ratatui (note the color names are Ratatui names, not crossterm ones):

colors

I'm not sure what the right design for this should be in coolor as it seems like it would be use case dependent, but perhaps adding an explicit Reset variant to the color enum. Do you think it would be worth marking this as non-exhaustive to allow adding other color models?

Canop commented

The thing is, coolor deals with colors and Reset isn't really a color.
Reset should probably be normally dealt with before calling into. Maybe with a function returning an Option<Color>.

joshka commented

Yeah - that was my sort of thinking too, but I wasn't sure what sorts of use cases would lead to using that method.

My interest in this particular crate was mainly piqued by wondering whether there is value to adding conversions for Ratatui colors.

Canop commented

My interest in this particular crate was mainly piqued by wondering whether there is value to adding conversions for Ratatui colors.

I don't know if that would be useful but it would be clean and straightforward from what I see of ratatui Color, so go ahead if you want.