You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the reverse effect instead of hardcoding "black/white on green background" or something similar provides more consistent styled output, since many terminal themes use different primary/intense colors than the background color.
It also properly handles light and dark backgrounds, which cannot be determined using 16 theme colors. Hardcoding RGB colors can guarantee legible output, but will not be consistent with the user's theme.
Proposed Feature
ColorSpec could offer reverse and set_reverse methods, similar to effects such as bold and underline.
/// A color specification.#[derive(Clone,Debug,Eq,PartialEq)]pubstructColorSpec{fg_color:Option<Color>,bg_color:Option<Color>,bold:bool,reverse:bool,// addedintense:bool,underline:bool,dimmed:bool,italic:bool,reset:bool,strikethrough:bool,}
For the WriteColor implementation for Ansi<W>, a small adjustment might work fine for non-Windows terminals;
I have no clue how windows handles this, nor am I familiar with GetConsoleMode or SetConsoleMode. It seems some of that is handled by the winapi-utils crate, so I haven't really dug in too much on it.
Just wanted to prefix this with a sincere thank you for all your hard work and great libraries/tools you given to us 馃槃
I tried searching the closed issues for anything related to "reverse", "invert", or "negative" keywords but did not find anything.
Issue
termcolor
does not expose any way to use the "reverse" color effect (seen = 7
: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters).Using the reverse effect instead of hardcoding "black/white on green background" or something similar provides more consistent styled output, since many terminal themes use different primary/intense colors than the background color.
It also properly handles light and dark backgrounds, which cannot be determined using 16 theme colors. Hardcoding RGB colors can guarantee legible output, but will not be consistent with the user's theme.
Proposed Feature
ColorSpec
could offerreverse
andset_reverse
methods, similar to effects such as bold and underline.Usage might look something like:
Naive Implementation
Adding a field to
ColorSpec
:For the
WriteColor
implementation forAnsi<W>
, a small adjustment might work fine for non-Windows terminals;Windows Considerations
I have no clue how windows handles this, nor am I familiar with
GetConsoleMode
orSetConsoleMode
. It seems some of that is handled by thewinapi-utils
crate, so I haven't really dug in too much on it.References
Value = 7
, called "Negative": https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-formattingThe text was updated successfully, but these errors were encountered: