Skip to content
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

hatch config show terminal colors don't seem compatible with light terminals #1465

Open
bluss opened this issue May 4, 2024 · 5 comments
Open

Comments

@bluss
Copy link

bluss commented May 4, 2024

Syntax colors in the terminal are nice, but the defaults picked don't seem to be easy to read in light background terminals. I've picked the "GNOME light" theme in gnome-terminal here as a standard reference (but I use another light theme, but the problem is the same.)

Configuration: none (I removed the hatch config file for these screenshots.
Version: Hatch, version 1.10.0

terminal colors screenshot 1
terminal colors screenshot 2

@ofek
Copy link
Sponsor Collaborator

ofek commented May 4, 2024

Can you please tell me what happens when you change the background color here? https://github.com/pypa/hatch/blob/hatch-v1.10.0/src/hatch/cli/config/__init__.py#L36

@bluss
Copy link
Author

bluss commented May 4, 2024

Using "white"

        text = app.config_file.read() if all_keys else app.config_file.read_scrubbed()
        app.output(Syntax(text.rstrip(), 'toml', background_color='white'))

produces

bild

Using '#ffffff'

        text = app.config_file.read() if all_keys else app.config_file.read_scrubbed()
        app.output(Syntax(text.rstrip(), 'toml', background_color='#ffffff'))

produces

bild

Using None

        app.output(Syntax(text.rstrip(), 'toml', background_color=None))

produces

bild

That's readable. Not pretty, but the contrast works, so it's readable. 🙂

@ofek
Copy link
Sponsor Collaborator

ofek commented May 4, 2024

@willmcgugan What should I do here? I'm not sure what is recommended.

@willmcgugan
Copy link

Syntax will use an Pygments theme by default. Pygments themes use RGB colors , which means that changing the background without changing the text colors is unlikely to look good.

You can also use ansi colors, which will render with the user's choice of terminal theme colors. Just set theme="ansi_light" or theme="ansi_dark".

@bluss
Copy link
Author

bluss commented May 5, 2024

I would suggest to keep it simple, because programs like gcc, rustc, ls, rg etc output colorful text without trying to know which background color the terminal has.

Pick a syntax coloring with few classes (few different colors or styles) and use ansi colors, I guess?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants