Module _G

Extends Lua's _G table to provide extra functions and fields.

Fields

  • _HOME [string]: Path to the directory containing Textadept.
  • _LEXERPATH [string]: Paths to lexers, formatted like package.path.
  • _RELEASE [string]: The Textadept release version.
  • _USERHOME [string]: Path to the user's ~/.textadept/.
  • _CHARSET [string]: The character set encoding of the filesystem. This is used in File I/O.
  • RESETTING [bool]: If reset() has been called, this flag is true while the Lua state is being re-initialized.
  • WIN32 [bool]: If Textadept is running on Windows, this flag is true.
  • OSX [bool]: If Textadept is running on Mac OSX, this flag is true.

Functions

new_buffer () Creates a new buffer.
quit () Quits Textadept.
reset () Resets the Lua state by reloading all init scripts.
timeout (interval, f, ...) Calls a given function after an interval of time.
user_dofile (filename) Calls `dofile()` on the given filename in the user's Textadept directory.

Tables

_BUFFERS Table of all open buffers in Textadept.
_VIEWS Table of all views in Textadept.
arg Command line parameters.


Functions

new_buffer ()
Creates a new buffer. Generates a `BUFFER_NEW` event.

Return value:

the new buffer.
quit ()
Quits Textadept.
reset ()
Resets the Lua state by reloading all init scripts. Language-specific modules for opened files are NOT reloaded. Re-opening the files that use them will reload those modules. This function is useful for modifying init scripts (such as the user's `modules/textadept/keys.lua`) on the fly without having to restart Textadept. `_G.RESETTING` is set to `true` when re-initing the Lua State. Any scripts that need to differentiate between startup and reset can utilize this variable.
timeout (interval, f, ...)
Calls a given function after an interval of time. To repeatedly call the function, return true inside the function. A `nil` or `false` return value stops repetition.

Parameters

  • interval: The interval in seconds to call the function after.
  • f: The function to call.
  • ...: Additional arguments to pass to `f`.
user_dofile (filename)
Calls `dofile()` on the given filename in the user's Textadept directory. Errors are printed to the Textadept message buffer.

Parameters

  • filename: The name of the file (not path).

Return value:

true if successful; false otherwise.

See also:

Tables

_BUFFERS
Table of all open buffers in Textadept. Numeric keys have buffer values and buffer keys have their associated numeric keys.
_VIEWS
Table of all views in Textadept. Numeric keys have view values and view keys have their associated numeric keys.
arg
Command line parameters.

Valid XHTML 1.0!