Closed folliehiyuki closed 2 years ago
Thanks for the report. I think Chafa is unable to determine the terminal's pixel dimensions, so it can't calculate how many pixels there are per cell. This would affect sixels and kitty, but not symbols. It probes stdout, stderr and stdin with the TIOCGWINSZ
ioctl, then falls back to getting the controlling tty with ctermid()
and if there is one, probes that the same way. If all of this fails, it falls back to assuming cells are 8x8 pixels, which is going to be wrong, but hey, at least there's something to look at.
So the issue is probably that Chafa is connected to vifm via pipes (which don't support TIOCGWINSZ) and is disassociated from the controlling terminal.
Did you try %N
with sixels?
I misremembered the way I did this with Kitty. It supports cell dimensions natively, so it doesn't need to know the terminal's pixel size to display correctly. Therefore only sixel is affected, which lines up with what you're seeing.
Edit: Kitty images may look blurry, though, because we can't calculate the precise pixel density without access to the tty.
Silly me! Wonder why I didn't try %N
with sixel before opening the issue. It works fine there.
For kitty images, the %N
flag was introduced in vifm to solve that problem in the first place. It looks good with %N
flag.
Thanks for the explanation, and sorry for all the fuss with this issue.
No problem, it's good to learn about these use cases even if there's no bug per se. Didn't know vifm supports graphics from subprocesses so well these days, I should do more testing with it.
At least whenever there is someone filling an issue about vifm
in the future, you can just send them here and say everything works perfectly :)
Side note: vifm currently doesn't do async preview processes for graphics though, so scrolling in symbols mode is faster than in sixel and kitty. Last time I checked it was planned.
EDIT: Got it working, the correct vifm config is:
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm,*.webp,*.gif
\ chafa -f kitty -s %pwx%ph %c:p %pd %N 2>/dev/null
\ %pc
\ kitty +icat --clear --silent %pd
@FollieHiyuki Sorry for pinging you on such an old thread, but this is the only relevant thread I can find relating to kitty chafa and vifm.
Do the images properly clear from the terminal for you? I end up with this, after I close the image preview:
Notice all the overlapping images on the right. The command I'm trying is:
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm,*.webp,*.gif
\ chafa -f kitty -s %pwx%ph %c:p %pd %N 2>/dev/null
vifm
has the option previewoptions=hardgraphicsclear
so I didn't need the kitty +icat clear
in the original post. I haven't used Kitty for quite a while so can't tell whether it is still the case now.
System information
OS: Alpine Linux (edge) chafa version: 1.8.0 / current master vifm version: 0.12 / current master terminal emulator: foot / kitty
Vifm
Here are some flags for the previewer inside Vifm that I use:
Description
I'm trying to use sixel to preview images inside vifm. The command I use in vifmrc file:
The output is something like this:
Here is the output for kitty (left) and symbols (right) backends, with the following commands (
%N
flag is not in 0.12 branch):Side note
I echoed the dimensions (
%pw
and%ph
) then used the numbers to output the image with sixel in the command line and it works fine (in the examples above it should be 48x37)