-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Approximate truecolor
styles with ANSI-256 colors
#3368
Comments
Thanks for investigating this! It's great that it's such a small change. I bet we could vendor that Wether this is in scope or not is a good question though. If truecolor support is the only thing older terminals are missing then IMO this would be in scope and it would be nice to expand the supported terminals with such a small change. But I'm concerned about features in terminal emulators like Bracketed-paste (see also #2239, #3233) or italics. If older terminals like Terminal.app are lacking many features, I think it may be best to explicitly not support them and instead to point to modern terminals like in the newly written Terminal Support wiki page. I'm curious what you think about it @archseer and @sudormrfbin? |
For the record, of the three features mentioned on mentioned on Terminal Support, Terminal.app:
Those are just the three features I knew enough about to add to the page, so there may be other relevant terminal features to consider. |
Another potential option for approximating Specifically, it could spawn I looked around and found this seemingly up-to-date list of terminal emulators that don't support |
On the other hand, I was able to copy and paste from the system pasteboard in Helix in Terminal.app on macOS just now, so I'm not sure I need to worry that Terminal.app doesn't support OSC 52. fish supports 8-bit-color fallback if 24-bit support isn't there. Personally I'd be satisfied as long as the 8-bit fallback doesn't try to use a purple foreground with a black background (or vice versa), as seen here: |
As a workaround, it could convert RGB colors in theme files into ANSI 256 color codes. (See https://github.com/koyeung/toml-rgb2ansi256) (This is not perfect. I hope Apple Terminal could support truecolor.) |
I had no idea Terminal.app was unsupported. Came here trying to find a way to have a fallback theme, so I can use one of the fancier themes in Alacritty instead of my current base16 theme, since I primarily use Terminal.app (my kingdom for tab support in Alacritty). Would love to see this approximate-color approach allow use of nicer themes in Terminal.app (and potentially move Terminal.app to the list of supported terminals, as AFAICT that's the only thing holding it back). |
The terminal emulator I use does not have true color support (specifically,
Terminal.app
). This means that most themes don't work.However, it is possible to have some support ANSI-256 color terminals by approximating 24-bit RGB colors to one of 256 ANSI colors.
For my own personal use and as a quick and dirty hack, I applied the following patch to the theme loading logic in order to get true color themes working locally (disclaimer: didn't do due diligence on what the best crate for doing the color conversion is, but from a quick glance
ansi_colours
seemed fine to me; additionally, the conversion fits into a single-file-module and can be easily vendored into this repo):This produces some good results:
While this quick and dirty solution is incredibly specific to my setup, I think it would be reasonable to build-in some theme true color -> ANSI-256 approximation. I don't mind contributing it myself, I just wanted to:
Regarding 2., I had imagined something like:
Where
mode
can be one of:auto
: behaves liketrue-color: false
does todaytruecolor
: behaves liketrue-color: true
does todayansi256
: approximates themes by converting RGB colors to ANSI-256 color codesThe downside to this suggestion is that it would be a backwards-compatibility breaking change.
The text was updated successfully, but these errors were encountered: