Textadept
Defines | Functions | Variables
src/textadept_splits.c File Reference
#include <locale.h>
#include <iconv.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "gtdialog.h"
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include "Scintilla.h"
#include "SciLexer.h"

Defines

#define l_setglobalview(l, v)   (l_pushview(l, v), lua_setglobal(l, "view"))
#define l_setglobaldoc(l, d)   (l_pushdoc(l, d), lua_setglobal(l, "buffer"))
#define l_setcfunction(l, n, k, f)   (lua_pushcfunction(l, f), lua_setfield(l, (n > 0) ? n : n - 1, k))
#define l_setmetatable(l, n, k, i, ni)
#define lL_openlib(l, n, f)   (luaL_requiref(l, n, f, 1), lua_pop(l, 1))

Functions

static void new_buffer (sptr_t)
static Scintilla * new_view (sptr_t)
static int lL_init (lua_State *, int, char **, int)
LUALIB_API int luaopen_lpeg (lua_State *)
LUALIB_API int luaopen_lfs (lua_State *)
static int lL_event (lua_State *L, const char *name,...)
static void find_add_to_history (const char *text, ListStore *store)
static void f_clicked (FindButton button, void *_)
static int lfind_next (lua_State *L)
static int lfind_prev (lua_State *L)
static int lfind_focus (lua_State *L)
static int lfind_replace (lua_State *L)
static int lfind_replace_all (lua_State *L)
static int lfind__index (lua_State *L)
static int lfind__newindex (lua_State *L)
static int lce_focus (lua_State *L)
static int lce_show_completions (lua_State *L)
static int lce__index (lua_State *L)
static int lce__newindex (lua_State *L)
static int lgui_dialog (lua_State *L)
static void l_pushview (lua_State *L, Scintilla *view)
static int lgui_get_split_table (lua_State *L)
static Scintilla * l_toview (lua_State *L, int index)
static void l_pushdoc (lua_State *L, sptr_t doc)
static void goto_view (Scintilla *view)
static int lgui_goto_view (lua_State *L)
static int l_rawgetiint (lua_State *L, int index, int n)
static void l_pushmenu (lua_State *L, int index, void(*callback)(void), int submenu)
static int lgui_menu (lua_State *L)
static int lgui__index (lua_State *L)
static void set_statusbar_text (const char *text, int bar)
static int lgui__newindex (lua_State *L)
static void lL_globaldoccheck (lua_State *L, int narg)
static int lbuffer_check_global (lua_State *L)
static sptr_t l_todoc (lua_State *L, int index)
static void lL_gotodoc (lua_State *L, Scintilla *view, int n, int relative)
static void lL_removedoc (lua_State *L, sptr_t doc)
static void delete_buffer (sptr_t doc)
static int lbuffer_delete (lua_State *L)
static int lbuffer_text_range (lua_State *L)
static long lL_checkscintillaparam (lua_State *L, int *narg, int type)
static int l_callscintilla (lua_State *L, int msg, int wtype, int ltype, int rtype, int arg)
static int lbuf_closure (lua_State *L)
static int lbuf_property (lua_State *L)
static void lL_adddoc (lua_State *L, sptr_t doc)
static int lbuffer_new (lua_State *L)
static int lquit (lua_State *L)
static int lL_dofile (lua_State *L, const char *filename)
static int lreset (lua_State *L)
static int emit_timeout (void *data)
static int ltimeout (lua_State *L)
static int lstring_iconv (lua_State *L)
static void lL_cleartable (lua_State *L, int index)
static void lL_removeview (lua_State *L, Scintilla *view)
static void delete_view (Scintilla *view)
static int unsplit_view (Scintilla *view)
static void l_close (lua_State *L)
static void lL_notify (lua_State *L, struct SCNotification *n)
static void s_notify (Scintilla *view, int _, void *lParam, void *__)
static Scintilla * lL_checkview (lua_State *L, int narg)
static int lview_goto_buffer (lua_State *L)
static void split_view (Scintilla *view, int vertical)
static int lview_split (lua_State *L)
static int lview_unsplit (lua_State *L)
static int lview__index (lua_State *L)
static int lview__newindex (lua_State *L)
static void lL_addview (lua_State *L, Scintilla *view)
static void new_window ()
int main (int argc, char **argv)

Variables

static char * textadept_home = NULL
static Scintilla * focused_view
static lua_State * lua = NULL
static int closing = FALSE
static int tVOID = 0
static int tINT = 1
static int tLENGTH = 2
static int tBOOL = 5
static int tKEYMOD = 6
static int tSTRING = 7
static int tSTRINGRESULT = 8

Define Documentation

#define l_setcfunction (   l,
  n,
  k,
 
)    (lua_pushcfunction(l, f), lua_setfield(l, (n > 0) ? n : n - 1, k))
#define l_setglobaldoc (   l,
 
)    (l_pushdoc(l, d), lua_setglobal(l, "buffer"))
#define l_setglobalview (   l,
 
)    (l_pushview(l, v), lua_setglobal(l, "view"))
#define l_setmetatable (   l,
  n,
  k,
  i,
  ni 
)
Value:
{ \
  if (luaL_newmetatable(l, k)) { \
    l_setcfunction(l, -1, "__index", i); \
    l_setcfunction(l, -1, "__newindex", ni); \
  } \
  lua_setmetatable(l, (n > 0) ? n : n - 1); \
}
#define lL_openlib (   l,
  n,
 
)    (luaL_requiref(l, n, f, 1), lua_pop(l, 1))

Function Documentation

static void delete_buffer ( sptr_t  doc) [static]

Removes the Scintilla buffer from the current Scintilla view.

Parameters:
docThe Scintilla document.
See also:
lL_removedoc
static void delete_view ( Scintilla *  view) [static]

Removes a Scintilla view.

Parameters:
viewThe Scintilla view to remove.
See also:
lL_removeview
static int emit_timeout ( void *  data) [static]
static void f_clicked ( FindButton  button,
void *  _ 
) [static]

Signal for a find box button click.

static void find_add_to_history ( const char *  text,
ListStore *  store 
) [static]

Adds the given text to the find/replace history list if it is not at the top.

Parameters:
textThe text to add.
storeThe ListStore to add the text to.
static void goto_view ( Scintilla *  view) [static]

Change focus to the given Scintilla view. Generates 'view_before_switch' and 'view_after_switch' events.

Parameters:
viewThe Scintilla view to focus.
static int l_callscintilla ( lua_State *  L,
int  msg,
int  wtype,
int  ltype,
int  rtype,
int  arg 
) [static]

Calls a function as a Scintilla function. Does not remove any arguments from the stack, but does push results.

Parameters:
LThe Lua state.
msgThe Scintilla message.
wtypeThe type of Scintilla wParam.
ltypeThe type of Scintilla lParam.
rtypeThe type of the Scintilla return.
argThe stack index of the first Scintilla parameter. Subsequent elements will also be passed to Scintilla as needed.
Returns:
number of results pushed onto the stack.
See also:
lL_checkscintillaparam
static void l_close ( lua_State *  L) [static]

Closes the Lua state. Unsplits and destroys all Scintilla views and removes all Scintilla documents, before closing the state.

Parameters:
LThe Lua state.
static void l_pushdoc ( lua_State *  L,
sptr_t  doc 
) [static]

Pushes the Scintilla document onto the stack. The document must have previously been added with lL_adddoc.

Parameters:
LThe Lua state.
docThe document to push.
See also:
lL_adddoc
static void l_pushmenu ( lua_State *  L,
int  index,
void(*)(void)  callback,
int  submenu 
) [static]

Pushes a menu created from the table at the given valid index onto the stack. Consult the LuaDoc for the table format.

Parameters:
LThe Lua state.
indexThe stack index of the table to create the menu from.
callbackAn optional GTK callback function associated with each menu item.
submenuFlag indicating whether or not this menu is a submenu.
static void l_pushview ( lua_State *  L,
Scintilla *  view 
) [static]

Pushes the Scintilla view onto the stack. The view must have previously been added with lL_addview.

Parameters:
LThe Lua state.
viewThe Scintilla view to push.
See also:
lL_addview
static int l_rawgetiint ( lua_State *  L,
int  index,
int  n 
) [static]

Returns the value t[n] as an integer where t is the value at the given valid index. The access is raw; that is, it does not invoke metamethods.

Parameters:
LThe Lua state.
indexThe stack index of the table.
nThe index in the table to get.
Returns:
integer
static sptr_t l_todoc ( lua_State *  L,
int  index 
) [static]

Returns the buffer at the given acceptable index as a Scintilla document.

Parameters:
LThe Lua state.
indexStack index of the buffer.
Returns:
Scintilla document
static Scintilla* l_toview ( lua_State *  L,
int  index 
) [static]

Returns the view at the given acceptable index as a Scintilla view.

Parameters:
LThe Lua state.
indexStack index of the view.
Returns:
Scintilla view
static int lbuf_closure ( lua_State *  L) [static]
static int lbuf_property ( lua_State *  L) [static]

`buffer.__index` Lua metatable.

static int lbuffer_check_global ( lua_State *  L) [static]

`buffer.check_global()` Lua function.

static int lbuffer_delete ( lua_State *  L) [static]

`buffer.delete()` Lua function.

static int lbuffer_new ( lua_State *  L) [static]

`_G.buffer_new()` Lua function.

static int lbuffer_text_range ( lua_State *  L) [static]

`buffer.text_range()` Lua function.

static int lce__index ( lua_State *  L) [static]

`command_entry.__index` Lua metatable.

static int lce__newindex ( lua_State *  L) [static]

`command_entry.__newindex` Lua metatable.

static int lce_focus ( lua_State *  L) [static]

`command_entry.focus()` Lua function.

static int lce_show_completions ( lua_State *  L) [static]

`command_entry.show_completions()` Lua function.

static int lfind__index ( lua_State *  L) [static]

`find.__index` Lua metatable.

static int lfind__newindex ( lua_State *  L) [static]

`find.__newindex` Lua metatable.

static int lfind_focus ( lua_State *  L) [static]

`find.focus()` Lua function.

static int lfind_next ( lua_State *  L) [static]

`find.find_next()` Lua function.

static int lfind_prev ( lua_State *  L) [static]

`find.find_prev()` Lua function.

static int lfind_replace ( lua_State *  L) [static]

`find.replace()` Lua function.

static int lfind_replace_all ( lua_State *  L) [static]

`find.replace_all()` Lua function.

static int lgui__index ( lua_State *  L) [static]

`gui.__index` Lua metatable.

static int lgui__newindex ( lua_State *  L) [static]

`gui.__newindex` Lua metatable.

static int lgui_dialog ( lua_State *  L) [static]

`gui.dialog()` Lua function.

static int lgui_get_split_table ( lua_State *  L) [static]

`gui.get_split_table()` Lua function.

static int lgui_goto_view ( lua_State *  L) [static]

`gui.goto_view()` Lua function.

static int lgui_menu ( lua_State *  L) [static]

`gui.menu()` Lua function.

static void lL_adddoc ( lua_State *  L,
sptr_t  doc 
) [static]

Adds a Scintilla document with a metatable to the 'buffers' registry table.

Parameters:
LThe Lua state.
docThe Scintilla document to add.
static void lL_addview ( lua_State *  L,
Scintilla *  view 
) [static]

Adds the Scintilla view with a metatable to the 'views' registry table.

Parameters:
LThe Lua state.
viewThe Scintilla view to add.
static long lL_checkscintillaparam ( lua_State *  L,
int *  narg,
int  type 
) [static]

Checks whether the function argument narg is the given Scintilla parameter type and returns it cast to the proper type.

Parameters:
LThe Lua state.
nargThe stack index of the Scintilla parameter.
typeThe Scintilla type to convert to.
Returns:
Scintilla param
static Scintilla* lL_checkview ( lua_State *  L,
int  narg 
) [static]

Checks whether the function argument narg is a Scintilla view and returns this view cast to a Scintilla.

Parameters:
LThe Lua state.
nargThe stack index of the Scintilla view.
Returns:
Scintilla view
static void lL_cleartable ( lua_State *  L,
int  index 
) [static]

Clears a table at the given valid index by setting all of its keys to nil.

Parameters:
LThe Lua state.
indexThe stack index of the table.
static int lL_dofile ( lua_State *  L,
const char *  filename 
) [static]

Loads and runs the given file.

Parameters:
LThe Lua state.
filenameThe file name relative to textadept_home.
Returns:
1 if there are no errors or 0 in case of errors.
static int lL_event ( lua_State *  L,
const char *  name,
  ... 
) [static]

Emits an event.

Parameters:
LThe Lua state.
nameThe event name.
...Arguments to pass with the event. Each pair of arguments should be a Lua type followed by the data value itself. For LUA_TLIGHTUSERDATA and LUA_TTABLE types, push the data values to the stack and give the value returned by luaL_ref(); luaL_unref() will be called appropriately. The list must be terminated with a -1.
Returns:
TRUE or FALSE depending on the boolean value returned by the event handler, if any.
static void lL_globaldoccheck ( lua_State *  L,
int  narg 
) [static]

Checks whether the function argument narg is a Scintilla document. If not, raises an error.

Parameters:
LThe Lua state.
nargThe stack index of the Scintilla document.
Returns:
Scintilla document
static void lL_gotodoc ( lua_State *  L,
Scintilla *  view,
int  n,
int  relative 
) [static]

Switches to a document in the given view.

Parameters:
LThe Lua state.
viewThe Scintilla view.
nRelative or absolute index of the document to switch to. An absolute n of -1 represents the last document.
relativeFlag indicating whether or not n is relative.
static int lL_init ( lua_State *  L,
int  argc,
char **  argv,
int  reinit 
) [static]

Initializes or re-initializes the Lua state. Populates the state with global variables and functions, then runs the 'core/init.lua' script.

Parameters:
LThe Lua state.
argcThe number of command line parameters.
argvThe array of command line parameters.
reinitFlag indicating whether or not to reinitialize the Lua state.
Returns:
TRUE on success, FALSE otherwise.
static void lL_notify ( lua_State *  L,
struct SCNotification *  n 
) [static]

Emits a Scintilla notification event.

Parameters:
LThe Lua state.
nThe Scintilla notification struct.
See also:
lL_event
static void lL_removedoc ( lua_State *  L,
sptr_t  doc 
) [static]

Removes the Scintilla document from the 'buffers' registry table. The document must have been previously added with lL_adddoc. It is removed from any other views showing it first. Therefore, ensure the length of 'buffers' is more than one unless quitting the application.

Parameters:
LThe Lua state.
docThe Scintilla document to remove.
See also:
lL_adddoc
static void lL_removeview ( lua_State *  L,
Scintilla *  view 
) [static]

Removes the Scintilla view from the 'views' registry table. The view must have been previously added with lL_addview.

Parameters:
LThe Lua state.
viewThe Scintilla view to remove.
See also:
lL_addview
static int lquit ( lua_State *  L) [static]

`_G.quit()` Lua function.

static int lreset ( lua_State *  L) [static]

`_G.reset()` Lua function.

static int lstring_iconv ( lua_State *  L) [static]

`string.iconv()` Lua function.

static int ltimeout ( lua_State *  L) [static]

`_G.timeout()` Lua function.

LUALIB_API int luaopen_lfs ( lua_State *  )
LUALIB_API int luaopen_lpeg ( lua_State *  )
static int lview__index ( lua_State *  L) [static]

`view.__index` Lua metatable.

static int lview__newindex ( lua_State *  L) [static]

`view.__newindex` Lua metatable.

static int lview_goto_buffer ( lua_State *  L) [static]

`view.goto_buffer()` Lua function.

static int lview_split ( lua_State *  L) [static]

`view.split()` Lua function.

static int lview_unsplit ( lua_State *  L) [static]

`view.unsplit()` Lua function.

int main ( int  argc,
char **  argv 
)

Runs Textadept. Initializes the Lua state, creates the user interface, and then runs `core/init.lua` followed by `init.lua`.

Parameters:
argcThe number of command line params.
argvThe array of command line params.
static void new_buffer ( sptr_t  doc) [static]

Creates a new Scintilla document and adds it to the Lua state. Generates 'buffer_before_switch' and 'buffer_new' events.

Parameters:
docAlmost always zero, except for the first Scintilla view created, in which its doc pointer would be given here.
See also:
lL_adddoc
static Scintilla * new_view ( sptr_t  doc) [static]

Creates a new Scintilla view. Generates a 'view_new' event.

Parameters:
docThe document to load in the new view. Almost never zero, except for the first Scintilla view created, in which there is no doc pointer.
Returns:
Scintilla view
See also:
lL_addview
static void new_window ( ) [static]

Creates the Textadept window. The window contains a menubar, frame for Scintilla views, hidden find box, hidden command entry, and two status bars: one for notifications and the other for buffer status.

static void s_notify ( Scintilla *  view,
int  _,
void *  lParam,
void *  __ 
) [static]

Signal for a Scintilla notification.

static void set_statusbar_text ( const char *  text,
int  bar 
) [static]
static void split_view ( Scintilla *  view,
int  vertical 
) [static]

Splits the given Scintilla view into two views. The new view shows the same document as the original one.

Parameters:
viewThe Scintilla view to split.
verticalFlag indicating whether to split the view vertically or horozontally.
static int unsplit_view ( Scintilla *  view) [static]

Unsplits the pane a given Scintilla view is in and keeps the view. All views in the other pane are deleted.

Parameters:
viewThe Scintilla view to keep when unsplitting.
See also:
remove_views_from_pane
delete_view

Variable Documentation

int closing = FALSE [static]
Scintilla* focused_view [static]
lua_State* lua = NULL [static]
int tBOOL = 5 [static]
char* textadept_home = NULL [static]
int tINT = 1 [static]
int tKEYMOD = 6 [static]
int tLENGTH = 2 [static]
int tSTRING = 7 [static]
int tSTRINGRESULT = 8 [static]
int tVOID = 0 [static]