ANSI colors not working with foreground and background

Problem description:
When I have a foreground and a background color for the same text, sometimes the foreground color will not be shown.

Expected behavior:
The foreground color and background color both show up (e.g. red text on a yellow background).

Actual behavior:
The foreground color is set to black.

Steps to reproduce:

# Should be red text on red background, thus making the text not appear.
# Actual: black text on red background.

All (as far as I know)

Replit ANSI is confusing. Try this:

def custom(fg, bg=[]):
    """Builds a custom color from an RGB Value"""
    if bg:
        return f"\033[38;2;{fg[0]};{fg[1]};{fg[2]}m\033[48;2;{bg[0]};{bg[1]};{bg[2]}m"
        return f"\033[38;2;{fg[0]};{fg[1]};{fg[2]}m"

print(custom([255, 0, 0], [255, 0, 0])+"Hello")
# red text, red background.

and let me know if that works

Nope, that’s not it.

lol replit ANSI codes are so scuffed

I didn’t change the ansi code foreground, but merely changing the background will change the foreground lol

Yes, that’s what the bug report is about. :frowning:

1 Like