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

Closed
bluss opened this issue May 4, 2024 · 9 comments · Fixed by #1529
Closed

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

bluss opened this issue May 4, 2024 · 9 comments · Fixed by #1529

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
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
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?

@ofek
Copy link
Collaborator

ofek commented May 25, 2024

I'm just going to remove the explicit background color for broader compatibility even though on light terminals it might not be as pretty like you mentioned. If you require configurability (and can provide example keyword arguments that look good) feel free to open a separate feature request!

@ofek
Copy link
Collaborator

ofek commented May 26, 2024

Just as a heads up (mostly for Will) the background_color option must be set to default for tests because otherwise a bunch of spaces get written at the end of each line I think based on the terminal size. That may be in fact why I did that originally 😅

@bluss
Copy link
Author

bluss commented May 26, 2024

Ok, thanks for that. What do you think about a config option that turns off syntax highlight for this?

@ofek
Copy link
Collaborator

ofek commented May 26, 2024

Sure I can do that.

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

Successfully merging a pull request may close this issue.

3 participants