-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Detect kitty graphics support via query #1998
Comments
i can go ahead and do this today; the only worry is that e.g. WezTerm currently has an incomplete implementation; if it answers to this query, but doesn't do the rest, we probably don't yet want to use kitty graphics there. more fundamentally, since WezTerm also implements sixel, it's going to respond to both of those queries. how do we decide between them? kitty is the more powerful protocol for sure, but in this particular case, we'd want sixel for now. hrmm. we could theoretically send a full animation sequence on a dummy image (this seems to be what mr. goyal recommends), but this might add some latency to our all-important initialization time (though it might not). |
this looks like a duplicate of #1908 |
Currently, wezterm does a terrible job at sending back responses to the kitty protocol, so it may not matter too much :-p |
wez/wezterm@fb9338f adds that option; you can use |
given the pragmatic reality that you are terminal #2 to publicly attempt kitty support, i will likely just hold off until i've tested your implementation by hand, i'm thinking. no need to play this like procedural automatons. |
Nice to see another terminal picking up Kitty's graphic protocol support. I would love to see it on Windows but when I filed an issue it was closed (since they don't even have Sixel yet) and the guy I would of thought may of been able to add it decided not to. So any push for someone to get this support on Windows would be greatly appreciated. I do think you should still switch to the query method. It's only a matter of time before more terminals adopt it. Any tuning of it can be worked out later when use cases show up. |
FWIW, this had me scratching my head for a while; wezterm's large number of color registers took precedence over kitty img support: diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c
index f727e5b..28a33ea 100644
--- a/src/lib/termdesc.c
+++ b/src/lib/termdesc.c
@@ -871,7 +872,7 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
// our current sixel quantization algorithm requires at least 64 color
// registers. we make use of no more than 256. this needs to happen
// after heuristics, since the choice of sixel_init() depends on it.
- if(ti->color_registers >= 64){
+ if(ti->color_registers >= 64 && ti->pixel_scrub != kitty_scrub){
setup_sixel_bitmaps(ti, fd, invertsixel);
}
return 0; |
not sure i'm following. i'm not yet doing the kitty test; it's only enabled (by hand) for kitty itself. wezterm ought always be getting sixel at the moment. was it not? |
I added a call to |
ahhh well that explains things perfectly, thanks. yes, the work i'm doing to send the kitty query addresses this issue, have no fears! |
The state of wezterm I've confirmed that Ignoring some quirks in the wezterm implementation that need to get run down and resolved, the reduction in bandwidth makes a nice impact in the FPS in the demo! FWIW, I've been working locally with this diff applied for testing: diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c
index f727e5b..731de53 100644
--- a/src/lib/termdesc.c
+++ b/src/lib/termdesc.c
@@ -573,6 +573,7 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd,
}
// we don't yet want to use the iterm2 protocol in place of sixel
//setup_iterm_bitmaps(ti, fd);
+ setup_kitty_bitmaps(ti, fd, KITTY_SELFREF);
}else if(qterm == TERMINAL_XTERM){
termname = "XTerm";
// xterm 357 added color palette escapes XT{PUSH,POP,REPORT}COLORS
@@ -871,7 +872,7 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
// our current sixel quantization algorithm requires at least 64 color
// registers. we make use of no more than 256. this needs to happen
// after heuristics, since the choice of sixel_init() depends on it.
- if(ti->color_registers >= 64){
+ if(ti->color_registers >= 64 && ti->pixel_scrub != kitty_scrub){
setup_sixel_bitmaps(ti, fd, invertsixel);
}
return 0; It's also worth noting that |
excellent @wez; i'll play around with it today, if possible! if it all works, i'm gonna see if i can't get a bottle of goodly laphroaig out to you |
so here's what i'm thinking we do: we already need to send a
which ought always generate we can then match any kitty-looking APC response, and turn on kitty graphics in that case. then, clear any sixel results in deference to kitty at the end of |
@wez things initially look very good indeed! i'm seeing one possible problem, but it might be nothing at all, or it might be my bug. it has to do with restoring cell-sized sections of a graphic, which i do using the "composition" element of the animation protocol. i'm seeing the following (notes to self; i don't expect you to look into these): (a) a single misplaced braille cell about halfway through let me try it with a lower conformance level and see if these behaviors change (i'm using the highest level, btw, having dug around in it a little, how does the overall code/project look to you? be honest! |
On Thu, Aug 05, 2021 at 01:15:10AM -0700, nick black wrote:
so here's what i'm thinking we do: we already need to send a `a=d` "clear all graphics" message on startup unless `NCOPTION_PRESERVE_BITMAPS` has been passed. so to kill two birds with one stone, let's send the "clear all" in our identification string unless `PRESERVE` was used; in that case, we can send whatever else will elicit a response and have no effect. the minimal such query i've found thus far is
`'\x1b_Gi=1;\x1b\\'`
which ought always generate `EINVAL:Zero width/height not allowed`.
we can then match any kitty-looking APC response, and turn on kitty graphics in that case. then, clear any sixel results in deference to kitty at the end of `ncinputlayer_init()`. that ought be a complete solution.
Use the query mode of the protocol: https://sw.kovidgoyal.net/kitty/graphics-protocol/#querying-support-and-available-transmission-mediums
|
i'm pretty sure that's exactly what i proposed? the example there is
and i was going to send
which suffices to get a response:
it's just your query stripped down. i was going to send this only if i wasn't sending an |
|
this suffices to get a response from both wezterm and kitty |
there we go |
I've not looked too deeply; it was pretty easy to grep and find the bit I needed to change, so I haven't needed to look far beyond that. It looks like a well-commented C/C++ project, which is nice: it was easy to find what I needed without having to read much, and it didn't make my eyes bleed. A solid first impression :-) I appreciate the breadth of the demo and all of the metrics it captures and dumps at the end: those imply a solid foundation and attention to detail. |
If you zoom in on this, it looks like there is a slightly offset transparent region that is showing the text that is behind the image (that splash of magenta is text from my prompt). Not sure yet where this is coming from. |
@wez is adding Kitty graphics support to WezTerm (wez/wezterm#986) in one of the happier bits of news this year. @kovidgoyal suggests querying for Kitty support somewhere in https://sw.kovidgoyal.net/kitty/protocol-extensions/ (can't find it right now, but the implementation is obvious). We should go ahead and do this to detect support, rather than adding it to WezTerm's heuristics. We'll leave the heuristics in there for Kitty, since we need to differentiate between several levels of support based on version (with that said, a failure to respond to the query ought disable support entirely, even in Kitty).
So yeah, toss this query into our initial query string, and check the result. Hopefully most terminals will consume it, but we'll see.
The text was updated successfully, but these errors were encountered: