Closed jabbalaci closed 3 years ago
Rich works with light backgrounds. It will use the color theme set by your terminal software.
The Syntax class use pygments, and you can select any of the pygments themes there.
Thanks. Well, it looks like this for me: https://i.imgur.com/kJPEoZy.png . I use Konsole with a light background. The "True" is hardly visible.
That's using one of the 16 standard colors (bright green in this instance) set by your terminal. Whoever designed the light theme for Konsole decided that looked good on a white background, but I would agree with you that it lacks contrast.
I'd suggest picking another light color theme in Konsole. Or if you like, you can configure Rich with a custom theme.
>>> from rich.console import Console
>>> from rich.theme import Theme
>>> console = Console(theme=Theme({'repr.bool_true': "italic green"}))
>>> console.print(True, False, None)
Thanks. I'm not good at creating an own style, but pygments has several styles:
>>>
>>> from pygments.styles import get_all_styles
>>>
>>> list(get_all_styles())
['borland', 'xcode', 'pastie', 'emacs', 'vim', 'rainbow_dash', 'igor',
'algol', 'murphy', 'native', 'lovelace', 'algol_nu', 'rrt', 'arduino',
'paraiso-dark', 'trac', 'fruity', 'colorful', 'friendly', 'vs', 'perldoc',
'autumn', 'monokai', 'abap', 'default', 'paraiso-light', 'tango', 'bw', 'manni']
>>>
>>>
Is it possible to specify one of them for rich to use? Then I would try all and pick the one that looks best on my terminal.
The Pygments theme applies to the Syntax class only. You would be better off find a theme for Konsole itself.
Thanks. I tried all the Konsole light themes, but I don't like the result in any of them. Well, maybe I will try another terminal app., but Konsole was the best for me so far.
iTerm is my favorite.
I use Linux.
I would like to use rich but by default it's made for dark background terminals. I prefer light background. How to set its color theme? Is there a config file for rich (or pygments) where I could change the color theme? Thanks.