adamyg / mcwin32

Midnight Commander for Windows
https://sourceforge.net/projects/mcwin32/
210 stars 14 forks source link

MC file plugins for win #9

Open eugenov opened 3 years ago

eugenov commented 3 years ago

mc has some plugins for handling files such as "plugin\archive.sh", "plugin\doc.sh" and such. All commands inside them are for unix. It will be very nice to make mc handle various types of files, but at least we need ability to pass file handling to win. Right now I can only launch executables.

adamyg commented 3 years ago

need an example use-case; scripts can always exec "start file-name" gaining win shell file association features.

eugenov commented 3 years ago

I.e. I have some .pdf file, which opens with MS edge in Explorer. When I execute it in mc (with RETURN key), nothing happens. The same with .doc, *.xls and other file formats with windows assosiations. I believe it's hard to implement archive processing inside mc in win, am I right?

atravert commented 2 years ago

Hello,

Currently the workaround I found to open a file from mc in a external application is to run the following in mc command line:

$ start program %f

So providing a .doc or .docx file is selected in the active panel, the following should work :

$ start winword %f

or equivalently:

$ start winword followed by CTRL + RETURN to add the filename

@eugenov , regarding your initial question: when I just type RETURN on a word file I have the following error (I guess that you should see a similar error, but you must type CRL+o to see the full output of the command line)

image

I don't know much about its implementation, but I suppose that mc is able to execute a part of doc.sh. Here for instance It recognize that type of file is a msdoc, but can't execute wvHtml or elinks which are linux commands.

I agree with you it would be nice being able to directly open the files by typing RETURN. I think that the mc.ext file is meant to do that, but I hanven't figured out yet how to properly do that in windows...

atravert commented 2 years ago

Hello,

Finally I found the following solution: in mc.ext the lines Open=... or View=... invoking doc.sh can be replaced by: Open=cmd /c start openprogram %p View=cmd /c start viewerprogram %p

where openprogram and viewerprogram are exe programs that can be found in the DOS PATH.

For instance for ms word/excel/powerpoint, one could use:

# Microsoft Word Document
regex/i/\.(do[ct]|wri|docx)$
    Open=cmd /c start winword %p
    View=cmd /c start winword %p
type/^Microsoft\ Word
    Open=cmd /c start winword %p
    View=cmd /c start winword %p

# Microsoft Excel Worksheet
regex/i/\.(xl[sw]|xlsx)$
    Open=cmd /c start excel %p
    View=cmd /c start excel %p
type/^Microsoft\ Excel
    Open=cmd /c start excel %p
    View=cmd /c start excel %p

# Microsoft PowerPoint Presentation
regex/i/\.(pp[ts]|pptx)$
    Open=cmd /c start powerpnt %p
    View=cmd /c start powerpnt %p

Finally, as start "" filename.ext makes WIN opening the file with the default program based on extension, one can put on top of mc.ext:

Open=cmd /c start "" %p

This will directly open the file with the default program.

@adamyg : I made few web search, but I did not find recipes to open/view files with mcwin32 (but maybe I did not use the correct keywords). It could be helpful to do so and/or change the default mc.ext so that files with current extensions could be directly opend/read with RETURN/ F3 keys ?

adamyg commented 2 years ago

The diagnostics reported is result of the logic within plugin/doc.sh (below); which is assuming a unix / open-office / abiword environment; shall consider reworking

  wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html -1
  elinks "$tmp/page.html"