# _G

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

- - -

## Fields

- - -

<a id="CURSES"></a>
### `CURSES` (bool)

If Textadept is running in the terminal, this flag is `true`.
  Curses feature incompatibilities are listed in the [Appendix][].

  [Appendix]: ../14_Appendix.html#Curses.Compatibility

- - -

<a id="OSX"></a>
### `OSX` (bool)

If Textadept is running on Mac OSX, this flag is `true`.

- - -

<a id="RESETTING"></a>
### `RESETTING` (bool)

If [`reset()`](#reset) has been called, this flag is `true` while the Lua
  state is being re-initialized.

- - -

<a id="WIN32"></a>
### `WIN32` (bool)

If Textadept is running on Windows, this flag is `true`.

- - -

<a id="_CHARSET"></a>
### `_CHARSET` (string)

The character set encoding of the filesystem.
  This is used when [working with files](io.html).

- - -

<a id="_HOME"></a>
### `_HOME` (string)

The path to the directory containing Textadept.

- - -

<a id="_LEXERPATH"></a>
### `_LEXERPATH` (string)

The paths to lexers, formatted like Lua's [`package.path`][].

  [`package.path`]: http://lua.org/manual/5.2/manual.html#pdf-package.path

- - -

<a id="_RELEASE"></a>
### `_RELEASE` (string)

The Textadept release version string.

- - -

<a id="_USERHOME"></a>
### `_USERHOME` (string)

The path to the user's *~/.textadept/* directory, where all preferences and
  user-data is stored.
  On Windows machines *~/* is the value of the "USERHOME" environment
  variable, typically *C:\Users\username\\* or
  *C:\Documents and Settings\username\\*. On Linux, BSD, and Mac OSX
  machines *~/* is the value of "$HOME", typically */home/username/* and
  */Users/username/* respectively.

- - -


## Functions

- - -

<a id="quit"></a>
### `quit`()

Emits a `QUIT` event, and unless any handler returns `false`, quits
Textadept.

See also:

* [`events.QUIT`](events.html#QUIT)

- - -

<a id="reset"></a>
### `reset`()

Resets the Lua state by reloading all initialization scripts.
Language-specific modules for opened files are NOT reloaded. Re-opening the
files that use them will reload those modules instead.
This function is useful for modifying user scripts (such as
*~/.textadept/init.lua* and *~/.textadept/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.

See also:

* [`RESETTING`](#RESETTING)

- - -

<a id="timeout"></a>
### `timeout`(*interval, f, ...*)

Calls the function *f* with the given arguments after *interval* seconds and
then repeatedly while *f* returns `true`. A `nil` or `false` return value
stops repetition.

Parameters:

* *`interval`*: The interval in seconds to call *f* after.
* *`f`*: The function to call.
* *`...`*: Additional arguments to pass to *f*.

- - -


## Tables

- - -

<a id="_BUFFERS"></a>
### `_BUFFERS`

Table of all open buffers in Textadept.
Numeric keys have buffer values and buffer keys have their associated numeric
keys.

Usage:

* `_BUFFERS[n]      --> buffer at index n`
* `_BUFFERS[buffer] --> index of buffer in _BUFFERS`

See also:

* [`buffer`](buffer.html)

- - -

<a id="_VIEWS"></a>
### `_VIEWS`

Table of all views in Textadept.
Numeric keys have view values and view keys have their associated numeric
keys.

Usage:

* `_VIEWS[n]    --> view at index n`
* `_VIEWS[view] --> index of view in _VIEWS`

See also:

* [`view`](view.html)

- - -

<a id="arg"></a>
### `arg`

Table of command line parameters passed to Textadept.

See also:

* [`args`](args.html)

- - -

<a id="buffer"></a>
### `buffer`

The current [buffer](buffer.html) in the current [view](#view).

- - -

<a id="view"></a>
### `view`

The currently focused [view](view.html).

- - -

