-
-
Notifications
You must be signed in to change notification settings - Fork 987
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
Update TERMINFO capabilities for 24-bit color support in emacs. #1141
Comments
there actually is a standard way to detect support for truecolor now, the RGB flag in the terminfo database. See https://gist.github.com/XVilka/8346728#detection I'd prefer to actually add that to kitty's terminfo rather then yet another alias for setrgbf. According to the emacs faq page once a standard way is supported they are going to remove setf24 anyway, so it does not seem worthwhile. If their FAQ page is wrong and the emacs developers say they dont want to use RGB then update this bug and I will reconsider. |
There is an entry in a changelog:
So, apparently some exceptions are already made. Why not do the same for emacs? :) |
Because according to emacs' own developers setf24 support will be dropped in the future. |
Hello, according to this bug report, the Emacs master branch should now support the standard RGB flag. However when I run the latest Emacs in Kitty, I am still stuck with 256 colors. Has the Kitty terminfo entry been updated to use the standard RGB flag as of version 0.14.6? |
@kovidgoyal Do you think the following patch makes sense? If so, I'd be happy to make a PR. diff --git a/kitty/terminfo.py b/kitty/terminfo.py
index 174a236a..77eb3a26 100644
--- a/kitty/terminfo.py
+++ b/kitty/terminfo.py
@@ -77,7 +77,7 @@ termcap_aliases.update({
numeric_capabilities = {
# maximum number of colors on screen
- 'colors': 256,
+ 'colors': 16777216,
'cols': 80,
'lines': 24,
# tabs initially every # spaces
diff --git a/terminfo/kitty.terminfo b/terminfo/kitty.terminfo
index 14c5907c..43007f6d 100644
--- a/terminfo/kitty.terminfo
+++ b/terminfo/kitty.terminfo
@@ -11,7 +11,7 @@ xterm-kitty|KovIdTTY,
msgr,
npc,
xenl,
- colors#256,
+ colors#16777216,
cols#80,
it#8,
lines#24, |
As I recall increasing colors beyond 256 breaks some programs. And do a |
For anyone else interested, here is the link to the commit with the discussion about the RGB capability: 18fe2e8. I can totally see why we don't use RGB in the terminfo anymore.
That is unfortunate. So that means that there is no way to support full color in emacs without breaking other programs, right? |
On Sun, Oct 13, 2019 at 01:48:31AM -0700, Luflosi wrote:
That is unfortunate. So that means that there is no way to support full color in emacs without breaking other programs, right?
Dont know, depends on the emacs developers. I dont know why they cant
make it either user configurable or use the same heuristics everyone
else uses.
Maybe someday the set of terminal programs that breaks with larger color
values with be small enough to consider changing it, but I would not
hold my breath. I checked vte, konsole, urxvt and xterm, all of them
appear to use colors=256
|
but instead of > xterm-emacs|xterm with 24-bit direct color mode for Emacs,
< use=xterm-256color,
> use=xterm-kitty,
> setb24=\E[48\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&\
> %d\:%p1%{255}%&%dm,
> setf24=\E[38\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&\
> %d\:%p1%{255}%&%dm,
> then
and you can do
why does it work? I have no idea, but it didn't work following the There is another way in which you follow the faq without replacing the code, but instead using
|
@Sleepful It sounds like you think that I had a problem with using emacs but I don't use emacs (and never have). I was just trying to make improvement suggestions in general. |
@Luflosi ah okay, I landed on this thread trying to get it to work, thanks for thinking about us emacs users. |
I digged into this a little bit and I agree it's a mess. How bad would it be to ship a |
IIRC ncurses ships with kitty-direct already, just use that. Though I think their version doesnt match kitty's terminfo fully, so other things might break, or maybe you will ge tlucky and nothing will break. |
Right, it was just my fear that other things will break, so I created a custom terminfo for now. I just thought shipping with a |
I'm afraid I am really not inclined to do so, sorry. It's hack, This really needs to be fixed in emacs. I don't know why they are being |
Thanks for your quick response. I can understand.
I'd probably be willing to mention this on the emacs list. But when you say this needs to be fixed in emacs, what fix do you have in mind? It's not clear to me how to fix this. AFAICT the only way to recognize RGB support from kitty's terminfo is to check for the non-standard
In fact what they at least removed that statement from their FAQ that the Now that adding RGB here failed, and |
On Mon, May 31, 2021 at 12:32:41AM -0700, Tim Ruffing wrote:
Thanks for your quick response. I can understand.
> This really needs to be fixed in emacs. I don't know why they are being
> stubborn about using the same terminfo properties as everyone else does.
I'd probably be willing to mention this on the emacs list. But when you say this needs to be fixed in emacs, what fix do you have in mind? It's not clear to me how to fix this. AFAICT the only way to recognize RGB support from kitty's terminfo is to check for the non-standard `setrgbf` and `setrgbb`. Do you think they should check for this? That sounds pragmatic at least.
vim has a user toggleable setting for this, "termguicolors" and t_8f/t_8b.
I dont know what mechanism is uses to autodetect. nvim detects
it using setrgbf. tmux detects it using Tc. Both of these are already in
kitty's terminfo. Emacs can pick and choose whatever it likes. Currently
it appears to be using RGB, this requires using a separate -direct
terminfo variant, which is bloody silly. Why on earth should users need
to change the TERM for emacs to condescend to use true color??
See here for why RGB is not suitable for this: 18fe2e8
> According to the emacs faq page once a standard way is supported they are going to remove setf24 anyway, so it does not seem worthwhile.
>
> If their FAQ page is wrong and the emacs developers say they dont want to use RGB then update this bug and I will reconsider.
In fact what they at least removed that statement from their FAQ that the `setb24`/`setf24` may be removed in the future: emacs-mirror/emacs@7f6153d#diff-d764b434e23a258c9b1467e4cac9a9b1c44143ece693dbeed6ba6c7ec448843eL1522
Now that adding RGB here failed, and `setb24` seems permanent in emacs, another pragmatic fix is to add `setb24` here, what was initially proposed here. What do you think?
I dont mind, though it seems bonkers to add another setting for the same
damn thing in every terminfo file, when there already exist widely
supported ones. So if you dont get anywhere on the emcas mailing list
feel free to send a PR for it.
|
Now this was quicker than I expected. https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44950#20 I guess I'll create a PR here then in the next days... |
After a lot of search, I finally managed to get 24-bit color support on Emacs in kitty by following @Sleepful suggestion above. So after creating a custom terminfo file, I start emacs with:
Is this the current and suggested working solution to get full color support on Emacs when using kitty? |
@gzagatti I'm not sure if there's a suggested solution (because the entire thing is a huge mess) but it's a working solution. Emacs 29.1 will support honor |
That's great news. Thanks for letting me know. I'm looking forward to this update. |
I was going to do tmux-direct and RGB instead of tmux-256color and Tc. It seemed to work but fish's brblack was wrong, emitting RGB even though I disabled fish_term24bit. Turns out direct/RGB is a bad idea: kovidgoyal/kitty#1141 kovidgoyal/kitty@18fe2e8 kovidgoyal/kitty@a91b3b9
Just as the kitty terminfo file contains non-standard
setrgbf
/setrgbb
capabilities for neovim, it would be nice if it included the equally non-standardsetf24
/setb24
capabilities which emacs decided to use.The specifics of emacs' desired capabilities are outlined at https://www.gnu.org/software/emacs/manual/html_node/efaq/Colors-on-a-TTY.html, the relevant termcap stanza is:
After doing a bunch of testing, I found that the colors capability needs to be updated to
colors#16777216
indicating that kitty actually supports 24bit colors.I've attached the terminfo file I used to get things running, before I realized that the checked-in
xterm-kitty
file was actually generated. I can try looking into how to get the generation to work as desired, but it would probably be faster/safer if someone else did that.Cheers!
kitty.terminfo.txt
The text was updated successfully, but these errors were encountered: