gokcehan / lf

Terminal file manager
MIT License
7.8k stars 330 forks source link

Resizing terminal font doesn't adjust the size and position of preview image #1793

Closed jdujava closed 2 months ago

jdujava commented 2 months ago

I use image previews in lf via ueberzugpp. After resizing the terminal font, the image preview is not located at proper position. Exiting lf and starting new instance (in the terminal with resized font) fixes the sizing and positioning of the preview.

Perhaps lf setups some variables depending on the font size (which concern preview size/positioning) only at the start?

joelim-work commented 2 months ago

Have you tried logging the parameters to the previewer script (e.g. x, y, width, height) whenever it runs? These values are measured in cells, so they should change whenever the terminal resizes.

jdujava commented 2 months ago

You are right, the values (x, y, width, height) are indeed changing on the font resizing. It seems, that ueberzug/ueberzugpp just has trouble adapting to the new font size.

joelim-work commented 2 months ago

I finally had some time to look at this, it seems like the issue is to do with ueberzugpp. I updated that issue with my own findings. In the meantime please try https://github.com/ueber-devel/ueberzug to see if that works for you instead.

joelim-work commented 2 months ago

Yeah, I tried following your steps, and ueberzug properly updated both position and size of the image, while ueberzugpp didn't.

This is maybe more suited to mention in lf issue, but position/size of previews in lf didn't update with neither ueberzug or ueberzugpp. But this can be caused by my setup and way of launching lf with ueberzug, more than with their response to resizing.

That seems strange if ueberzug can work by itself but not while running lf. lf doesn't actually do anything special with ueberzug at all, it's all controlled by user configuration. Have you tried:

jdujava commented 2 months ago

Now I see that my message wasn't very clear. Position/size of previews was changing on new preview updates, but it was still stuck with the old "fontsize".

Now I have located the culprit. I was launching ueberzug with lf via

setsid ueberzug layer -s <"$FIFO_UEBERZUG" &

where setsid (don't know the exact details) precluded ueberzug to obtain updates about the terminal font size. Running with

ueberzug layer -s <"$FIFO_UEBERZUG" &

results in ueberzug properly adapting to resizes. Still, as you pointed out directly, ueberzugpp is not able to react to font size changes anyway.

@joelim-work Thank you very much for looking into this!