Module globals

Globals functions.

There isn’t really a module named “globals”. This page just serves to document any global functions or variables.

Functions

E Defined at the locale module.
N Defined at the locale module.
Q Defined at the locale module.
T Defined at the locale module.
abort(message) A “benign” version of error.
abortive(val, message, ...) A “benign” version of assert.
alert Alias for prompts.alert.
assert_arg_type(idx, val, type) A utility for validating types of function arguments.
declare(variable_name) Declares global variables.
import_from(module_name, names) Imports names from a module.
require_legacy(module_name) Requires a legacy module.

Fields

arg Alias for argv.
argv Command line arguments.

Events

<<core::after-restart>> Triggered after Lua has been restarted (e.g., by pressing C-x l, by default).
<<core::before-restart>> Triggered just before Lua gets restarted.
<<core::before-vfs-shutdown>> [Used internally].
<<core::loaded>> [Used internally].
<<ui::ready>> Triggered when the UI has become ready.
<<ui::restored>> Triggered when the UI is restored.
<<ui::skin-change>> Triggered when the user changes the skin.

Lua compatibility

table.maxn()
table.pack()
table.unpack()
table.unpackn() This function is our own’s extension to the API.


Functions

E
Defined at the locale module.
N
Defined at the locale module.
Q
Defined at the locale module.
T
Defined at the locale module.
abort(message)
A “benign” version of error.

Instead of showing the error message in a frightening red box with a stack trace, it’s shown as a normal alert. This is intended for usage errors whereas error is intended for programming errors.

abortive(val, message, ...)
A “benign” version of assert.

See abort.

alert
Alias for prompts.alert.
assert_arg_type(idx, val, type)

A utility for validating types of function arguments.

Example:

function print_message(msg)
  assert_arg_type(1, msg, "string")
  ...
end
declare(variable_name)

Declares global variables.

You won't normally use global variables, but if you have to, you first have to declare them:

declare('foo')
foo = 666
import_from(module_name, names)

Imports names from a module.

This is just a convenience function. Instead of doing the lengthy:

local stamp = assert(require('luafs.gc').stamp)
local rmstamp = assert(require('luafs.gc').rmstamp)
local stamp_create = assert(require('luafs.gc').stamp_create)
-- The assert() guards against typos.

Do:

local stamp, rmstamp, stamp_create
    = import_from('c.luafs', { 'stamp', 'rmstamp', 'stamp_create' })
require_legacy(module_name)
Requires a legacy module.

This is like require except that it turns off the global namespace protection during its operation so old code which sets global variable(s) won’t raise an exception.

Fields

arg
Alias for argv.

This alias exists for compatibility with source code written for /usr/bin/lua, the “official” Lua interpreter, which names that table “arg”.

You should prefer using “argv” in your code because grepping your code for this name is easier (“arg”, on the other hand, is a more generic term).

argv
Command line arguments.

A table holding command line arguments, starting at index 1. Index 0 holds the pathname of the script being run.

It is only available in standalone mode. Otherwise it is nil. See the user guide for details.

See usage example in misc/bin/htmlize

Events

<<core::after-restart>>
Triggered after Lua has been restarted (e.g., by pressing C-x l, by default).

-- Sound a beep so the user knows Lua's been
-- restarted successfully.
event.bind('core::after-restart', function()
  os.execute('beep -l 4')
end)

See also core::before-restart.

<<core::before-restart>>
Triggered just before Lua gets restarted.

See also core::after-restart.

<<core::before-vfs-shutdown>>
[Used internally].

End-users won’t need this.

<<core::loaded>>
[Used internally].

End-users won’t need this.

Triggered after the core’s _bootstrap.lua script has run. It’s used by the system to initiate the loading of user and system scripts.

<<ui::ready>>
Triggered when the UI has become ready.
<<ui::restored>>
Triggered when the UI is restored.

Whenever a user returns from running a shell command, or resumes a suspended MC process, the UI is restored.

For example, the screensaver uses this event to reschedule the animation.

<<ui::skin-change>>
Triggered when the user changes the skin.

See explanation in tty.style.

Lua compatibility

These are functions that were either removed or added in Lua 5.2+. We implement them so they're always available.
table.maxn()
table.pack()
table.unpack()
table.unpackn()
This function is our own’s extension to the API. It’s equivalent to table.unpack(t, 1, t.n or table.maxn(t)). It’s a version of table.unpack which is tolerant to nils.
generated by LDoc 1.4.3 Last updated 2016-08-23 17:29:40