Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

The Vifm v0.8 changelog mention new features, including the :

[a]bility to use terminal applications to preview graphics (e.g. w3mimgdisplay).

Unfortunately, I do not see it mentioned anywhere in the documentation and I am not sure how to set it up.

It's worth noting that ranger supports displaying full color images on *NIX and even on OS X (iTerm).

2 Answers

0 votes
by
reshown by
0 votes
by

Unfortunately, I do not see it mentioned anywhere in the documentation and I am not sure how to set it up.

This is because it has been made possible and Vifm now provides means to achieve it, but that's where support ends, i.e. nothing is hard-coded and theoretically any similar application might work by using these means.

There is related Wiki page describing possible setup with w3mimgdisplay: How to preview images.

It's worth noting that ranger supports displaying full color images on *NIX and even on OS X (iTerm).

As far as I know it also uses w3mimgdisplay, although not sure about OS X.

In case of ranger it is more hard-coded and thus somewhat more convenient to users, but not very good from design point of view (unfortunately, what's good for application sometimes leads to worse user experience, but I think consistency of application should be preserved, unless there are strong reasons to break it).

by

As far as I know, w3mimgdisplay does not work on OS X: I have failed trying to compile it many times before. By the way, I also strongly oppose hard coding unless absolutely necessary, but it would be interesting to implement full color image preview for OS X too. Ideally, this should be provided by an external command that is more polished, cross-platform, and less "patchy" than w3mimgdisplay.

by

Ideally, this should be provided by an external command that is more polished, cross-platform, and less "patchy" than w3mimgdisplay.

Yeah, but terminal emulators are text only and know nothing about pictures, so having it cross-platform or even cross-terminal is basically impossible without substantial changes to the way they all work (an extension that would take path to image and coordinates/dimensions would probably do it, but this needs changes to all terminals out there).

by

What about hiptext? Technically it's text, it's multi-platform, and it's simpler. Looks like a good compromise to me.

by

I didn't try hiptext, tried other similar viewers and they might not always work depending on what controlling sequences they use. If they don't just output characters sequentially and, say, change position of output you need quite a lot of processing to make it work inside applications (read it as "you need to do terminal emulator's work"). At least ncurses doesn't let you output escape sequences as is, one needs to translate them into corresponding curses API calls.

by

Hi,

I do not have a very valuable contribution to the discussion above, but inspired by the referenced wiki and reddit pages I tried getting the image previews to work and would like to share my experience:

I started with Uberzug. The code blocks referred to in the reddit post out-of-the-box 'worked' for me in the sense that images get displayed in the terminal. However, it all feels very buggy and non-robust:

1) In GNOME-terminal or Terminator when creating a second terminal tab the tabline appears and moves the effective VIFM curses interface area down. However, the image stays at the original location and then overlaps the terminal tab. Also, in Terminator with the image preview enabled and there being a horizontal terminal split with VIFM in the top terminal and another VIFM-unrelated terminal below, if one slides the separator of the terminal split to another location the image preview does not rescale to fit the VIFM preview area: the bottom terminal will be overlayed by the image preview when dragging the separator up.
2) When going to the VIFM subshell by pressing the 's' key the preview image stays visible overlaying the VIFM subshell interface.

This behavior is identical for GNOME-terminal and for Terminator. It seems like the Uberzug image is bound to the parent terminal emulator (and its dimensions) rather than the VIFM curses area.

The w3mimgdisplay method explained in the wiki.vifm on the other hand works perfectly without any of the issues mentioned above, although it did force me to migrate to XTerm (with tmux for multiplexing) since w3mimgdisplay does not work in GNOME-terminal and Terminator (for me on ubuntu 18.04). Moreover, in the process one gets a terminal text-based web browser for free -w3m- ;)

I post this message here for documentation purpose hoping that someone understands the Uberzug behavior and knows how to 'fix' (i.e. improve) it. As far as myself is concerned I may just stick with w3mimgdisplay+XTerm+tmux anyway ...

Kind regards,
A very happy vifm user :D

by

Hello,

Upgraded to Ueberzug 18.1.5 in case that would make any difference, but I still don't see some of the behaviour you've described.

It seems like the Uberzug image is bound to the parent terminal emulator (and its dimensions) rather than the VIFM curses area.

Technically that's how it is, but Vifm does redraw preview when it redraws preview area, so it should match each other. In particular, on opening tabs it does go down for me as well as on changing type of splitting, etc.

2) When going to the VIFM subshell by pressing the 's' key the preview image stays visible overlaying the VIFM subshell interface.

Yes, this and similar thing on switching tabs is something that should probably be addressed in code. w3m doesn't expose this behaviour as clearing curses windows gets rid of the image automatically. For :shell a custom command/mapping that disables preview, does :shell and enables preview might serve as a workaround.

by

I've just pushed fixes for hiding graphics on switching tabs and running external applications (including :shell) (merge commit). Thanks for the bug reports!

...