Adding items to plugins' menus
Like the regular macros, the added menu items are loaded from Lua- and MoonScript-files, residing in the directory %FARPROFILE%\Macros\scripts and its subdirectories.
A menu item is loaded by the global function MenuItem that takes one argument – a table with parameters. The function returns true on success.
MenuItem { description = "Menu item"; -- string (optional field) menu = "Plugins Disks Config"; -- string area = "Shell Editor Viewer Dialog Menu"; -- string (optional field) guid = "A435D567-AD64-4DD1-8C61-28CB90358817"; -- string text = function(menu,area) return "Hello!" end; -- string, or function action = function(OpenFrom,Item) ...... end; -- function }
The fields description and area are optional with the default values being an empty string. Other fields are mandatory.
The field
menuis the list of Far Manager menus the given menu item should be added to. The valid values of list elements are"Plugins","Disks"and"Config"that stand for plugins menu, disk menu and plugins configuration menu respectively.The field
areais the list of areas, where the given menu item should be added to the plugins menu when it is envoked. This field is used only if the fieldmenucontainsPlugins. The valid values of list elements coincide with the names of macro areas.The field
guidcontains a unique identifier (GUID) of the given menu item.The field
text: if it is a string then that string is used as the menu item’s text.
Otherwise it should be a function. The menu item is added only if the function returned a string value.
The function receives 2 arguments:- menu – type of the menu (either of:
"Plugins","Disks"or"Config") - area – name of the current macroarea.
- menu – type of the menu (either of:
The field
actionis the function that is called upon activation of the given menu item. It takes the same arguments as the functionexport.Open(seeluafar_manual.chm), exceptGuid. If the function is called from the plugins configuration menu then both the arguments havenilvalue. The returned value is not used.