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

More color support #2

Open
BrewingWeasel opened this issue Feb 20, 2023 · 1 comment
Open

More color support #2

BrewingWeasel opened this issue Feb 20, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@BrewingWeasel
Copy link
Owner

Anteater desperately needs at least 256 color support, although true color is the end goal.

Curses supports 8 bit color, and you can change the rgb values of those, which should work to fake true color. But working around curses with ANSI escape codes might be easier.

@BrewingWeasel BrewingWeasel added the enhancement New feature or request label Feb 20, 2023
@BrewingWeasel
Copy link
Owner Author

Doing it with ANSI escape codes would probably look something like this:

def show_color(stdscr, r, g, b):
    print(f"\033[38;2;{r};{g};{b}m\033[1A")
    stdscr.refresh()

This function changes the color to any RGB value and forces curses to register it. But it doesn't work on row one (or the first time it's called?)

def add_str(stdscr, *args):
    final_args = []
    for arg in enumerate(args):
        if isinstance(arg[1], Color):
            show_color(stdscr, arg[1].r, arg[1].g, arg[1].b)
        else:
            final_args.append(arg)
    stdscr.addstr(*[arg for _, arg in final_args])
    stdscr.refresh()

Simple wrapper for screen.add_str() which works with custom RGB Colors (custom type Color) and normal colors.
It should probably reset the color once it does receive the color.

@BrewingWeasel BrewingWeasel pinned this issue Feb 20, 2023
@BrewingWeasel BrewingWeasel self-assigned this Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant