-
Notifications
You must be signed in to change notification settings - Fork 380
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
feat: support ANSI themes #460
Conversation
Awesome, this is the feature I've been wanting to add all along. Thank you for implementing it! I'll review it ASAP. |
Looks good to me! Would you like to change the default to an ANSI theme in this PR as well? I think it's quite reasonable as it not only makes Yazi more compatible with users' terminals but also potentially resolves #295. |
Yeah, I totally agree. Just didn't want to do it without the author's permission. I'm not exactly sure where the |
I used the neo-ansi theme and not bat's ANSI theme since the |
I'm happy if you're happy, feel free to squash and merge whenever! Thanks for the awesome file manager! |
Thank you! Let me make some little changes. |
Hi, I've made some changes:
Would you like to give it a review? |
The current default theme is base16-ocean.dark, which as you can see below doesn't match the terminal colors by default:
If I load an 8-bit theme like this one from this neo-ansi repo, I currently see all black theming:
This is because ANSI is configured in
.tmTheme
files as #RR000000, a.k.a. the 8-bit color is in the red component and all other components, especially the Alpha, are0x00
. Assuming colors are 8-bit if the alpha is zero is suggested bysyntect
's author in this comment, and is implemented in bat already here. Given these precedents, I went ahead and implemented it, as seen below:This implementation uses
crossterm
to write the escape sequences, which has a few benefits:crossterm
, so there are no new dependenciescrossterm
provides them for usI think that ANSI themes are a better default for these kind of color-specific tools (since they always match the colors of the terminal), but there are no ANSI themes packed by default into
syntect
's ThemeSet::load_defaults that we use. Maybe a future PR could change to this ANSI theme from bat.