timofurrer / colorful

Terminal string styling done right, in Python :snake: :tada:
MIT License
525 stars 23 forks source link

ANSI bright colors are impossible to use #30

Closed airstrike closed 4 years ago

airstrike commented 5 years ago

https://github.com/timofurrer/colorful/search?q=rgb_to_ansi16&unscoped_q=rgb_to_ansi16

Though rgb_to_ansi16 includes a use_bright parameter, the user has no way of passing a True value to the function

timofurrer commented 5 years ago

Good catch, thanks for creating this issue!

I think the change would have to go somewhere in here: https://github.com/timofurrer/colorful/blob/9f95d3eaa6b57b55639c623e55065f8a37eee8e7/colorful/core.py#L103

Basically ANSI_16_COLORS should allow the bright colors in addition to the standard colors when using ANSI_8_COLORS.

I'm not entirely sure yet what the best implementation would look like - because here https://github.com/timofurrer/colorful/blob/9f95d3eaa6b57b55639c623e55065f8a37eee8e7/colorful/core.py#L43 the colorname is already evaluated and something like bright_red would not be found (it's not a valid X11 color, and it depends on the used color palette anyway.) Maybe we need some kind of logic in https://github.com/timofurrer/colorful/blob/9f95d3eaa6b57b55639c623e55065f8a37eee8e7/colorful/core.py#L43 to determine whether the given RGB should be bright in case of the ANSI_16_COLORS mode ...

Any ideas?

github-actions[bot] commented 5 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

airstrike commented 5 years ago

Haven't yet had time to think this through / work on it, but commenting on it so the issue isn't closed just yet.

github-actions[bot] commented 4 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days