Open mr-tz opened 10 months ago
We color the output using the 16 named ANSI colors here: https://github.com/mandiant/capa/pull/1697/files#diff-fe1c2d3620e13ab3bc93755b55f86a8a561bbb45000da79a1b31de56fb40cde6R29
def bold(s: str) -> str:
"""draw attention to the given string"""
return termcolor.colored(s, "cyan")
def bold2(s: str) -> str:
"""draw attention to the given string, within a `bold` section"""
return termcolor.colored(s, "green")
def mute(s: str) -> str:
"""draw attention away from the given string"""
return termcolor.colored(s, "dark_grey")
def warn(s: str) -> str:
return termcolor.colored(s, "yellow")
So, we don't pick a specific RGB color (since this might conflict with a user's theme). Rather, we use these named colors so that themes can provide a reasonable set of values that work well together. When they don't, like above, there's not too much we can do.
Alternatives:
For (4) we could use, e.g., light_grey
instead of dark_grey
and see if that looks better. We'd have to sample a bunch of themes and configurations to see what worked most consistently. I think we would give the most weight to default terminal settings (like freshly installed Windows Terminal, Gnome Terminal, etc.).
I wonder if we can find any published resources on how to use terminal colors in a consistent and portable way. Like, "use ANSI yellow to do this, and ANSI grey to do that".
show color theme colors:
https://github.com/termcolor/termcolor/blob/main/src/termcolor/__main__.py
default gnome:
default gnome light:
tango dark:
solarized dark:
gnome black on light yellow:
edit: in the surrounding analysis i was only changing the "Text and Background Color" which doesn't include the colors of the characters. So even this isn't correct, for example, here is Solarized on Solarized, and note how the "light" variants aren't even colored!
This also makes clear that Solarized maps "dark grey" to the same color as the background, so its totally invisible.
So, who knows?!?
Maybe normal red/green/yellow/magenta/cyan are most safe, with no good option for "mute".
(original content):
in summary:
my opinion for if we should use the following colors:
for the "ok" colors, generally prefer the "light" variants, because they "pop" more for highlights.
i don't see a great option for "mute". dark grey seems ok, but the original issue text shows a pretty bad case. mabye its a bug with that theme's implementation? what do you all think?
Wow, thanks, that's a good overview.
I agree that we can highlight things fairly reliably but muting isn't ideal. So maybe we don't mute for now / in the CLI.
And preferably, we use red/yellow only for warnings/errors.
can we configure / use colors that are (always) good to see?