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 ratatui-image tmux detection when used with a configured image protocol #352

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

Nemo157
Copy link
Contributor

@Nemo157 Nemo157 commented Sep 13, 2024

I finally tracked down part of the problems from #345, ratatui-image only does its tmux detection when guess_protocol is called.

This is required for kitty (and presumably iterm2) protocol to work inside tmux, for sixel it's not required since tmux actually implements sixel support itself, but it does appear to give better results by bypassing tmux and passing the sixel data directly to the terminal.

@benjajaja
Copy link
Contributor

Thank you!

@reynoldsme
Copy link
Contributor

I will agree that with this patch, sixel in tmux is significantly more usable. Images are consistently visible and the performance issues appear to be gone. The only downside I can see is that it looks as if tmux is no longer tracking the placement of the sixels internally and as a result, terminal layout starts to break as soon as you add tmux splits as sixels can end up getting placed wherever the cursor is.

sixel-tmux-bypass2

In particular, if a sixel gets renders past the current bottom of the terminal, the terminal itself will scroll instead of tmux, and that breaks layout pretty badly (Note how the tmux status line is moving up the screen on every sixel refresh in the next screenshot).

tmux-sixel-bypass3

@Nemo157
Copy link
Contributor Author

Nemo157 commented Sep 16, 2024

Right, that makes a lot of sense, and actually seems to happen with the iTerm2 protocol as well, since the cursor is not under the apps control when it's not the active pane and so since the passthrough'd escape sequences are cursor dependent they render in the wrong place. Kitty seems to be the only protocol that actually renders correctly in that situation since its escape sequence isn't related to placement, the placement happens purely through the unicode characters.

@ulyssa
Copy link
Owner

ulyssa commented Sep 17, 2024

@Nemo157 Thank you for looking into this and figuring out the fix, and thank you to @benjajaja for reviewing it!

It sounds like from @reynoldsme that this is a net improvement when running in tmux so I'm going to go ahead and merge it. There is code that should prevent drawing images past the bottom of the window, but if I understand right it sounds like the image doesn't get cleared when the window gets resized during the tmux split. That will probably require a follow-up change to improve the situation.

@ulyssa ulyssa merged commit e40a8a8 into ulyssa:main Sep 17, 2024
3 checks passed
@ulyssa ulyssa added this to the v0.0.11 milestone Sep 17, 2024
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.

4 participants