src/textadept.c File Reference

#include "textadept.h"

Defines

#define gbool   gboolean
#define signal(o, s, c)   g_signal_connect(G_OBJECT(o), s, G_CALLBACK(c), 0)
#define attach(w, x1, x2, y1, y2, xo, yo, xp, yp)   gtk_table_attach(GTK_TABLE(findbox), w, x1, x2, y1, y2, xo, yo, xp, yp)
#define ao_expand   (GtkAttachOptions)(GTK_EXPAND | GTK_FILL)
#define ao_normal   (GtkAttachOptions)(GTK_SHRINK | GTK_FILL)

Functions

static void s_notification (GtkWidget *, gint, gpointer, gpointer)
static void s_command (GtkWidget *, gint, gpointer, gpointer)
static gbool s_keypress (GtkWidget *, GdkEventKey *, gpointer)
static gbool s_buttonpress (GtkWidget *, GdkEventButton *, gpointer)
static gbool w_focus (GtkWidget *, GdkEventFocus *, gpointer)
static gbool w_keypress (GtkWidget *, GdkEventKey *, gpointer)
static gbool w_exit (GtkWidget *, GdkEventAny *, gpointer)
GtkWidget * pm_create_ui ()
static int pm_search_equal_func (GtkTreeModel *, int, const char *, GtkTreeIter *, gpointer)
static int pm_sort_iter_compare_func (GtkTreeModel *, GtkTreeIter *, GtkTreeIter *, gpointer)
static void pm_entry_activated (GtkWidget *, gpointer)
static void pm_entry_changed (GtkComboBoxEntry *, gpointer)
static gbool pm_keypress (GtkWidget *, GdkEventKey *, gpointer)
static void pm_row_expanded (GtkTreeView *, GtkTreeIter *, GtkTreePath *, gpointer)
static void pm_row_collapsed (GtkTreeView *, GtkTreeIter *, GtkTreePath *, gpointer)
static void pm_row_activated (GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *, gpointer)
static gbool pm_buttonpress (GtkTreeView *, GdkEventButton *, gpointer)
static gbool pm_popup_menu (GtkWidget *, gpointer)
GtkWidget * find_create_ui ()
static void find_button_clicked (GtkWidget *, gpointer)
static int cec_match_func (GtkEntryCompletion *, const char *, GtkTreeIter *, gpointer)
static gbool cec_match_selected (GtkEntryCompletion *, GtkTreeModel *, GtkTreeIter *, gpointer)
static void c_activated (GtkWidget *, gpointer)
static gbool c_keypress (GtkWidget *, GdkEventKey *, gpointer)
int main (int argc, char **argv)
void create_ui ()
GtkWidget * new_scintilla_window (sptr_t buffer_id)
void remove_scintilla_window (GtkWidget *editor)
void new_scintilla_buffer (GtkWidget *editor, int create, int addref)
void remove_scintilla_buffer (sptr_t doc)
void split_window (GtkWidget *editor, int vertical)
void remove_scintilla_windows_in_pane (GtkWidget *pane)
int unsplit_window (GtkWidget *editor)
void set_menubar (GtkWidget *new_menubar)
void set_statusbar_text (const char *text, int docbar)
static void switch_to_view (GtkWidget *editor)
void pm_toggle_focus ()
void find_toggle_focus ()
static void find_add_to_history (const char *text, GtkListStore *store)
void ce_toggle_focus ()

Variables

GtkWidget * window
GtkWidget * focused_editor
GtkWidget * menubar
GtkWidget * statusbar
GtkWidget * docstatusbar
char * textadept_home
GtkWidget * pm_view
GtkWidget * pm_entry
GtkWidget * pm_container
GtkTreeStore * pm_store
GtkWidget * findbox
GtkWidget * find_entry
GtkWidget * replace_entry
GtkWidget * fnext_button
GtkWidget * fprev_button
GtkWidget * r_button
GtkWidget * ra_button
GtkWidget * match_case_opt
GtkWidget * whole_word_opt
GtkWidget * lua_opt
GtkWidget * in_files_opt
GtkListStore * find_store
GtkListStore * repl_store
GtkWidget * command_entry
GtkListStore * cec_store
GtkEntryCompletion * command_entry_completion

Define Documentation

#define ao_expand   (GtkAttachOptions)(GTK_EXPAND | GTK_FILL)
#define ao_normal   (GtkAttachOptions)(GTK_SHRINK | GTK_FILL)
#define attach ( w,
x1,
x2,
y1,
y2,
xo,
yo,
xp,
yp   )     gtk_table_attach(GTK_TABLE(findbox), w, x1, x2, y1, y2, xo, yo, xp, yp)
#define gbool   gboolean
#define signal ( o,
s,
 )     g_signal_connect(G_OBJECT(o), s, G_CALLBACK(c), 0)

Function Documentation

static void c_activated ( GtkWidget *  entry,
gpointer  udata 
) [static]

Signal for the 'enter' key being pressed in the Command Entry.

static gbool c_keypress ( GtkWidget *  entry,
GdkEventKey *  event,
gpointer  udata 
) [static]

Signal for a keypress inside the Command Entry.

void ce_toggle_focus (  ) 

Toggles focus between a Scintilla window and the Command Entry. When the entry is visible, the statusbars are temporarily hidden.

static int cec_match_func ( GtkEntryCompletion *  entry,
const char *  key,
GtkTreeIter *  iter,
gpointer  udata 
) [static]

Sets every item in the Command Entry Model to be a match. For each attempted completion, the Command Entry Model is filled with the results from a call to Lua to make a list of possible completions. Therefore, every item in the list is valid.

static gbool cec_match_selected ( GtkEntryCompletion *  entry,
GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  udata 
) [static]

Enters the requested completion text into the Command Entry. The last word at the cursor is replaced with the completion. A word consists of any alphanumeric character or underscore.

void create_ui (  ) 

Creates the user interface. The UI consists of:

  • A menubar initially hidden and empty. It should be populated by script and then shown.
  • A side pane. It contains a treeview for hierarchical data sets, such as a file structure for project management.
  • A frame for Scintilla windows.
  • A find text frame initially hidden.
  • A command entry initially hidden. This entry accepts and runs Lua code in the current Lua state.
  • Two status bars: one for notifications, the other for document status.
static void find_add_to_history ( const char *  text,
GtkListStore *  store 
) [static]

Adds the given text to the Find/Replace history list if it's not the first item.

Parameters:
text The text to add.
store The GtkListStore to add the text to.
static void find_button_clicked ( GtkWidget *  button,
gpointer  udata 
) [static]

Signal for a Find frame button click. Performs the appropriate action depending on the button clicked.

GtkWidget * find_create_ui (  ) 

Creates the Find/Replace text frame.

void find_toggle_focus (  ) 

Toggles the focus between the Find/Replace frame and the current Scintilla window.

int main ( int  argc,
char **  argv 
)

Runs Textadept in Linux or Mac. Inits the Lua State, creates the user interface, loads the core/init.lua script, and also loads init.lua.

Parameters:
argc The number of command line params.
argv The array of command line params.
void new_scintilla_buffer ( GtkWidget *  editor,
int  create,
int  addref 
)

Creates a new Scintilla buffer for a newly created Scintilla window. The buffer's default properties are set via 'set_default_buffer_properties', but the default style is set here. Generates a 'buffer_new' event.

Parameters:
editor The Scintilla window to associate the buffer with.
create Flag indicating whether or not to create a buffer. If FALSE, the Scintilla window already has a buffer associated with it (typically because new_scintilla_window was passed a non-NULL buffer_id).
addref Flag indicating whether or not to add a reference to the buffer in the Scintilla window when create is FALSE. This is necessary for creating Scintilla windows in split views. If a buffer appears in two separate Scintilla windows, that buffer should have multiple references so when one Scintilla window closes, the buffer is not deleted because its reference count is not zero.
See also:
l_add_scintilla_buffer
GtkWidget* new_scintilla_window ( sptr_t  buffer_id  ) 

Creates a new Scintilla window. The Scintilla window is the GTK widget that displays a Scintilla buffer. The window's default properties are set via 'set_default_editor_properties'. Generates a 'view_new' event.

Parameters:
buffer_id A Scintilla buffer ID to load into the new window. If NULL, creates a new Scintilla buffer and loads it into the new window.
Returns:
the Scintilla window.
See also:
l_add_scintilla_window
static gbool pm_buttonpress ( GtkTreeView *  view,
GdkEventButton *  event,
gpointer  udata 
) [static]

Signal for a Project Manager mouse click. If it is a right-click, popup a context menu for the selected item.

See also:
l_pm_popup_context_menu
GtkWidget * pm_create_ui (  ) 

Creates the Project Manager pane. It consists of an entry box and a treeview called 'textadept-pm-entry' and 'textadept-pm-view' respectively for styling via gtkrc. The treeview model consists of a gdk-pixbuf for icons and markup text.

static void pm_entry_activated ( GtkWidget *  entry,
gpointer  udata 
) [static]

Signal for the activation of the Project Manager entry. Requests contents for the Project Manager.

static void pm_entry_changed ( GtkComboBoxEntry *  entry,
gpointer  udata 
) [static]

Signal for a change of the text in the Project Manager entry. Requests contents for the Project Manager.

static gbool pm_keypress ( GtkWidget *  pm,
GdkEventKey *  event,
gpointer  udata 
) [static]

Signal for a Project Manager keypress. Currently handled keypresses:

  • Escape - Refocuses the Scintilla view.
static gbool pm_popup_menu ( GtkWidget *  view,
gpointer  udata 
) [static]

Signal for popping up a Project Manager context menu. Typically Shift+F10 activates this event.

See also:
l_pm_popup_context_menu
static void pm_row_activated ( GtkTreeView *  view,
GtkTreePath *  path,
GtkTreeViewColumn *  column,
gpointer  udata 
) [static]

Signal for the activation of a Project Manager node. Performs the appropriate action on a selected Project Manager node. If the node is a collapsed parent, it is expanded; otherwise the parent is collapsed. If the node is not a parent at all, a Lua action is performed.

static void pm_row_collapsed ( GtkTreeView *  view,
GtkTreeIter *  iter,
GtkTreePath *  path,
gpointer  udata 
) [static]

Signal for a Project Manager parent collapse. Removes all Project Manager children from a parent node being closed. Re-adds a dummy child to indicate this parent is still a parent. It will be removed when the parent is re-opened.

static void pm_row_expanded ( GtkTreeView *  view,
GtkTreeIter *  iter,
GtkTreePath *  path,
gpointer  udata 
) [static]

Signal for a Project Manager parent expansion. Requests contents for a Project Manager parent node being opened. Since a parent is given a dummy child by default in order to indicate that it is a parent, that dummy child is removed.

static int pm_search_equal_func ( GtkTreeModel *  model,
int  col,
const char *  key,
GtkTreeIter *  iter,
gpointer  udata 
) [static]

When searching the Project Manager treeview, matches are tree items that contain the search text as a substring.

Parameters:
model The GtkTreeModel for the treeview.
col The column number to use for comparing search text to.
key The search text.
iter The GtkTreeIter for each tree node being compared.
static int pm_sort_iter_compare_func ( GtkTreeModel *  model,
GtkTreeIter *  a,
GtkTreeIter *  b,
gpointer  udata 
) [static]

Sorts the Project Manager treeview case sensitively.

Parameters:
model The GtkTreeModel for the treeview.
a The GtkTreeIter for one tree node being compared.
b The GtkTreeIter for the other tree node being compared.
void pm_toggle_focus (  ) 

Toggles the focus between the Project Manager and the current Scintilla window.

void remove_scintilla_buffer ( sptr_t  doc  ) 

Removes the Scintilla buffer from the current Scintilla window.

Parameters:
doc The Scintilla buffer ID to remove.
See also:
l_remove_scintilla_buffer
void remove_scintilla_window ( GtkWidget *  editor  ) 

Removes a Scintilla window.

Parameters:
editor The Scintilla window to remove.
See also:
l_remove_scintilla_window
void remove_scintilla_windows_in_pane ( GtkWidget *  pane  ) 

For a given GTK pane, remove the Scintilla windows inside it recursively.

Parameters:
pane The GTK pane to remove Scintilla windows from.
See also:
remove_scintilla_window
static gbool s_buttonpress ( GtkWidget *  editor,
GdkEventButton *  event,
gpointer  udata 
) [static]

Signal for a Scintilla mouse click. If it is a right-click, popup a context menu.

See also:
l_ta_popup_context_menu
static void s_command ( GtkWidget *  editor,
gint  wParam,
gpointer  lParam,
gpointer  udata 
) [static]

Signal for a Scintilla command. Currently handles SCEN_SETFOCUS.

static gbool s_keypress ( GtkWidget *  editor,
GdkEventKey *  event,
gpointer  udata 
) [static]

Signal for a Scintilla keypress. Collects the modifier states as flags and calls Lua to handle the keypress.

static void s_notification ( GtkWidget *  editor,
gint  wParam,
gpointer  lParam,
gpointer  udata 
) [static]

Signal for a Scintilla notification.

void set_menubar ( GtkWidget *  new_menubar  ) 

Sets a user-defined GTK menubar and displays it.

Parameters:
new_menubar The GTK menubar.
See also:
l_ta_mt_newindex
void set_statusbar_text ( const char *  text,
int  docbar 
)

Sets the notification statusbar text.

Parameters:
text The text to display.
docbar Flag indicating whether or not the statusbar text is for the docstatusbar.
void split_window ( GtkWidget *  editor,
int  vertical 
)

Splits a Scintilla window into two windows separated by a GTK pane. The buffer in the original pane is also shown in the new pane.

Parameters:
editor The Scintilla window to split.
vertical Flag indicating whether to split the window vertically or horozontally.
static void switch_to_view ( GtkWidget *  editor  )  [static]

Helper function for switching the focused view to the given one.

Parameters:
editor The Scintilla window to focus.
See also:
s_notification
s_command
int unsplit_window ( GtkWidget *  editor  ) 

Unsplits the pane a given Scintilla window is in and keeps that window. If the pane to discard contains other Scintilla windows, they are removed recursively.

Parameters:
editor The Scintilla window to keep when unsplitting.
See also:
remove_scintilla_windows_in_pane
remove_scintilla_window
static gbool w_exit ( GtkWidget *  window,
GdkEventAny *  event,
gpointer  udata 
) [static]

Signal for exiting Textadept. Closes the Lua State and releases resources. Generates a 'quit' event.

See also:
l_close
static gbool w_focus ( GtkWidget *  window,
GdkEventFocus *  event,
gpointer  udata 
) [static]

Signal for a Textadept window focus change.

static gbool w_keypress ( GtkWidget *  window,
GdkEventKey *  event,
gpointer  udata 
) [static]

Signal for a Textadept keypress. Currently handled keypresses:

  • Escape - hides the search frame if it's open.

Variable Documentation

GtkListStore* cec_store
GtkWidget* command_entry
GtkEntryCompletion* command_entry_completion
GtkWidget * docstatusbar
GtkWidget * find_entry
GtkListStore* find_store
GtkWidget* findbox
GtkWidget * fnext_button
GtkWidget * focused_editor
GtkWidget * fprev_button
GtkWidget * in_files_opt
GtkWidget * lua_opt
GtkWidget * match_case_opt
GtkWidget * menubar
GtkWidget * pm_container
GtkWidget * pm_entry
GtkTreeStore* pm_store
GtkWidget* pm_view
GtkWidget * r_button
GtkWidget * ra_button
GtkListStore * repl_store
GtkWidget * replace_entry
GtkWidget * statusbar
GtkWidget * whole_word_opt
GtkWidget* window

Generated by  doxygen 1.6.2