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

support color256 #5

Merged
merged 17 commits into from
Oct 18, 2024
Merged

support color256 #5

merged 17 commits into from
Oct 18, 2024

Conversation

ahaoboy
Copy link
Owner

@ahaoboy ahaoboy commented Oct 16, 2024

close: #4 (comment)

34 | 44 => "blue".into(),
35 | 45 => "magenta".into(),
36 | 46 => "cyan".into(),
37 | 47 => "white".into(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a good time to add 39 | 49 which are set to default
https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#8-16-colors
https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters

of course it would need to be updated in other places. I can add a new issue if you like?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

39 and 49 should be white by default. If you have a specific use case, feel free to open a new issue. This PR is already larger than I expected :D.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of default is that your terminal knows what text color contrasts well with your background color. So, on light terminals the text is dark and on dark terminals the text is light. I'm not sure exactly how it works because it's not necessarily index 0 (black) or 15 (white) for the color. On Dark Solarized, which has a kind of green background, it chooses a gray color, which is index 10, 11, or 12. I can submit another issue on this subject. Thanks.

@fdncred
Copy link

fdncred commented Oct 17, 2024

This seems to be real close, using the xterm theme, but for some reason default text is black.
image

You can see that the escapes are trying to make it white, but they're showing up black. Also note that the 0 B file size is supposed to be black and it's inverted too based on the ansi escapes.
image

This is the command I used

ls | table | ansi2 -f svg --font C:\Users\fdncred\AppData\Local\Microsoft\Windows\Fonts\CascadiaMonoNF.ttf --mode dark --theme xterm | save ls-xterm.svg -f

ansi file
ls.ans.txt

@fdncred
Copy link

fdncred commented Oct 17, 2024

ah, it must be inverting white and black because of --mode dark?

@ahaoboy
Copy link
Owner Author

ahaoboy commented Oct 18, 2024

ah, it must be inverting white and black because of --mode dark?

In dark mode, white and black are swapped, and the terminal implementation is much more complicated. If the font and background colors are similar, the font color will be inverted, which ansi2 does not support

@ahaoboy ahaoboy merged commit 7cede32 into main Oct 18, 2024
13 checks passed
@ahaoboy ahaoboy deleted the color256 branch October 19, 2024 04:22
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

Successfully merging this pull request may close these issues.

256 color index lookups with 38;5 and 48;5
2 participants