view - Textadept API

# Textadept

- Home |
- Download |
- Lua API |
- Source |
- Language Modules |
- Stats |
- Wiki |
- Mailing List

# view

A Textadept view object.

## Fields

### `size` (number)

The position of the split resizer (if this view is part of a split view).

## Functions

### `goto_buffer`(view, n, relative)

Goes to buffer number n in the view. If relative is `true`, n is an index relative to the index of the current buffer in `_G._BUFFERS` instead of an absolute index. Emits `BUFFER_BEFORE_SWITCH` and `BUFFER_AFTER_SWITCH` events.

Parameters:

- `view`: The view to switch buffers in.
- `n`: A relative or absolute buffer index in `_G._BUFFERS`. An absolute index of `-1` goes to the last buffer.
- `relative`: Optional flag indicating whether n is a relative or absolute index. The default value is `false`, for an absolute index.

See also:

- `_G._BUFFERS`
- `events.BUFFER_BEFORE_SWITCH`
- `events.BUFFER_AFTER_SWITCH`

### `split`(view, vertical)

Splits the view into top and bottom views, unless vertical is `true`, focuses the new view, and returns both the old and new views. If vertical is `false`, splits the view vertically into left and right views. Emits a `VIEW_NEW` event.

Parameters:

- `view`: The view to split.
- `vertical`: Optional flag indicating whether or not to split the view vertically. The default value is `false`, for horizontal.

Return:

- old view and new view.

See also:

- `events.VIEW_NEW`

### `unsplit`(view)

Unsplits the view if possible, returning `true` on success.

Parameters:

- `view`: The view to unsplit.

Return:

- boolean if the view was unsplit or not.

## Tables

### `buffer`

The buffer the view contains. (Read-only)