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_item)
    menu_item: text of the menu item clicked.

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.
reload () Reloads event handlers.

Tables

_braces [Local table] A table of (integer) brace characters with their matches.
_error_details [Local table] A table of error string details.


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. Opens a new buffer (if one hasn't already been opened) for printing errors.

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.
reload ()
Reloads event handlers. Clears each event's table of handlers and reloads this module to reset to the default handlers.

Tables

_braces
[Local table] A table of (integer) brace characters with their matches.
_error_details
[Local table] A table of error string details. Each entry is a table with the following fields: pattern: the Lua pattern that matches a specific error string. filename: the index of the Lua capture that contains the filename the error occured in. line: the index of the Lua capture that contains the line number the error occured on. message: [Optional] the index of the Lua capture that contains the error's message. A call tip will be displayed if a message was captured. When an error message is double-clicked, the user is taken to the point of error.

Valid XHTML 1.0!