Page 1 of 1

Plugins' API for scripts

Posted: Sun 16 Aug, 2015 08:31
by Shmuel
pepak wrote: Regarding Plugin.Call, I have no idea how to interface plugins with macros.
- To implement that in the plugin, start with OpenW page (in Russian).
- To see how it looks from macro side, see description of Plugin.Call in macroapi_manual.en.chm (in English).
Ask for help on particular issues if needed.

Named Folders Lite

Posted: Sun 16 Aug, 2015 09:32
by pepak
Well, the first issue is, I need some introduction as to why I would want to create such an interface: what it can achieve and why is it better than just programming the desired functionality (whatever it is) into plugin itself. I am sure it sounds like something everyone should know, but I don't - when I wrote, I know "literally nothing about it", I was serious, I really don't know anything about it. My experience with FAR macros is limited to CTRL+dot and to copying other people's macros to my profile directory.

Named Folders Lite

Posted: Sun 16 Aug, 2015 09:47
by Shmuel
In short:
Plugin macro interface makes plugin functionality available from macros. Plugin becomes something like a library providing macros with various functions that can pass arbitrary number of arguments to the plugin and receive arbitrary number of return values from it. Each argument and return value can have its own type and value. (In many cases, no argument and no return value are needed).

Named Folders Lite

Posted: Sun 16 Aug, 2015 11:11
by pepak
OK, that makes sense.

Now, how does it apply to Named Folders Lite? I can see that I could expose an interface which would allow you to create a new bookmark - something like Plugin.Call("6073FF5D-703E-4C1E-8182-26400240073A", "New", "root", "C:\") - or delete one Plugin.Call("6073FF5D-703E-4C1E-8182-26400240073A", "Delete", "root"). Fair enough. It is certainly doable. But, what would be the point? Surely there must be some reason why a script would want to bookmark a directory, but I must admit I don't see it. And, assuming that there is such a reason, why would I want to perform a Plugin.Call rather than, say, execute pushd Somedirectory[ENTER]cd::name[ENTER]popd[ENTER] on FAR's command line?

I can see where a scripting interface would be useful for e.g. DirSync3: I could provide a function which would let the caller know which kind of line is the line with the cursor (whether it is a <<== line or a ---> line or maybe it's a description line...) and another function for changing the kind of line to something else. But I have my doubts even there - why spend time on creating a plugin interface when I could spend the same time (perhaps less of it) implementing the required functionality directly within the plugin?

[Note to admin: Perhaps it would be useful to split the posts beginning with http://forum.farmanager.com/viewtopic.p ... 74#p131974 into a separate thread.]

Named Folders Lite

Posted: Sun 16 Aug, 2015 11:19
by Shmuel
pepak, I've no intention to convince you that you need that thing. If it occurs that you have specific questions on how to do it, I'll gladly answer.

Named Folders Lite

Posted: Sun 16 Aug, 2015 11:26
by pepak
I don't consider this as some contest between "me who doesn't want to implement macro interface" and "you who does". I am simply approaching the issue from a position of someone who never worked with FAR scripts and never implemented interfaces for them and wants to learn why it would be worthwhile. If there is a good reason for adding scripting support to Named Folders Lite (or any other of my plugins), surely I can do that. I just don't see that good reason at this moment, but certainly am willing to listen if someone wants to explain where he sees the benefits. The "how" will become important later, after I understand the "why".

Named Folders Lite

Posted: Sun 16 Aug, 2015 11:34
by John Doe
pepak wrote: execute pushd Somedirectory[ENTER]cd::name[ENTER]popd[ENTER] on FAR's command line
In order to avoid pushd/popd you may provide more advanced commandline interface.

Named Folders Lite

Posted: Sun 16 Aug, 2015 11:37
by HaRT
pepak wrote:[Note to admin: Perhaps it would be useful to split the posts beginning with http://forum.farmanager.com/viewtopic.p ... 74#p131974 into a separate thread.]
Done

Plugins' API for scripts

Posted: Sun 16 Aug, 2015 11:42
by John Doe
pepak wrote: The "how" will become important later, after I understand the "why".
You should ask GAAlex "why".
As for me, commandline interface is enough for most purposes of the plugin.
It is accessible from macros via Plugin.Command (but there is one limitation: currently it is available in panels only).