Unfortunately, rich cannot autodetect the terminal background, so it's not possible to adjust explain colors based on it. (This comment suggests that rich already adapts to the terminal color scheme, but I didn't notice that in the samples below). A few options I see:
- Do nothing and rely on that the default colors are good enough on most terminal bgs.
- Define a set of bg colors that we want to support and try to find colors that are better than the defaults on these bgs
- Don't use any color and instead rely on bolding, underlining, and (maybe) reversing for highlights.
- Use another package to autodetect the background and adjust accordingly. For python, shell-term-background looks promising.
Technically, any colors could be used as a terminal background color, which means that no color is safe to use in explain. However, it's probably safe to assume that most people run a terminal that is either close to black or close to white, rather than red, green, blue, etc (maybe we can even go so far to say that the only light color bg we need to account for is the default light one for iTerm2 on OSX?) The error messages area already clear on terminal backgrounds that are close to black. Some examples of other terminal backgrounds:

Unfortunately, rich cannot autodetect the terminal background, so it's not possible to adjust
explaincolors based on it. (This comment suggests that rich already adapts to the terminal color scheme, but I didn't notice that in the samples below). A few options I see:Technically, any colors could be used as a terminal background color, which means that no color is safe to use in
explain. However, it's probably safe to assume that most people run a terminal that is either close to black or close to white, rather than red, green, blue, etc (maybe we can even go so far to say that the only light color bg we need to account for is the default light one for iTerm2 on OSX?) The error messages area already clear on terminal backgrounds that are close to black. Some examples of other terminal backgrounds: