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

xterm-256color support #17

Open
cmang opened this issue Jul 15, 2024 · 2 comments
Open

xterm-256color support #17

cmang opened this issue Jul 15, 2024 · 2 comments

Comments

@cmang
Copy link

cmang commented Jul 15, 2024

It would be nice for libansilove to support these escape codes for the xterm-256color palette.

Examples of ANSI editors that export ANSI to this format include Durdraw, which also does Ansilove exporting. This would allow Durdraw to export PNG and GIF files in 256 color, instead of just 16 color. This would also allow sites like 16colo.rs to view these files correctly.

I am looking at the source code... I think the trick would be something like:

1: In config.h: Add the xterm-256color palette as 8-bit hex values
2: In ansi.c: Add interpreters for the 256 color escape codes, the palette generator, and any other logic to deal with color values larger than 16.
3: ???
4: profit!

If I get some time I will give it a try, or if someone else wants to. This can probably be considered a duplicate of issue ansilove/ansilove#43.

Thanks!

@cmang
Copy link
Author

cmang commented Jul 15, 2024

Here is an example 256 color ANSI file with CP437 encoding:
xmas-cp437.zip

And how it should look:
Screenshot 2024-07-15 at 3 14 17 PM

@cmang
Copy link
Author

cmang commented Jul 20, 2024

A resource for xterm-256 palette information: https://www.ditig.com/publications/256-colors-cheat-sheet

Note that colors 0-15 are not standard. The ones listed there do not match VGA colors. I think they might be the default colors when using classic OG xterm. However, terminals can (and do) set colors 0-15 to however they like, with no real standard.

Personally I think it would be fine for colors 0-15 to use the VGA colors instead of the nonstandard xterm default. I am pretty sure this is what the Linux console uses, and this is how I configure my terminals. This also improves standard DOS/CP437 ANSI art compatibility.

For now, in my little libansilove fork, I am copying colors 0-15 from Ansilove's VGA palette for use in the 256 color palette, instead of using colors 0-15 from the link above.

cmang added a commit to cmang/libansilove that referenced this issue Jul 20, 2024
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

1 participant