NikitaIvanovV / ctpv

Image previews for lf file manager
https://www.nikitaivanov.com/man1/ctpv
MIT License
272 stars 26 forks source link

Flicker-free transition #66

Open musjj opened 1 year ago

musjj commented 1 year ago

I'm wondering if it'd be possible to remove the flicker that occurs when transitioning between previews. Transitions between text previews are essentially flicker-free once they're cached, but image previews are just never fast enough for it not to flicker and it's really jarring.

I had a preview script for nnn (unfortunately lost), but it had some experimental trickeries to eliminate flickering.

For images, it was simple, I just used kitty +kitten icat --image-id 1. This will replace any previous image occupying the id without any flickers.

For text, it was really hacky. I used tmux to run the previewer and wait until it's done. Then the output (along with all the escape codes) is print to the preview screen, overwriting anything that was on it. To make sure any leftovers from previous previews are cleaned up, I sent an ANSI sequence that clears everything from the cursor position to the end of the screen.

I'm wondering if this could be implemented more elegantly in ctpv. But the idea is simple, don't clear the screen until the output is completely ready.

NikitaIvanovV commented 1 year ago

Could you please, if it's easy to do, record a video of flickering you are experiencing and send here?

musjj commented 1 year ago

Here's a recording:

https://github.com/NikitaIvanovV/ctpv/assets/72612857/8cee4c43-34d8-434e-bb60-f347976179b2

Are you not experiencing this?

Goosegit11 commented 1 year ago

same, but I'm not sure if that's a fixable issue