kyoheiu / felix

tui file manager with vim-like key mapping
https://kyoheiu.dev/felix/
MIT License
729 stars 26 forks source link

Add Sixel support for better image preview #71

Closed balroggg closed 2 years ago

balroggg commented 2 years ago

Viuer crate has optional sixel feature.

For example, foot terminal emulator show better previews with it.

balroggg commented 2 years ago

One thing I notice that image preview with sixel has wrong width(around twice smaller).

kyoheiu commented 2 years ago

Thank you for pointing that out! I didn't realize that previewed images produced by sixel can be cleared with escape sequences, which termion uses. (FYI, in kitty, high-res images cannot be cleared by them).

And yes, previewed images are a little bit smaller. I don't think it is a huge problem, because unless they are "bigger", they should not break the layout of this app. Do you know if this is rooted in sixel itself, or something goes wrong in this app or viuer?

Anyway, for example in wezterm on my machine, sixel support works very well, so I'm going to add that in the next release.

balroggg commented 2 years ago

Yeah, not a big problem. Maybe problem in calculation of width/height, because sixel more pixel format, not column/row. Something like that https://docs.rs/termion/latest/src/termion/sys/unix/size.rs.html#14-28

kyoheiu commented 2 years ago

Created PR #72

kyoheiu commented 2 years ago

I decided to not implement the sixel feature for now: The reason is that with this sixel feature turned on, libsixel must be preinstalled even if you are not using a terminal that supports sixel (without it, felix will not start). I am trying to figure out how to implement hi-res preview without the dynamic dependency.

balroggg commented 2 years ago

Ok, I completely forgot about it. It's a little strange, I thought viuer contains code for work with sixel.

kyoheiu commented 2 years ago

Yeah, actually it seems sixel-sys or other wrapper crate builds a local version of libsixel, so cargo run works withoug libsixel preinstalled. That's why I didn't think the preinstall is necessary. I'll keep this issue open to remind.

kyoheiu commented 2 years ago

Created PR #78 Hi-res image preview will be enabled by this if the terminal supports sixel and libsixel is preinstalled.