Module textadept.events
Module that handles Scintilla and Textadept notifications/events. Most of Textadept's functionality comes through handlers. Scintilla notifications, Textadept's own events, and user-defined events can all be handled.
Usage
Each event can have multiple handlers, which are simply Lua functions that
are called in the sequence they are added as handler functions. Sometimes it
is useful to have a handler run under a specific condition(s). If this is the
case, place a conditional in the function that returns if it isn't met.
For users creating their own events, one does not have to be explicitly
defined. A handler can simply be added for an event name, and 'handle'd when
necessary.
For reference, events will be shown in 'event(arguments)' format, but in
reality, the event is handled as 'handle(event, arguments)'.
Scintilla notifications:
char_added(ch)
ch: the (integer) character added.
save_point_reached()
save_point_left()
double_click(position, line)
position: the position of the beginning of the line clicked.
line: the line clicked.
update_ui()
macro_record(message, wParam, lParam)
message: the SCI_* message.
wParam: wParam in SCI_*.
lParam: lParam in SCI_*.
margin_click(margin, modifiers, position)
margin: the margin number.
modifiers: mouse modifiers.
position: the position of the beginning of the line at the point clicked.
user_list_selection(wParam, text)
wParam: the user list ID.
text: the text of the selected item.
uri_dropped(text)
text: the URI dropped.
call_tip_click(position)
position: 1 or 2 if the up or down arrow was clicked; 0 otherwise.
auto_c_selection(lParam, text)
lParam: the start position of the word being completed.
text: the text of the selected item.
Textadept events:
buffer_new()
buffer_deleted()
buffer_switch()
view_new()
view_switch()
quit()
Note: when adding a quit handler, it must be inserted at index 1 because
the default quit handler returns true, which ignores all subsequent
handlers.
keypress(code, shift, control, alt)
code: the key code.
shift: flag indicating whether or not shift is pressed.
control: flag indicating whether or not control is pressed.
alt: flag indicating whether or not alt is pressed.
menu_clicked(menu_id)
menu_id: the numeric ID of the menu item.
pm_view_filled()
Functions
| add_handler (event, f, index) | Adds a handler function to an event. |
| error (...) | Default error handler. |
| handle (event, ...) | Calls every handler function added to an event in sequence. |
| notification (n) | Handles Scintilla notifications. |
| set_title (buffer) | [Local function] Sets the title of the Textadept window to the buffer's filename. |
Functions
- add_handler (event, f, index)
-
Adds a handler function to an event.
Parameters
- event: The string event name.
- f: The Lua function to add.
- index: Optional index to insert the handler into.
- error (...)
-
Default error handler. Prints the errors to an error buffer.
Parameters
- ...: Error strings.
- handle (event, ...)
-
Calls every handler function added to an event in sequence. If true or false is returned by any handler, the iteration ceases. Normally this function is called by the system when necessary, but it can be called in scripts to handle user-defined events.
Parameters
- event: The string event name.
- ...: Arguments to the handler.
- notification (n)
-
Handles Scintilla notifications.
Parameters
- n: The Scintilla notification structure as a Lua table.
- set_title (buffer)
-
[Local function] Sets the title of the Textadept window to the buffer's filename.
Parameters
- buffer: The currently focused buffer.