Andrew Rodland wants to merge 5 commits from /u/hobbified/gnuplot/ to master, 2023-06-08
This patch adds 'kittycairo' and 'kittygd' terminals supporting the Kitty Graphics Protocol (https://sw.kovidgoyal.net/kitty/graphics-protocol/) which is a more modern, more compact, truecolor alternative to sixel, supported by the Kitty and Konsole terminal emulators, among others.
It's built atop the existing PNG renderers (cairo and gd), and the existing base64-embedding code (which gets a bit of an overhaul to allow it to output bytes through a callback instead of just outputting to a FILE*, so that we can chunk and wrap the data properly).
This is a WIP — some error handling is missing, the documentation mostly hasn't been written, and I'm sure I've gotten some code-style stuff wrong — but I've tested it locally and it works great. If the patch is interesting then please get back to me and I'll clean it up. I'm also on IRC (hobbs) for more interactive chat.
| Commit | Date | |
|---|---|---|
|
[396cbd]
(kitty)
by
Change kittygd to use a gdIOCtx Instead of rendering the PNG to an in-memory buffer and then Should use a bit less memory. |
2023-05-04 06:31:15 | Tree |
|
[3901c5]
by
Add kittygd terminal driver This inherits most of its operations from the png driver (like sixelgd |
2023-05-04 06:08:08 | Tree |
|
[648190]
by
Add kittycairo terminal driver This is the same as pngcairo in most respects, except that the PNG is |
2023-05-04 06:04:05 | Tree |
|
[229158]
by
Add kitty output-encoding helpers This gets its own .c file because it will be used from gd.trm and These are functions that can be used together with the write_base64 |
2023-05-04 05:55:10 | Tree |
|
[1cde36]
by
Refactor base64 functions in write_png_image to take a callback Instead of having a FILE* in the base64state and writing to it using The existing write_png_base64_image still works the same as it always |
2023-05-04 05:49:43 | Tree |
In action: https://vimeo.com/823613499/aab4928b77
The
animateflag could theoretically be put to better use, because kitty graphics protocol has actual animation support, but I haven't done that yet.Quick review.
In general it looks very promising.
set term kittygd
load 'animate.dem'
<cr> to start animation
^C to interrupt after a few frames.
At this point output to the kitty terminal [sometimes] becomes jammed. You can switch to another terminal and plot normally, but if you switch back to kittygd it remains jammed. I imagine some sort of cleanup/reinitialization of the callback output routine is neeeded but I don't know exactly what or where to put it.</cr>
5b. About mouse support: kitty has the same mouse support that most newer terminals do (actually, I'm a Konsole user, not a kitty user). It should be possible to handle it and have interactivity at the terminal. But yes, it's just a bunch of escape codes on stdin. I think that instead of bypassing readline, it's possible to work with readline and add the mouse escape codes as "keybindings", so that all you have to do is send the magic "yes, I want mouse clicks" code to the terminal, and then you will receive those interactions as readline events. It's totally not my field, and it seems sparsely documented, but I think it's possible.
Now merged, and integrated with the new pseudo-mousing routines for interactive response to arrow keys during "pause mouse".
Thank you for your contribution to gnuplot!
Last edit: Ethan Merritt 2023-05-24
Thanks! I did intend to come back to this and do more cleanup, I just got quite busy. So thank you for taking it to the finish. Let me know if there's anything else I can lend a hand with.