22 Commits

Author SHA1 Message Date
Qwerasd
b64f49a0d7 fix(kittygfx): accept commands with no control data
This sort of command is treated as valid by Kitty so we should too. In
fact, it occurs with the example `send-png` script provided in the docs
for the protocol.
2025-04-07 13:31:51 -06:00
Jeffrey C. Ollie
995959dce4 kitty images: add delete by range operations
Fixes #5937

Implement [deleting Kitty image ranges](https://sw.kovidgoyal.net/kitty/graphics-protocol/#deleting-images).
2025-02-23 12:57:24 -06:00
Chris Marchesi
861531a1fd terminal/kitty: increase value buffer, make 'H' and 'V' i32
This commit increases the value buffer to 11 characters - this is
technically what it should be to allow for large negative integers
(i.e., 2.4 billion plus the sign character).

Additionally corrected the types for 'H' (horizontal offset) and 'V'
(vertical offset) - these are supposed to be i32 versus u32.

Added some extra tests to test all of this stuff as well.

I've also added a few more tests to help track these cases.
2024-09-25 09:01:39 -07:00
Tim Culverhouse
723d79c9de graphics: set default transmission format as .rgba
The default format for transmission is defined as RGBA (f=32) in the
Kitty Graphics specification. When no format is specified, this can
result in an error for length checking.

Fixes: #2212
Reference: https://sw.kovidgoyal.net/kitty/graphics-protocol/#control-data-reference
2024-09-10 11:03:51 -07:00
Mitchell Hashimoto
761bcfad50 kitty gfx: handle q with chunked transmissions properly
Fixes #2190

The `q` value with chunk transmissions is a bit complicated. The initial
transmission ("start" command) `q` value is used for all subsequent
chunks UNLESS a subsequent chunk specifies a `q >= 1`. If a chunk
specifies `q >= 1`, then that `q` value is subsequently used for all
future chunks unless another chunk specifies `q >= 1`. And so on.

This commit importantly also introduces the ability to test a full Kitty
command from string request to structured response. This will let us
prevent regressions in the future and ensure that we are correctly
handling the complex underspecified behavior of Kitty Graphics.
2024-09-04 10:24:25 -07:00
Mitchell Hashimoto
2acd7e8a42 kitty: respond OK with metadata on display transmissions 2024-09-03 11:05:16 -07:00
Jeffrey C. Ollie
5e925db521 kitty graphics: fix usage of "m" key for local-only transmission mediums
If the transmission medium is a local-only medium, ignore the "m"
key. The Kitty graphics protocol specification does not explicitly
call out this behavior (although the "m" key is only mentioned in
connection with remote clients) but that's how it's implemented in
Kitty and at least one client (mpv) relies on this behavior when
using the shared memory transmission medium.

https://sw.kovidgoyal.net/kitty/graphics-protocol/#the-transmission-medium
ccc3bee9af/kitty/graphics.c (L547-L592)
2024-09-01 21:10:08 -07:00
Mitchell Hashimoto
d8f43b34ba terminal: yeet usingnamespace 2024-08-16 10:32:43 -07:00
Qwerasd
37872afbce kitty graphics: support loading 1 channel grayscale images 2024-08-15 21:38:46 -04:00
Qwerasd
10b8ca3c69 spelling: normalize grey -> gray 2024-08-11 18:31:01 -04:00
Mitchell Hashimoto
b368702a9d terminal/kitty: shared memory size may be larger than expected for pages
The shared memory segment size must be a multiple of page size. This
means that it may be larger than our expected image size. In this case,
we trim the padding at the end.
2024-08-09 20:33:39 -07:00
Mitchell Hashimoto
358b4ca896 terminal/kitty: parse relative placement fields 2024-07-25 21:32:44 -07:00
Mitchell Hashimoto
360e4f690f terminal/kitty: change graphics base64 decode to use simdutf 2024-07-16 20:21:09 -07:00
Qwerasd
04ec859925 terminal/kitty_graphics: update tests
Kitty Graphics command structures have been changed to hold decoded payloads not base64 strings.
2024-03-31 22:28:53 -04:00
Qwerasd
ca4b55b486 terminal/kitty_graphics: ignore base64 padding
Also move all base64 decoding to inside of the command parser.
2024-03-31 21:09:37 -04:00
Qwerasd
5dee7e1430 terminal/kitty_graphics: update outdated comments 2024-03-31 19:29:56 -04:00
Mitchell Hashimoto
7c8b156960 kitty images: support pngs with greyscale/alpha (bpp=2)
Fixes #1355
2024-01-22 14:32:27 -08:00
Mitchell Hashimoto
81498fe9be terminal/kitty-gfx: delete newest 2023-08-23 11:35:14 -07:00
Mitchell Hashimoto
4b38fb96db terminal/kitty-gfx: honor "z" setting 2023-08-23 09:55:13 -07:00
Mitchell Hashimoto
7bec2820a7 terminal/kitty-gfx: start working on placements 2023-08-20 22:03:21 -07:00
Mitchell Hashimoto
f82899bd58 terminal/kitty-gfx: better memory ownership semantics around func calls 2023-08-20 22:03:21 -07:00
Mitchell Hashimoto
c7658df978 terminal/kitty-gfx: support "query", loading images, tests 2023-08-20 22:03:20 -07:00