-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Feature request: Add support for "reverse" color effect #74
Comments
bwpge
changed the title
Feature: Add support for "reverse" color effect
Feature request: Add support for "reverse" color effect
May 21, 2023
Adding additional reference for Windows implementation. Since References: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: