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

bgcolor highlighting of ast nodes in traceback may be unreadable #13486

Closed
alexandru-dinu opened this issue Jan 24, 2022 · 6 comments
Closed
Milestone

Comments

@alexandru-dinu
Copy link

alexandru-dinu commented Jan 24, 2022

The commit 3026c20 introduced a change with a hard-coded bg:ansiyellow color.

Unfortunately, for some terminal color schemes, white-on-yellow may be unreadable, for example:
image

Changing to bg:ansired looks better:
image

Is it possible to make this option configurable?

Thank you!

@Carreau
Copy link
Member

Carreau commented Jan 25, 2022

Duplicate #13446

@Carreau Carreau closed this as completed Jan 25, 2022
@Carreau Carreau modified the milestones: 8.1, 8.2 Feb 25, 2022
@amerlyq
Copy link

amerlyq commented Apr 17, 2022

Linked issue is locked, and as I understood it mostly focused on choosing new default color/style instead of exposing Token.ExecutingNode for style_overrides config option.

Mentioning that "bg:ansiyellow" is being only used as fallback in stack_data.style_with_executing_node(style, "bg:ansiyellow") is wrong. Because its value is used as override:

def style_with_executing_node(style, modifier):
    from pygments.styles import get_style_by_name
    if isinstance(style, str):
        style = get_style_by_name(style)

    class NewStyle(style):
        for_executing_node = True

        styles = {
            **style.styles,
            **{
                k.ExecutingNode: v + " " + modifier
                for k, v in style.styles.items()
            }
        }

Therefore we really don't have a way to modify it from user config -- only through modifiying sources itself.

@kanbara
Copy link

kanbara commented Jul 11, 2022

I have spent several hours reading the source and issues trying to override these colours. It's pretty bad for dark backgrounds, and I finally have the normal colours sorted, but I would really really really like the ability for the traceback to be customised-- especially the node colour. It's unusable on dark backgrounds and clashes with everything else.

@DanielO
Copy link

DanielO commented Jul 22, 2022

Being able to customise it would be ideal as currently is illegible on a dark terminal unless you have a muted yellow. Unfortunately I don't know how it's all plumbed together so I am not sure how to make the change.

For iTerm2 at least using anisred for the BG colour is quite legible for both light and dark (when editing the source).

If I change it like so:

        if self.has_colors:
            style = get_style_by_name("default")
            style = stack_data.style_with_executing_node(style, style.styles[pygments.token.Generic.Error])
            formatter = Terminal256Formatter(style=style)

(And add import pigments.token up the top) then it uses the existing error style rather than hard coding it - perhaps that is a suitable solution.

@0xquad
Copy link

0xquad commented Aug 27, 2022

Has there been plans to fix this issue?

First use after many years and experienced the problem immediately. Errors are unreadable, so the tool basically becomes impossible to use normally. I have to run things in a simple python console instead to see anything.

FYI I'm on Windows with Putty (Kitty fork). Tweaking the terminal colors is a huge hack at the very least and not a solution: only IPython outputs unreadable text (white on bright yellow) from all the things I've been using in the past years. (I'm actually surprised that it wasn't fixed before; it really should be a blocking issue in my book. Am I the only one having this issue? Otherwise is there any way I can disable this whole colored output in IPython (not the terminal) in order to restore usability?)

Also the original issue was locked ("off-topic" ?) so no one can comment there. Perhaps work is being done elsewhere?

Thanks for all the efforts put in IPython nonetheless, it's excellent!

Carreau added a commit to Carreau/ipython that referenced this issue Sep 12, 2022
For example put

    from IPython.core.ultratb import VerboseTB
    VerboseTB._tb_highlight = "bg:#039dfc"

In your ipython_config.py

Mitigate ipython#13446 and ipython#13486
@Carreau
Copy link
Member

Carreau commented Sep 12, 2022

See #13756 as a workaround. But really most of the open issue that are not fixed is really because someone need to dive into them and do the work.

shaperilio pushed a commit to shaperilio/ipython that referenced this issue Nov 15, 2022
For example put

    from IPython.core.ultratb import VerboseTB
    VerboseTB._tb_highlight = "bg:#039dfc"

In your ipython_config.py

Mitigate ipython#13446 and ipython#13486
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

6 participants