python icon indicating copy to clipboard operation
python copied to clipboard

White text on yellow background is not visible

Open ghost opened this issue 1 year ago • 10 comments

This is the error message that is displayed in case of error image

The yellow background renders the white text not readable.

Can we change background?

Thanks

ghost avatar May 05 '24 16:05 ghost

Screenshot 2024-10-20 at 23 07 32

This also affects code completion options from the terminal in ipython.

Pilgrim1379 avatar Oct 20 '24 22:10 Pilgrim1379

Hey :wave:,

This is the error message that is displayed in case of error

Am I right in saying that this is when IPython is configured? I'd like to try and resolve this but I'm not sure how to replicate this scenario off the top of my head.

Could you please provide step by step reproduction instructions including the instructions you followed to install the Catppuccin theme?

Thanks!

sgoudham avatar Oct 25 '24 19:10 sgoudham

In my case I'm using wezterm 20240203-110809-5046fc22 which comes with Catppuccin built-in. I've enabled the theme like so:

local config = {}

-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then config = wezterm.config_builder() end

--- This is where you actually apply your config choices
--- Color scheme
function scheme_for_appearance(appearance)
    if appearance:find "Dark" then
        return "Catppuccin Mocha"
    else
        return "Catppuccin Latte"
    end
end

config.color_scheme = scheme_for_appearance(wezterm.gui.get_appearance())

My ipython_config.py has the following content:

from pygments.styles import get_style_by_name
from pygments.util import ClassNotFound

c = get_config()
c.InteractiveShell.confirm_exit = False
c.InteractiveShell.separate_in = ""
c.TerminalIPythonApp.display_banner = True
try:
    c.TerminalInteractiveShell.highlighting_style = get_style_by_name(
        "catppuccin-mocha"
    )
except ClassNotFound as ex:
    print(f"Failed to set theme: {ex}")

At the prompt I start ipython shown in the screenshot below then type say f and hit TAB. Screenshot 2024-10-25 at 21 38 09

I hope all this makes sense and thanks for trying to find a solution.

Pilgrim1379 avatar Oct 25 '24 20:10 Pilgrim1379

Thanks for the reproduction instructions, my results are a bit interesting.

This is my IPython Config:

c = get_config()  #noqa

c.InteractiveShell.confirm_exit = False
c.InteractiveShell.separate_in = ""
c.TerminalIPythonApp.display_banner = True
c.TerminalInteractiveShell.true_color = True
c.TerminalInteractiveShell.highlighting_style = "catppuccin-mocha"

And my wezterm options aren't actually styled in the first place:

image

My WezTerm version is 20230712-072601-f4abf8fd so I'm a bit behind you. I wonder if this is actually related to https://github.com/catppuccin/wezterm/issues/15 in newer versions of WezTerm?

sgoudham avatar Oct 25 '24 22:10 sgoudham

With regards to the original issue, unfortunately it looks related to our ANSI colours: https://stackoverflow.com/questions/14129278/how-do-i-customize-text-color-in-ipython

We're in the process of overhauling ANSI colours but I think this is a classic example where the Catppuccin theme doesn't look good with "white" text on accented backgrounds (i.e. red, yellow, green, etc) so we'll need to perform some overrides for IPython to make the text foreground base or crust according to our style guidelines.

sgoudham avatar Oct 25 '24 22:10 sgoudham

Thanks for the reproduction instructions, my results are a bit interesting.

This is my IPython Config:

c = get_config()  #noqa

c.InteractiveShell.confirm_exit = False
c.InteractiveShell.separate_in = ""
c.TerminalIPythonApp.display_banner = True
c.TerminalInteractiveShell.true_color = True
c.TerminalInteractiveShell.highlighting_style = "catppuccin-mocha"

And my wezterm options aren't actually styled in the first place:

image

My WezTerm version is 20230712-072601-f4abf8fd so I'm a bit behind you. I wonder if this is actually related to catppuccin/wezterm#15 in newer versions of WezTerm?

Using the suggestions from the wezterm issue you linked to, I modifed my config to:

config.color_scheme = scheme_for_appearance(wezterm.gui.get_appearance())
config.colors = {indexed = {[16] = "#000000"}} 

and the completion now looks like yours Screenshot 2024-10-25 at 23 40 45

I can live with this. At least its readable. Thanks a ton for your help.

Pilgrim1379 avatar Oct 25 '24 22:10 Pilgrim1379

@Pilgrim1379 it's worth checking if c.TerminalInteractiveShell.true_color = True in your ipython config helps too - it's almost always better. in particular i've noticed using 256 colour (the default on some configurations) breaks the completion menu.

i think the original issue with the yellow background on exception tracebacks is a bad highlight choice that needs to be fixed separately.

backwardspy avatar Oct 26 '24 08:10 backwardspy

@10b14224cc please could you provide some more details about your configuration, terminal emulator, et cetera? i am currently unable to replicate this issue.

image

backwardspy avatar Oct 26 '24 09:10 backwardspy

I have kitty and the following in my IPython configuration at ~/.ipython/profile_default/ipython_config.py

## Set the color scheme (NoColor, Neutral, Linux, or LightBG).
#  Choices: any of ['Neutral', 'NoColor', 'LightBG', 'Linux'] (case-insensitive)
#  Default: 'Neutral'
c.InteractiveShell.colors = 'Linux'
c.TerminalInteractiveShell.true_color = True
c.TerminalIPythonApp.display_banner = False
try:
    c.TerminalInteractiveShell.highlighting_style = get_style_by_name("catppuccin-macchiato")
except ClassNotFound as ex:
    print(f"Failed to set theme: {ex}")

ghost avatar Oct 26 '24 13:10 ghost

nice, thanks for the info! i realised my terminal emulator was shielding me from this issue by automatically improving contrast in these situations. i've disabled that and i can now replicate the issue. it comes from the InteractiveShell.colors part of the configuration and i don't know if it can be changed.

one workaround for now is to set that to nocolor which, as the name implies, disables colour in tracebacks and so on. syntax highlighting is controlled with TerminalInteractiveShell.highlighting_style so that continues to work.

the outstanding question now is whether the ansi colours used by InteractiveShell.colors can be modified or not.

backwardspy avatar Oct 26 '24 15:10 backwardspy