huijunchen9260 / fm.awk

File manager written in awk
GNU General Public License v3.0
125 stars 3 forks source link

Externalize preview generators. #8

Closed magpie514 closed 3 years ago

magpie514 commented 3 years ago

As explained it leaves the drawing to fm.awk, so it's not a huge change. An option for the future would be for it to generate previews of various items and return the characters to display entirely, but for now this allows to customize the commands and settings.

huijunchen9260 commented 3 years ago

Is it possible to also check for dependencies? So that fm.awk itself don't need to check dependency.

huijunchen9260 commented 3 years ago

Also, I hope this externalization can cocver all/most of the preview function within fm.awk. Like graphic_preview and print_preview. For draw_preview, maybe it depends.

magpie514 commented 3 years ago

I'd prefer dependency check to be done only once instead than on every invocation of the script, but yes. As for making it more general, sure, but I'd need to make a bunch of changes in the whole previewing section. In this case, I think having the previewer generate a text stream to be fed back to fm.awk would do the trick. That way if chafa is used we just need to get the output, and we can add previewers for text formats as well, such as a csv or maybe a code previewer using bat or such tools that are popular around. What do you think? If you give it greenlight i'll close this PR and start a new one. Please push any changes you have in your local repo, I'll build from the next commit.

huijunchen9260 commented 3 years ago

I'd prefer dependency check to be done only once instead than on every invocation of the script, but yes.

I mean make dependency check at fmawk-ueberzug file, since most of the preview stuff is connected by that shell script.

As for making it more general, sure, but I'd need to make a bunch of changes in the whole previewing section. In this case, I think having the previewer generate a text stream to be fed back to fm.awk would do the trick. That way if chafa is used we just need to get the output, and we can add previewers for text formats as well, such as a csv or maybe a code previewer using bat or such tools that are popular around. What do you think?

If you are really really lazy and don't want to start over and deal with all the details, how about referencing lfimg as your base? I feel that they are doing quite good job in terms of communicating between file manager and preview script.

If you give it greenlight i'll close this PR and start a new one. Please push any changes you have in your local repo, I'll build from the next commit.

Greenlight on!!!

magpie514 commented 3 years ago

I mean make dependency check at fmawk-ueberzug file, since most of the preview stuff is connected by that shell script.

Oh, didn't explain myself right. I mean that sure, they can go now since it's decoupled. The previewer script is also what users will have to customize to add more format or use different tools, so you can say we only really need to check for chafa or ueberzug.

If you are really really lazy and don't want to start over and deal with all the details, how about referencing [lfimg] (https://github.com/cirala/lfimg) as your base? I feel that they are doing quite good job in terms of communicating between file manager and preview script.

Will check if my current idea doesn't work well, but should be okay even using POSIX shell. Bash would make it easier but, eh, it's a good excuse to practice that stuff.

Greenlight on!!!

Alright then! I'll start over, should be rolling in about 8-ish hours. Fortunately I was thinking about it yesterday so just need to go and implement it.