Module textadept.io

Provides file input/output routines for Textadept. Opens and saves files and sessions and reads API files. Events: file_opened(filename) file_saved_as(filename)

Functions

close (buffer) Closes the current buffer.
close_all () Closes all open buffers.
load_session (filename, only_pm) Loads a Textadept session file.
open (filenames) Opens a list of files.
open_helper (filename) [Local function] Opens a file or goes to its already open buffer.
read_api_file (filename, word_chars) Reads an API file.
reload (buffer) Reloads the file in a given buffer.
save (buffer) Saves the current buffer to a file.
save_all () Saves all dirty buffers to their respective files.
save_as (buffer, filename) Saves the current buffer to a file different than its filename property.
save_session (filename) Saves a Textadept session to a file.

Tables

recent_files List of recently opened files.


Functions

close (buffer)
Closes the current buffer. If the buffer is dirty, the user is prompted to continue. The buffer is not saved automatically. It must be done manually.

Parameters

  • buffer: The buffer to close. This must be the currently focused buffer.

Usage:

buffer:close()
close_all ()
Closes all open buffers. If any buffer is dirty, the user is prompted to continue. No buffers are saved automatically. They must be saved manually.

Usage:

textadept.io.close_all()

Return value:

true if user did not cancel.
load_session (filename, only_pm)
Loads a Textadept session file. Textadept restores split views, opened buffers, cursor information, and project manager details.

Parameters

  • filename: The absolute path to the session file to load. Defaults to $HOME/.ta_session if not specified.
  • only_pm: Flag indicating whether or not to load only the Project Manager session settings. Defaults to false.

Usage:

textadept.io.load_session(filename)

Return value:

true if the session file was opened and read; false otherwise.
open (filenames)
Opens a list of files.

Parameters

  • filenames: A '\n' separated list of filenames to open. If none specified, the user is prompted to open files from a dialog.

Usage:

textadept.io.open(filename)
open_helper (filename)
[Local function] Opens a file or goes to its already open buffer.

Parameters

  • filename: The absolute path to the file to open.
read_api_file (filename, word_chars)
Reads an API file. Each non-empty line in the API file is structured as follows: identifier (parameters) description Whitespace is optional, but can used for formatting. In description, '\\n' will be interpreted as a newline (\n) character. 'Overloaded' identifiers are handled appropriately.

Parameters

  • filename: The absolute path to the API file to read.
  • word_chars: Characters considered to be word characters for determining the identifier to lookup. Its contents should be in Lua pattern format suitable for the character class construct.

Usage:

textadept.io.read_api_file(filename, '%w_')

Return value:

API table.
reload (buffer)
Reloads the file in a given buffer.

Parameters

  • buffer: The buffer to reload. This must be the currently focused buffer.

Usage:

buffer:reload()
save (buffer)
Saves the current buffer to a file.

Parameters

  • buffer: The buffer to save. Its 'filename' property is used as the path of the file to save to. This must be the currently focused buffer.

Usage:

buffer:save()
save_all ()
Saves all dirty buffers to their respective files.

Usage:

textadept.io.save_all()
save_as (buffer, filename)
Saves the current buffer to a file different than its filename property.

Parameters

  • buffer: The buffer to save. This must be the currently focused buffer.
  • filename:

Usage:

buffer:save_as(filename)
save_session (filename)
Saves a Textadept session to a file. Saves split views, opened buffers, cursor information, and project manager details.

Parameters

  • filename: The absolute path to the session file to save. Defaults to $HOME/.ta_session if not specified.

Usage:

textadept.io.save_session(filename)

Tables

recent_files
List of recently opened files.

Valid XHTML 1.0!