MakeResident
MakeResident (file)
Function MakeResident
is available to the _usermenu.lua script.
It allows to add a file, containing one or more handlers that will be further called on some FAR events.
The following handlers are supported:
ProcessEditorInput
ProcessEditorEvent
ProcessViewerEvent
ExitScript
Parameters
file
A specification for a Lua script that is run by this function. The exact file name is determined according to the same rules as withrequire
function, that is,package.path
is used to search for the file. But contrary torequire
, the value returned by the script is not cached inpackage.loaded
.
Notes about the handlers
- Handlers must be defined as global functions.
- There can be multiple handlers for the same event type. They will
be called in the order their files are specified in
_usermenu.lua
. - The handlers' input parameters correspond to the exported
functions with the same names, e.g.
ProcessViewerEvent
corresponds toexport.ProcessViewerEvent
, etc. (see LuaFAR manual for details).ExitScript
has no parameters, no return value. - If the return value of a handler’s
ProcessEditorInput
is true, the rest ofProcessEditorInput
handlers are not called, and true is returned to Far. - The return values of
ProcessEditorEvent
andProcessViewerEvent
are ignored. ProcessEditorInput
handlers are not called when a user-defined hot key is pressed.ExitScript
is called when the plugin is about to be unloaded. It is also called before the “Reload User file” operation.