Module gui
The core gui table.
Fields
title[string]: The title of the Textadept window.context_menu: A GTK menu defining the editor's context menu.clipboard_text[string]: The text on the clipboard. (Read-only)statusbar_text[string]: The text displayed by the statusbar.docstatusbar_text[string]: The text displayed by the doc statusbar. (Write-only)
Functions
| _print (buffer_type, ...) | Helper function for printing messages to buffers. |
| dialog (kind, ...) | Displays a gcocoadialog of a specified type with the given string arguments. |
| filteredlist (title, columns, items, int_return, ...) | Shortcut function for `gui.dialog('filtered_list', ...)` with 'Ok' and 'Cancel' buttons. |
| get_split_table () | Gets the current split view structure. |
| goto_file (filename, split, preferred_view) | Goes to the buffer with the given filename. |
| goto_view (n, relative) | Goes to the specified view. |
| gtkmenu (menu_table) | Creates a GTK menu, returning the userdata. |
| print (...) | Prints messages to the Textadept message buffer. |
| select_theme () | Prompts the user to select an editor theme from a filtered list. |
| set_theme (name) | Sets the editor theme from the given name. |
| switch_buffer () | Displays a dialog with a list of buffers to switch to and switches to the selected one, if any. |
Tables
| menubar | A table of GTK menus defining a menubar. |
| size | The size of the Textadept window (`{ width, height }`). |
Functions
- _print (buffer_type, ...)
-
Helper function for printing messages to buffers. Splits the view and opens a new buffer for printing messages. If the message buffer is already open and a view is currently showing it, the message is printed to that view. Otherwise the view is split, goes to the open message buffer, and prints to it.
Parameters
- buffer_type: String type of message buffer.
- ...: Message strings.
Usage
- gui._print(_L['[Error Buffer]'], error_message)
- gui._print(_L['[Message Buffer]'], message)
- dialog (kind, ...)
-
Displays a gcocoadialog of a specified type with the given string arguments. Each argument is like a string in Lua's `arg` table. Tables of strings are allowed as arguments and are expanded in place. This is useful for filteredlist dialogs with many items.
Parameters
- kind: The kind of gcocoadialog.
- ...: Parameters to the gcocoadialog.
Return value:
string gcocoadialog result. - filteredlist (title, columns, items, int_return, ...)
-
Shortcut function for `gui.dialog('filtered_list', ...)` with 'Ok' and 'Cancel' buttons.
Parameters
- title: The title for the filteredlist dialog.
- columns: A column name or list of column names.
- items: An item or list of items.
- int_return: If `true`, returns the integer index of the selected item in the filteredlist. Defaults to `false`, which returns the string item. Not compatible with a `'--select-multiple'` filteredlist.
- ...: Additional parameters to pass to `gui.dialog()`.
Usage
- gui.filteredlist('Title', 'Foo', { 'Bar', 'Baz' })
- gui.filteredlist('Title', { 'Foo', 'Bar' }, { 'a', 'b', 'c', 'd' }, false, '--output-column', '2')
Return value:
Either a string or integer on success; `nil` otherwise. - get_split_table ()
-
Gets the current split view structure.
Return value:
table of split views. Each split view entry is a table with 4 fields: `1`, `2`, `vertical`, and `size`. `1` and `2` have values of either split view entries or the index of the buffer shown in each view; `vertical` is a flag indicating if the split is vertical or not; and `size` is the integer position of the split resizer. - goto_file (filename, split, preferred_view)
-
Goes to the buffer with the given filename. If the desired buffer is open in a view, goes to that view. Otherwise, opens the buffer in either the `preferred_view` if given, the first view that is not the current one, a split view if `split` is `true`, or the current view.
Parameters
- filename: The filename of the buffer to go to.
- split: If there is only one view, split it and open the buffer in the other view.
- preferred_view: When multiple views exist and the desired buffer is not open in any of them, open it in this one.
- goto_view (n, relative)
-
Goes to the specified view. Generates `VIEW_BEFORE_SWITCH` and `VIEW_AFTER_SWITCH` events.
Parameters
- n: A relative or absolute view index.
- relative: Flag indicating if n is a relative index or not. Defaults to false.
- gtkmenu (menu_table)
-
Creates a GTK menu, returning the userdata.
Parameters
- menu_table: A table defining the menu. It is an ordered list of tables with a string menu item, integer menu ID, and optional keycode and modifier mask. The latter two are used to display key shortcuts in the menu. The string menu item is handled as follows: `'gtk-*'` - a stock menu item is created based on the GTK stock-id. `'separator'` - a menu separator item is created. Otherwise a regular menu item with a mnemonic is created. Submenus are just nested menu-structure tables. Their title text is defined with a `title` key.
See also:
- print (...)
-
Prints messages to the Textadept message buffer. Opens a new buffer (if one has not already been opened) for printing messages.
Parameters
- ...: Message strings.
- select_theme ()
- Prompts the user to select an editor theme from a filtered list.
- set_theme (name)
-
Sets the editor theme from the given name. Themes in `_USERHOME/themes/` are checked first, followed by `_HOME/themes/`. If the name contains slashes ('/' on Linux and Mac OSX and '\' on Win32), it is assumed to be an absolute path so `_USERHOME` and `_HOME` are not checked. Throws an error if the theme is not found. Any errors in the theme are printed to `io.stderr`.
Parameters
- name: The name or absolute path of a theme. If nil, sets the default theme.
- switch_buffer ()
- Displays a dialog with a list of buffers to switch to and switches to the selected one, if any.