mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.26k stars 29 forks source link

Images are not shown when using tmux #72

Closed yujinyuz closed 8 months ago

yujinyuz commented 10 months ago

I tried downloading the binary in the releases and also tried building it but still had the same problem.

The terminal just hangs whenever it's the image part and could not proceed further through the slides.

https://github.com/mfontanini/presenterm/assets/10972027/63e40205-9797-4fa7-8ac5-eee0f0dbedc3

I tried running without tmux and it was working just fine.

mfontanini commented 10 months ago

Images won't work on tmux as it doesn't support image protocols. However, this shouldn't just stall and should instead show a version of the image made up of colored text blocks. I'll try to reproduce on a mac later but you should avoid tmux altogether here.

yujinyuz commented 10 months ago

@mfontanini Oh. Alright. I thought it was compatible with tmux since I can run kitten icat examples/doge.png just fine within tmux.

image

Does this app not use that command under the hood?

mfontanini commented 10 months ago

Hmm interesting... kitty icat may be skipping a step that the library this uses to print images uses, which may cause it to think tmux can't show images when it can. Under the hood this is running the same code that viu uses so this would need to be changed there.

rmartine-ias commented 10 months ago

Tmux actually supports sixel, now! https://www.arewesixelyet.com/#tmux (it has to be compiled in, though) Maybe that's what it's using?

mfontanini commented 10 months ago

I don't think that's the case here. I could be wrong but I think both tmux and your terminal emulator would need to support sixel and kitty (which @yujinyuz is using doesn't). The reason why this works on kitty icat is because that uses some custom logic to deal with tmux. Because we use viuer, this means that library would need to do the same.

mfontanini commented 8 months ago

Alright, this was fixed in #166 (only for the kitty terminal + tmux). See the notes there but tl;dr; you need to specify --image-protocol kitty-local for now and gifs (I recently got these to work under kitty!) only work properly in the latest tmux 3.3a.

yujinyuz commented 7 months ago

Hi @mfontanini I just tried this again with tmux 3.4 and kitty using presenterm 0.7.0

Passing the --image-protocol kitty-local works but it doesn't render anything..

Screenshot 2024-03-11 at 00 51 01

It works properly without tmux though..

Screenshot 2024-03-11 at 00 51 21
mfontanini commented 7 months ago

I forgot to clarify (and forgot myself this was necessary so I had to chase it down): you need to enable the allow-passthrough option in tmux (see man). e.g. put this in your tmux.conf:

set-option -g allow-passthrough on

This allows tmux to pass through characters straight to the terminal emulator so it handles them rather than tmux doing so itself. In this case, this lets presenterm tell tmux that the escape codes to transmit images via the kitty protocol need to be forwarded to kitty, as it's the one drawing them.

yujinyuz commented 7 months ago

Awesome! That makes sense now.

It’s working properly now.

The only problem I see is that if you didn't pass the image-protocol, it just hangs and doesn't load.

But I can live with this and I just changed the default config.yaml.

mfontanini commented 7 months ago

Yeah I know, it's not great but I haven't spent the time to figure out how to do this properly without risking doing something wrong. At least the config file approach does it for now.

AllenFind commented 4 months ago

Even with all the settings above, iterm2 still cannot produce the image with tmux ;(

Tmux version: 3.4 presenterm: latest code build command: presenterm test.md --image-protocol iterm2

mfontanini commented 4 months ago

Are you using large image files? Does it also fail if you use a small image? e.g. a few KBs long

AllenFind commented 4 months ago

Hi, I tested 1KB image. It still doesn't work.