MakeResident

LuaFAR for Editor

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

  1. 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 with require function, that is, package.path is used to search for the file. But contrary to require, the value returned by the script is not cached in package.loaded.

Notes about the handlers

  1. Handlers must be defined as global functions.
  2. There can be multiple handlers for the same event type. They will be called in the order their files are specified in _usermenu.lua.
  3. The handlers' input parameters correspond to the exported functions with the same names, e.g. ProcessViewerEvent corresponds to export.ProcessViewerEvent, etc. (see LuaFAR manual for details). ExitScript has no parameters, no return value.
  4. If the return value of a handler’s ProcessEditorInput is true, the rest of ProcessEditorInput handlers are not called, and true is returned to Far.
  5. The return values of ProcessEditorEvent and ProcessViewerEvent are ignored.
  6. ProcessEditorInput handlers are not called when a user-defined hot key is pressed.
  7. ExitScript is called when the plugin is about to be unloaded. It is also called before the “Reload User file” operation.