Textadept
- Home |
- Download |
- Lua API |
- Source |
- Language Modules |
- Stats |
- Wiki |
- Mailing List
Contents
gui
The core gui table.
Fields
clipboard_text
(string, Read-only)
The text on the clipboard.
context_menu
A GTK menu defining the editor’s context menu.
docstatusbar_text
(string, Write-only)
The text displayed by the doc statusbar.
statusbar_text
(string)
The text displayed by the statusbar.
title
(string)
The title of the Textadept window.
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:
- 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
: Iftrue
, returns the integer index of the selected item in the filteredlist. The default value isfalse
, which returns the string item. Not compatible with a'--select-multiple'
filteredlist....
: Additional parameters to pass togui.dialog()
.
Usage:
gui.filteredlist('Title', 'Foo', { 'Bar', 'Baz' })
gui.filteredlist('Title', { 'Foo', 'Bar' }, { 'a', 'b', 'c', 'd' }, false, '--output-column', '2')
Return:
- Either a string or integer on success;
nil
otherwise.
get_split_table
()
Gets the current split view structure.
Return:
- table of split views. Each split view entry is a table with 4
fields:
1
,2
,vertical
, andsize
.1
and2
have values of either nested split view entries or the views themselves;vertical
is a flag indicating if the split is vertical or not; andsize
is the integer position of the split resizer.
goto_file
(filename, split, preferred_view, sloppy)
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.sloppy
: Flag indicating whether or not to not matchfilename
tobuffer.filename
exactly. Whentrue
, matchesfilename
to only the last part ofbuffer.filename
This is useful for run and compile commands which output relative filenames and paths instead of full ones and it is likely that the file in question is already open. The default value isfalse
.
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. The default value isfalse
.
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 atitle
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.
Tables
menubar
A table of GTK menus defining a menubar. (Write-only)
size
The size of the Textadept window ({ width, height }
).