kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.34k stars 151 forks source link

feature request: change, simplify joshuto image preview #516

Open iambumblehead opened 3 months ago

iambumblehead commented 3 months ago

Mainly, preview setup is too complicated. It requires wrapper scripts and extra documentation. The "preview_*" hooks are insufficient to call other applications and scripts in varied ways they require.

Its useful to compare joshuto with vifm. I wrote an image preview script that is easily used with vifm, whereas I failed to get any sort of "hello world" preview from any tool working with joshuto. Vifm is proof; image preview can be simple for curses apps.


The details,

Wrapper scripts should not be used. They increase complexity and chance of bugs, require documentation and explanation, etc. Joshuto should provide a means for calling external scripts with no wrapper.

Preview hooks are insufficient,

The “shown” script gets the path of the file being previewed as first argument and then the x and y coordinate and the width a height of the preview area as second to fifth parameters.

It would be an improvement if joshuto would call, within reason, any script using any call signature or extra options. Vifm allows preview behaviour to call (for example) thu.sh -ck %c %pw %ph %pd, where %c and %pw will resolve to "current file" and "preview width" https://vifm.info/manual.shtml#Command%20macros Joshuto users currently must write wrapper scripts to simulate this behaviour that would be nice to have in Joshuto rather than userland.

Expose a hook or a way to call external scripts before ncurses is started. A wrapper script is not a good solution for this, as it adds complexity to userland. The hook would be useful for bash scripts like thu.sh because, when ncurses runs, stdout cannot be used by child scripts to query the terminal for things like sixel features and cell resolution. This hook would allow bash scripts to query stdout beforehand.

Thank you for reading me.

Related links,

donovanglover commented 3 months ago

I had a working preview script but it broke with the recent 0.9.8 update. I've since switched to yazi which has everything built-in.

iambumblehead commented 2 months ago

your nixos repo is looking very rad @donovanglover :+1: :)