Skip to content
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

fix kitty image protocol display parameters #4847

Merged
merged 2 commits into from
Jan 28, 2024
Merged

Conversation

jonboh
Copy link
Contributor

@jonboh jonboh commented Jan 24, 2024

Hi! I've made some changes into the way that images get displayed to properly handle the kitty image protocol. The changes should not affect the iterm2 and sixel implementations.

I've also added in test-data/kitty-png.py some functions with test cases (intended to be checked manually) that should cover all the changes. To run each of the test just uncomment the one to be run and comment the rest.

Here is a list of changes:

  • Fix x,y,w,h,c,r parameter behaviour
  • Fix cell padding (X, Y). It must be lower than the cell width/height (previously it could pad without limit). Now for bigger input the padding is limited.
  • images with id=0 handling

Here are some screenshots comparing kitty, the current wezterm master branch, and this pr branch.

display_parameters (x, y, w, h, c, r) test

Kitty

image

Wezterm 05eadb7

image

This PR

image

cell_offsets (X, Y parameters) test

Kitty

image

Wezterm 05eadb7

image

This PR

image

For these I've used this picture, although any image should generate similar results.
ferris

This PR should solve most of the issues described in #986 (comment)

I'll be happy to make any modification if needed :)

@wez
Copy link
Owner

wez commented Jan 24, 2024

Thanks for looking into this!
Could you also run a couple of tests to confirm that sixel and iterm2 image protocol handling isn't impacted by this change?
https://wezfurlong.org/wezterm/cli/imgcat.html is the easiest way to play around with the latter.
The former is a bit more ad-hoc.

The thing that caught my eye, although I haven't read your diff in detail yet, is that there were some changes around how the cursor position is handled, so it would be good to confirm that wezterm imgcat --no-move-cursor still functions correctly.

@jonboh
Copy link
Contributor Author

jonboh commented Jan 24, 2024

Here's what I get running img2sixel and wezterm imgcat
I had checked img2sixel, and wezterm imgcat, but not with --no-move-cursor thanks for pointing it out, it seems the behaviour on all three cases is the same 👍.

Wezterm 05eadb7

image

kitty-image branch (this pr)

image

@jonboh
Copy link
Contributor Author

jonboh commented Jan 28, 2024

Here are the results of the tests. All seem to be displayed correctly.

#1156 (kitty on the left, this branch on the right)
1156
e left, test on the right)

#1156, #2084, #4233
tests1

#3918 (kitty on the left, this branch on the right)
sequence_test

#2422
sweep-rs_test

#1663 did not provide a file/script with which to reproduce, but from the problem description and the other results I think we can consider it closed.

@wez
Copy link
Owner

wez commented Jan 28, 2024

So this PR will close all of those issues? Excellent work, thank you!

@jonboh
Copy link
Contributor Author

jonboh commented Jan 28, 2024

Yeah, #2761 can also be closed, as its changes are already integrated here (the part about the id=0)
thank you for reviewing it and wezterm as a whole! :D

@wez wez merged commit 820c451 into wez:main Jan 28, 2024
14 of 15 checks passed
wez added a commit that referenced this pull request Jan 28, 2024
refs: #1156
refs: #1156
refs: #1663
refs: #2084
refs: #2422
refs: #2761
refs: #3918
refs: #4233
refs: #4847
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants