doronbehar / pistol

General purpose file previewer designed for Ranger, Lf to make scope.sh redundant
MIT License
322 stars 7 forks source link

cleaner #79

Closed lucas-mior closed 2 years ago

lucas-mior commented 2 years ago

hello there.

lf has a cleaner options for previews, which is meant to be used after using ueberzug to display an image. It will clear the screen when the user selects the next file so that the terminal can show up whatever next preview.

However, the problem with this approach is that everytime an image comes after the other, the cleaner will be unnecessarly called, since all image previews shall return an error (which is a signal to lf to call the cleaner). This causes an annoying flickering between images, as noted in this issue. Ueberzug replaces one image for the other very smoothly when the cleaner isn't executed.

In the aforementioned issue, the user suggests to allow control over the cleaner, but I think the better solution is for the preview program to clean the screen (if necessary). Maybe pistol could have an cleaner option, like lf, but also another option which sets which file types require that the previous one is cleared. The advantage is that other programs using pistol, like fzf, don't require to deal with this issue. The solution is within the previewer.

I could write a PR if it is possible to be accepted. Cheers!

doronbehar commented 2 years ago

So you suggest to make pistol have a --clean option that will print (e.g?) empty lines of text in the amount of the number of lines in the text file it gets as the main argument?

What did you think to make pistol do when it gets a path to an image file?

lucas-mior commented 2 years ago

I don't think you understood what I meant. The cleaner is to clean images that are drawn by ueberzug above the terminal, so all text printed below it can't be seen. That's why normal previews need cleaning if an image was display before. (I don't know of other programs that need cleaning, but there might be).

One approach is to have (let's say in pistol.conf) a --clean flag in the file type that needs cleaning before previewing it. Basically to me that would mean everyfile that doesn't use ueberzug. Yes, I could do that from the previewer itself, but then I will end up wrapping all my previews in shell scripts and then what's the point of using pistol?

The cleaner is also meant to be configureable (like in lf).

However, as I think about it, I think it might be a bit wrong to do it in pistol, because the cleaner will be executed even when the previous file didn't use ueberzug at all. (pistol, unlike lf, can't possibly know which file that was). lfgoes around this issue by calling the cleaner if the last preview returned an error.

Although calling the cleaner everytime is still better than having the flickering between images, maybe the better solution is to do that in lf after all...

doronbehar commented 2 years ago

I'm sorry but I don't use ueberzug and I can't follow all the details.. It'd have been nice to see a screencast if that's possible. Intuitively, it seems as if ueberzug should be the program that would clean something if it's the one that made things dirty.

lucas-mior commented 2 years ago

It's been solved in lf.