aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-09-21 17:08:20 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2008-09-21 17:08:20 -0400
commite05c5b2a88f84bc7eca915806e59cbdbd689af9c (patch)
treecc6ea9ec079ff4d42a2f99e391cbb429978828de /src
parent26551456de4cde7d73fa422437235d3aaa6ca326 (diff)
downloadtextadept-e05c5b2a88f84bc7eca915806e59cbdbd689af9c.tar.gz
textadept-e05c5b2a88f84bc7eca915806e59cbdbd689af9c.zip
Code cleanup.
Diffstat (limited to 'src')
-rw-r--r--src/lua_interface.c33
-rw-r--r--src/textadept.c160
-rw-r--r--src/textadept.h27
3 files changed, 106 insertions, 114 deletions
diff --git a/src/lua_interface.c b/src/lua_interface.c
index 8a1fc675..2e6a26bc 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -124,7 +124,7 @@ void l_init(int argc, char **argv, bool reinit) {
*/
void l_load_script(const char *script_file) {
char *script = g_strconcat(textadept_home, "/", script_file, NULL);
- if (luaL_dofile(lua, script) != 0) l_handle_error(lua);
+ if (luaL_dofile(lua, script) != 0) l_handle_error(lua, NULL);
g_free(script);
}
@@ -170,11 +170,11 @@ void l_reg_set(LS *lua, const char *k) {
* returns it as a GtkWidget.
* @param lua The Lua State.
* @param narg Relative stack index to check for a Scintilla window.
- * @param errstr Error string to use if the stack element is not a Scintilla
- * window.
+ * @param errstr Optional error string to use if the stack element is not a
+ * Scintilla window.
* Defaults to "View argument expected.".
*/
-static GtkWidget* l_checkview(LS *lua, int narg, const char *errstr=NULL) {
+static GtkWidget *l_checkview(LS *lua, int narg, const char *errstr=0) {
if (lua_type(lua, narg) == LUA_TTABLE) {
lua_pushstring(lua, "widget_pointer");
lua_rawget(lua, narg > 0 ? narg : narg - 1);
@@ -270,10 +270,11 @@ void l_set_view_global(GtkWidget *editor) {
* Scintilla document pointer associated with it.
* @param lua The Lua State.
* @param narg Relative stack index to check for a buffer table.
- * @param errstr Error string to use if the stack element is not a buffer table.
+ * @param errstr Optional error string to use if the stack element is not a
+ * buffer table.
* Defaults to "Buffer argument expected.".
*/
-static sptr_t l_checkdocpointer(LS *lua, int narg, const char *errstr=NULL) {
+static sptr_t l_checkdocpointer(LS *lua, int narg, const char *errstr=0) {
if (lua_type(lua, narg) == LUA_TTABLE) {
lua_pushstring(lua, "doc_pointer");
lua_rawget(lua, narg > 0 ? narg : narg - 1);
@@ -507,9 +508,9 @@ bool l_is_ta_table_function(const char *table, const char *function) {
* one element lower on the stack with the Lua function being under the first
* argument.
* @param nargs The number of arguments to pass to the Lua function to call.
- * @param retn The number of expected return values. Defaults to 0.
- * @param keep_return Flag indicating whether or not to keep the return values
- * at the top of the stack. If false, discards the return values.
+ * @param retn Optional number of expected return values. Defaults to 0.
+ * @param keep_return Optoinal flag indicating whether or not to keep the return
+ * values at the top of the stack. If false, discards the return values.
* Defaults to false.
*/
bool l_call_function(int nargs, int retn=0, bool keep_return=false) {
@@ -518,7 +519,7 @@ bool l_call_function(int nargs, int retn=0, bool keep_return=false) {
bool result = retn > 0 ? lua_toboolean(lua, -1) == 1 : true;
if (retn > 0 && !keep_return) lua_pop(lua, retn); // retn
return result;
- } else l_handle_error(lua);
+ } else l_handle_error(lua, NULL);
return false;
}
@@ -541,7 +542,7 @@ static int l_rawgeti_int(LS *lua, int index, int n) {
* @param index The relative index of the table to rawget from.
* @param k String key in the table to rawget.
*/
-static const char* l_rawget_str(LS *lua, int index, const char *k) {
+static const char *l_rawget_str(LS *lua, int index, const char *k) {
lua_pushstring(lua, k); lua_rawget(lua, index);
const char *str = lua_tostring(lua, -1);
lua_pop(lua, 1); // string
@@ -578,7 +579,7 @@ static long l_toscintillaparam(LS *lua, int type, int &arg_idx) {
* @param submenu Flag indicating whether or not this menu is a submenu.
* Defaults to false.
*/
-GtkWidget* l_create_gtkmenu(LS *lua, GCallback callback, bool submenu=false) {
+GtkWidget *l_create_gtkmenu(LS *lua, GCallback callback, bool submenu) {
GtkWidget *menu = gtk_menu_new(), *menu_item = 0, *submenu_root = 0;
const char *label;
lua_getfield(lua, -1, "title");
@@ -611,7 +612,7 @@ GtkWidget* l_create_gtkmenu(LS *lua, GCallback callback, bool submenu=false) {
* Handles a Lua error.
* The main error message is at the top of the Lua stack.
* @param lua The Lua State.
- * @param errmsg An additional error message to display. Defaults to NULL.
+ * @param errmsg An additional error message to display.
*/
void l_handle_error(LS *lua, const char *errmsg) {
if (focused_editor && l_is_ta_table_function("events", "error")) {
@@ -844,7 +845,7 @@ void l_pm_popup_context_menu(GdkEventButton *event, GCallback callback) {
return;
}
if (l_call_function(1, 1, true) && lua_istable(lua, -1)) {
- GtkWidget *menu = l_create_gtkmenu(lua, callback);
+ GtkWidget *menu = l_create_gtkmenu(lua, callback, false);
lua_pop(lua, 1); // returned table
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
@@ -1293,7 +1294,7 @@ LF l_cf_ta_get_split_table(LS *lua) {
return 1;
}
-LF l_cf_ta_goto_(LS *lua, GtkWidget *editor, bool buffer=true) {
+LF l_cf_ta_goto_(LS *lua, GtkWidget *editor, bool buffer) {
int n = static_cast<int>(luaL_checkinteger(lua, 1));
bool absolute = lua_gettop(lua) > 1 ? lua_toboolean(lua, 2) == 1 : true;
buffer ? l_goto_scintilla_buffer(editor, n, absolute)
@@ -1329,7 +1330,7 @@ static void t_menu_activate(GtkWidget *menu_item, gpointer) {
LF l_cf_ta_gtkmenu(LS *lua) {
luaL_checktype(lua, 1, LUA_TTABLE);
- GtkWidget *menu = l_create_gtkmenu(lua, G_CALLBACK(t_menu_activate));
+ GtkWidget *menu = l_create_gtkmenu(lua, G_CALLBACK(t_menu_activate), false);
lua_pushlightuserdata(lua, const_cast<GtkWidget*>(menu));
return 1;
}
diff --git a/src/textadept.c b/src/textadept.c
index 8bdf7e63..4d639ab6 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -7,6 +7,7 @@
#define strcasecmp _stricmp
#endif
+#define gbool gboolean
#define signal(o, s, c) g_signal_connect(G_OBJECT(o), s, G_CALLBACK(c), 0)
// Textadept
@@ -17,17 +18,17 @@ GtkEntryCompletion *command_entry_completion;
GtkTreeStore *cec_store;
static void c_activated(GtkWidget *widget, gpointer);
-static bool c_keypress(GtkWidget *widget, GdkEventKey *event, gpointer);
+static gbool c_keypress(GtkWidget *widget, GdkEventKey *event, gpointer);
static int cec_match_func(GtkEntryCompletion *, const char *, GtkTreeIter *,
gpointer);
-static bool cec_match_selected(GtkEntryCompletion *, GtkTreeModel *model,
- GtkTreeIter *iter, gpointer);
+static gbool cec_match_selected(GtkEntryCompletion *, GtkTreeModel *model,
+ GtkTreeIter *iter, gpointer);
static void t_notification(GtkWidget*, gint, gpointer lParam, gpointer);
static void t_command(GtkWidget *editor, gint wParam, gpointer, gpointer);
-static bool t_keypress(GtkWidget*, GdkEventKey *event, gpointer);
-static bool w_focus(GtkWidget*, GdkEventFocus *, gpointer);
-static bool w_keypress(GtkWidget*, GdkEventKey *event, gpointer);
-static bool w_exit(GtkWidget*, GdkEventAny*, gpointer);
+static gbool t_keypress(GtkWidget*, GdkEventKey *event, gpointer);
+static gbool w_focus(GtkWidget*, GdkEventFocus *, gpointer);
+static gbool w_keypress(GtkWidget*, GdkEventKey *event, gpointer);
+static gbool w_exit(GtkWidget*, GdkEventAny*, gpointer);
// Project Manager
GtkWidget *pm_view, *pm_entry, *pm_container;
@@ -38,15 +39,15 @@ static int pm_search_equal_func(GtkTreeModel *model, int col, const char *key,
static int pm_sort_iter_compare_func(GtkTreeModel *model, GtkTreeIter *a,
GtkTreeIter *b, gpointer);
static void pm_entry_activated(GtkWidget *widget, gpointer);
-static bool pm_keypress(GtkWidget *, GdkEventKey *event, gpointer);
+static gbool pm_keypress(GtkWidget *, GdkEventKey *event, gpointer);
static void pm_row_expanded(GtkTreeView *, GtkTreeIter *iter,
GtkTreePath *path, gpointer);
static void pm_row_collapsed(GtkTreeView *, GtkTreeIter *iter,
GtkTreePath *path, gpointer);
static void pm_row_activated(GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *,
gpointer);
-static bool pm_button_press(GtkTreeView *, GdkEventButton *event, gpointer);
-static bool pm_popup_menu(GtkWidget *, gpointer);
+static gbool pm_button_press(GtkTreeView *, GdkEventButton *event, gpointer);
+static gbool pm_popup_menu(GtkWidget *, gpointer);
static void pm_menu_activate(GtkWidget *menu_item, gpointer);
// Find/Replace
@@ -57,8 +58,8 @@ GtkAttachOptions
normal = static_cast<GtkAttachOptions>(GTK_SHRINK | GTK_FILL),
expand = static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL);
-static bool fe_keypress(GtkWidget*, GdkEventKey *event, gpointer);
-static bool re_keypress(GtkWidget*, GdkEventKey *event, gpointer);
+static gbool fe_keypress(GtkWidget*, GdkEventKey *event, gpointer);
+static gbool re_keypress(GtkWidget*, GdkEventKey *event, gpointer);
static void button_clicked(GtkWidget *button, gpointer);
/**
@@ -82,22 +83,17 @@ char *textadept_home;
/**
* Runs Textadept in Windows.
- * Sets textadept_home according to the directory the executable is in, inits
- * the Lua state, creates the user interface, and loads the core/init.lua
- * script.
+ * Sets textadept_home according to the directory the executable is in before
+ * calling main.
+ * @see main
*/
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int) {
char path[260];
GetModuleFileName(0, path, sizeof(path));
char *last_slash = strrchr(path, '\\');
if (last_slash) *last_slash = '\0';
- textadept_home = static_cast<char *>(path);
- gtk_init(0, NULL);
- l_init(0, NULL, false);
- create_ui();
- l_load_script("init.lua");
- gtk_main();
- return 0;
+ textadept_home = static_cast<char*>(path);
+ return main(0, NULL);
}
#endif
@@ -137,47 +133,47 @@ void create_ui() {
signal(window, "focus-in-event", w_focus);
signal(window, "key_press_event", w_keypress);
- GtkWidget *vbox = gtk_vbox_new(false, 0);
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), vbox);
menubar = gtk_menu_bar_new();
- gtk_box_pack_start(GTK_BOX(vbox), menubar, false, false, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
GtkWidget *pane = gtk_hpaned_new();
- gtk_box_pack_start(GTK_BOX(vbox), pane, true, true, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), pane, TRUE, TRUE, 0);
GtkWidget *pm = pm_create_ui();
gtk_paned_add1(GTK_PANED(pane), pm);
- GtkWidget *hbox = gtk_hbox_new(false, 0);
+ GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
gtk_paned_add2(GTK_PANED(pane), hbox);
- GtkWidget *editor = new_scintilla_window();
- gtk_box_pack_start(GTK_BOX(hbox), editor, true, true, 0);
+ GtkWidget *editor = new_scintilla_window(NULL);
+ gtk_box_pack_start(GTK_BOX(hbox), editor, TRUE, TRUE, 0);
GtkWidget *find = find_create_ui();
- gtk_box_pack_start(GTK_BOX(vbox), find, false, false, 5);
+ gtk_box_pack_start(GTK_BOX(vbox), find, FALSE, FALSE, 5);
- GtkWidget *hboxs = gtk_hbox_new(false, 0);
- gtk_box_pack_start(GTK_BOX(vbox), hboxs, false, false, 0);
+ GtkWidget *hboxs = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hboxs, FALSE, FALSE, 0);
statusbar = gtk_statusbar_new();
gtk_statusbar_push(GTK_STATUSBAR(statusbar), 0, "");
- gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(statusbar), false);
- gtk_box_pack_start(GTK_BOX(hboxs), statusbar, true, true, 0);
+ gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(statusbar), FALSE);
+ gtk_box_pack_start(GTK_BOX(hboxs), statusbar, TRUE, TRUE, 0);
command_entry = gtk_entry_new();
gtk_widget_set_name(command_entry, "textadept-command-entry");
signal(command_entry, "activate", c_activated);
signal(command_entry, "key_press_event", c_keypress);
g_object_set(G_OBJECT(command_entry), "width-request", 200, NULL);
- gtk_box_pack_start(GTK_BOX(hboxs), command_entry, true, true, 0);
+ gtk_box_pack_start(GTK_BOX(hboxs), command_entry, TRUE, TRUE, 0);
command_entry_completion = gtk_entry_completion_new();
signal(command_entry_completion, "match-selected", cec_match_selected);
gtk_entry_completion_set_match_func(command_entry_completion, cec_match_func,
NULL, NULL);
- gtk_entry_completion_set_popup_set_width(command_entry_completion, false);
+ gtk_entry_completion_set_popup_set_width(command_entry_completion, FALSE);
gtk_entry_completion_set_text_column(command_entry_completion, 0);
cec_store = gtk_tree_store_new(1, G_TYPE_STRING);
gtk_entry_completion_set_model(command_entry_completion,
@@ -187,7 +183,7 @@ void create_ui() {
docstatusbar = gtk_statusbar_new();
gtk_statusbar_push(GTK_STATUSBAR(docstatusbar), 0, "");
g_object_set(G_OBJECT(docstatusbar), "width-request", 400, NULL);
- gtk_box_pack_start(GTK_BOX(hboxs), docstatusbar, false, false, 0);
+ gtk_box_pack_start(GTK_BOX(hboxs), docstatusbar, FALSE, FALSE, 0);
gtk_widget_show_all(window);
gtk_widget_hide(menubar); // hide initially
@@ -208,7 +204,7 @@ void create_ui() {
* @see set_default_editor_properties
* @see l_add_scintilla_window
*/
-GtkWidget* new_scintilla_window(sptr_t buffer_id) {
+GtkWidget *new_scintilla_window(sptr_t buffer_id) {
GtkWidget *editor = scintilla_new();
gtk_widget_set_size_request(editor, 1, 1); // minimum size
signal(editor, "key_press_event", t_keypress);
@@ -260,7 +256,7 @@ void new_scintilla_buffer(ScintillaObject *sci, bool create, bool addref) {
doc = SS(sci, SCI_GETDOCPOINTER);
if (create) { // create the new document
doc = SS(sci, SCI_CREATEDOCUMENT);
- l_goto_scintilla_buffer(focused_editor, l_add_scintilla_buffer(doc));
+ l_goto_scintilla_buffer(focused_editor, l_add_scintilla_buffer(doc), true);
} else if (addref) {
l_add_scintilla_buffer(doc);
SS(sci, SCI_ADDREFDOCUMENT, 0, doc);
@@ -385,7 +381,7 @@ void set_menubar(GtkWidget *new_menubar) {
GtkWidget *vbox = gtk_widget_get_parent(menubar);
gtk_container_remove(GTK_CONTAINER(vbox), menubar);
menubar = new_menubar;
- gtk_box_pack_start(GTK_BOX(vbox), menubar, false, false, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
gtk_box_reorder_child(GTK_BOX(vbox), menubar, 0);
gtk_widget_show_all(menubar);
}
@@ -444,20 +440,20 @@ static void c_activated(GtkWidget *widget, gpointer) {
* - Escape - Hide the completion buffer if it is open.
* - Tab - Display possible completions.
*/
-static bool c_keypress(GtkWidget *widget, GdkEventKey *event, gpointer) {
+static gbool c_keypress(GtkWidget *widget, GdkEventKey *event, gpointer) {
if (event->state == 0)
switch(event->keyval) {
case 0xff1b:
ce_toggle_focus();
- return true;
+ return TRUE;
case 0xff09:
if (l_cec_get_completions_for(gtk_entry_get_text(GTK_ENTRY(widget)))) {
l_cec_populate();
gtk_entry_completion_complete(command_entry_completion);
}
- return true;
+ return TRUE;
}
- return false;
+ return FALSE;
}
/**
@@ -468,7 +464,7 @@ static bool c_keypress(GtkWidget *widget, GdkEventKey *event, gpointer) {
*/
static int cec_match_func(GtkEntryCompletion*, const char*, GtkTreeIter*,
gpointer) {
- return true;
+ return 1;
}
/**
@@ -476,14 +472,14 @@ static int cec_match_func(GtkEntryCompletion*, const char*, GtkTreeIter*,
* The last word at the cursor is replaced with the completion. A word consists
* of any alphanumeric character or underscore.
*/
-static bool cec_match_selected(GtkEntryCompletion*, GtkTreeModel *model,
+static gbool cec_match_selected(GtkEntryCompletion*, GtkTreeModel *model,
GtkTreeIter *iter, gpointer) {
const char *entry_text = gtk_entry_get_text(GTK_ENTRY(command_entry));
const char *p = entry_text + strlen(entry_text) - 1;
while ((*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z') ||
(*p >= '0' && *p <= '9') || *p == '_') {
g_signal_emit_by_name(G_OBJECT(command_entry), "move-cursor",
- GTK_MOVEMENT_VISUAL_POSITIONS, -1, true, 0);
+ GTK_MOVEMENT_VISUAL_POSITIONS, -1, TRUE, 0);
p--;
}
if (p < entry_text + strlen(entry_text) - 1)
@@ -495,7 +491,7 @@ static bool cec_match_selected(GtkEntryCompletion*, GtkTreeModel *model,
g_free(text);
gtk_tree_store_clear(cec_store);
- return true;
+ return TRUE;
}
/**
@@ -523,20 +519,20 @@ static void t_command(GtkWidget *editor, gint wParam, gpointer, gpointer) {
* Collects the modifier states as flags and calls Lua to handle the keypress.
* @see l_handle_keypress
*/
-static bool t_keypress(GtkWidget*, GdkEventKey *event, gpointer) {
+static gbool t_keypress(GtkWidget*, GdkEventKey *event, gpointer) {
bool shift = event->state & GDK_SHIFT_MASK;
bool control = event->state & GDK_CONTROL_MASK;
bool alt = event->state & GDK_MOD1_MASK;
- return l_handle_keypress(event->keyval, shift, control, alt);
+ return l_handle_keypress(event->keyval, shift, control, alt) ? TRUE : FALSE;
}
/**
* Signal for a Textadept window focus change.
*/
-static bool w_focus(GtkWidget*, GdkEventFocus*, gpointer) {
+static gbool w_focus(GtkWidget*, GdkEventFocus*, gpointer) {
if (focused_editor && !GTK_WIDGET_HAS_FOCUS(focused_editor))
gtk_widget_grab_focus(focused_editor);
- return false;
+ return FALSE;
}
/**
@@ -544,12 +540,12 @@ static bool w_focus(GtkWidget*, GdkEventFocus*, gpointer) {
* Currently handled keypresses:
* - Escape - hides the search frame if it's open.
*/
-static bool w_keypress(GtkWidget*, GdkEventKey *event, gpointer) {
+static gbool w_keypress(GtkWidget*, GdkEventKey *event, gpointer) {
if (event->keyval == 0xff1b && GTK_WIDGET_VISIBLE(findbox)) {
gtk_widget_hide(findbox);
gtk_widget_grab_focus(focused_editor);
- return true;
- } else return false;
+ return TRUE;
+ } else return FALSE;
}
/**
@@ -558,12 +554,12 @@ static bool w_keypress(GtkWidget*, GdkEventKey *event, gpointer) {
* Generates a 'quit' event.
* @see l_close
*/
-static bool w_exit(GtkWidget*, GdkEventAny*, gpointer) {
- if (!l_handle_event("quit")) return true;
+static gbool w_exit(GtkWidget*, GdkEventAny*, gpointer) {
+ if (!l_handle_event("quit")) return TRUE;
l_close();
scintilla_release_resources();
gtk_main_quit();
- return false;
+ return FALSE;
}
// Project Manager
@@ -574,12 +570,12 @@ static bool w_exit(GtkWidget*, GdkEventAny*, gpointer) {
* 'textadept-pm-view' respectively for styling via gtkrc. The treeview model
* consists of a gdk-pixbuf for icons and markup text.
*/
-GtkWidget* pm_create_ui() {
- pm_container = gtk_vbox_new(false, 1);
+GtkWidget *pm_create_ui() {
+ pm_container = gtk_vbox_new(FALSE, 1);
pm_entry = gtk_entry_new();
gtk_widget_set_name(pm_entry, "textadept-pm-entry");
- gtk_box_pack_start(GTK_BOX(pm_container), pm_entry, false, false, 0);
+ gtk_box_pack_start(GTK_BOX(pm_container), pm_entry, FALSE, FALSE, 0);
pm_store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
GtkTreeSortable *sortable = GTK_TREE_SORTABLE(pm_store);
@@ -590,8 +586,8 @@ GtkWidget* pm_create_ui() {
pm_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pm_store));
g_object_unref(pm_store);
gtk_widget_set_name(pm_view, "textadept-pm-view");
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pm_view), false);
- gtk_tree_view_set_enable_search(GTK_TREE_VIEW(pm_view), true);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pm_view), FALSE);
+ gtk_tree_view_set_enable_search(GTK_TREE_VIEW(pm_view), TRUE);
gtk_tree_view_set_search_column(GTK_TREE_VIEW(pm_view), 2);
gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(pm_view),
pm_search_equal_func, NULL, NULL);
@@ -610,7 +606,7 @@ GtkWidget* pm_create_ui() {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(scrolled), pm_view);
- gtk_box_pack_start(GTK_BOX(pm_container), scrolled, true, true, 0);
+ gtk_box_pack_start(GTK_BOX(pm_container), scrolled, TRUE, TRUE, 0);
signal(pm_entry, "activate", pm_entry_activated);
signal(pm_entry, "key_press_event", pm_keypress);
@@ -674,7 +670,7 @@ void pm_activate_selection() {
if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(pm_view), path))
gtk_tree_view_collapse_row(GTK_TREE_VIEW(pm_view), path);
else
- gtk_tree_view_expand_row(GTK_TREE_VIEW(pm_view), path, false);
+ gtk_tree_view_expand_row(GTK_TREE_VIEW(pm_view), path, FALSE);
else {
l_pm_get_full_path(path);
l_pm_perform_action();
@@ -756,7 +752,7 @@ static int pm_sort_iter_compare_func(GtkTreeModel *model, GtkTreeIter *a,
*/
static void pm_entry_activated(GtkWidget *widget, gpointer) {
const char *entry_text = gtk_entry_get_text(GTK_ENTRY(widget));
- if (l_pm_get_contents_for(entry_text)) l_pm_populate();
+ if (l_pm_get_contents_for(entry_text, false)) l_pm_populate(NULL);
}
/**
@@ -765,12 +761,12 @@ static void pm_entry_activated(GtkWidget *widget, gpointer) {
* - Ctrl+Tab - Refocuses the Scintilla view.
* - Escape - Refocuses the Scintilla view.
*/
-static bool pm_keypress(GtkWidget *, GdkEventKey *event, gpointer) {
+static gbool pm_keypress(GtkWidget *, GdkEventKey *event, gpointer) {
if ((event->keyval == 0xff09 && event->state == GDK_CONTROL_MASK) ||
event->keyval == 0xff1b) {
gtk_widget_grab_focus(focused_editor);
- return true;
- } else return false;
+ return TRUE;
+ } else return FALSE;
}
/**
@@ -805,9 +801,9 @@ static void pm_row_activated(GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *,
* If it is a right-click, popup a context menu for the selected node.
* @see pm_popup_context_menu
*/
-static bool pm_button_press(GtkTreeView *, GdkEventButton *event, gpointer) {
- if (event->type != GDK_BUTTON_PRESS || event->button != 3) return false;
- pm_popup_context_menu(event); return true;
+static gbool pm_button_press(GtkTreeView *, GdkEventButton *event, gpointer) {
+ if (event->type != GDK_BUTTON_PRESS || event->button != 3) return FALSE;
+ pm_popup_context_menu(event); return TRUE;
}
/**
@@ -815,8 +811,8 @@ static bool pm_button_press(GtkTreeView *, GdkEventButton *event, gpointer) {
* Typically Shift+F10 activates this event.
* @see pm_popup_context_menu
*/
-static bool pm_popup_menu(GtkWidget *, gpointer) {
- pm_popup_context_menu(NULL); return true;
+static gbool pm_popup_menu(GtkWidget *, gpointer) {
+ pm_popup_context_menu(NULL); return TRUE;
}
/**
@@ -838,8 +834,8 @@ static void pm_menu_activate(GtkWidget *menu_item, gpointer) {
/**
* Creates the Find/Replace text frame.
*/
-GtkWidget* find_create_ui() {
- findbox = gtk_table_new(2, 6, false);
+GtkWidget *find_create_ui() {
+ findbox = gtk_table_new(2, 6, FALSE);
GtkWidget *flabel = gtk_label_new_with_mnemonic("_Find:");
GtkWidget *rlabel = gtk_label_new_with_mnemonic("R_eplace:");
@@ -858,7 +854,7 @@ GtkWidget* find_create_ui() {
gtk_label_set_mnemonic_widget(GTK_LABEL(flabel), find_entry);
gtk_label_set_mnemonic_widget(GTK_LABEL(rlabel), replace_entry);
- //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lua_opt), true);
+ //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lua_opt), TRUE);
attach(find_entry, 1, 2, 0, 1, expand, normal, 5, 0);
attach(replace_entry, 1, 2, 1, 2, expand, normal, 5, 0);
@@ -923,12 +919,12 @@ static int get_flags() {
* Currently handled keypresses:
* - Enter - Find next or previous.
*/
-static bool fe_keypress(GtkWidget *, GdkEventKey *event, gpointer) {
+static gbool fe_keypress(GtkWidget *, GdkEventKey *event, gpointer) {
// TODO: if incremental, call l_find()
if (event->keyval == 0xff0d) {
l_find(find_text, get_flags(), true);
- return true;
- } else return false;
+ return TRUE;
+ } else return FALSE;
}
/**
@@ -936,11 +932,11 @@ static bool fe_keypress(GtkWidget *, GdkEventKey *event, gpointer) {
* Currently handled keypresses:
* - Enter - Find next or previous.
*/
-static bool re_keypress(GtkWidget *, GdkEventKey *event, gpointer) {
+static gbool re_keypress(GtkWidget *, GdkEventKey *event, gpointer) {
if (event->keyval == 0xff0d) {
l_find(find_text, get_flags(), true);
- return true;
- } else return false;
+ return TRUE;
+ } else return FALSE;
}
/**
diff --git a/src/textadept.h b/src/textadept.h
index 24c17816..504dae05 100644
--- a/src/textadept.h
+++ b/src/textadept.h
@@ -37,26 +37,21 @@ static long SS(ScintillaObject *sci, unsigned int msg, unsigned long wParam=0,
return scintilla_send_message(sci, msg, wParam, lParam);
}
-#ifdef WIN32
-#define bool gboolean
-#endif
-
// textadept.c
void create_ui();
-GtkWidget* new_scintilla_window(sptr_t default_id=NULL);
+GtkWidget *new_scintilla_window(sptr_t default_id);
void remove_scintilla_window(GtkWidget *editor);
-void new_scintilla_buffer(ScintillaObject *sci, bool create=true,
- bool addref=true);
+void new_scintilla_buffer(ScintillaObject *sci, bool create, bool addref);
void remove_scintilla_buffer(sptr_t doc);
-void split_window(GtkWidget *editor, bool vertical=true);
+void split_window(GtkWidget *editor, bool vertical);
bool unsplit_window(GtkWidget *editor);
-void resize_split(GtkWidget *editor, int pos, bool increment=true);
+void resize_split(GtkWidget *editor, int pos, bool increment);
void set_menubar(GtkWidget *menubar);
void set_statusbar_text(const char *text);
void set_docstatusbar_text(const char *text);
void ce_toggle_focus();
-GtkWidget* pm_create_ui();
+GtkWidget *pm_create_ui();
void pm_toggle_focus();
void pm_open_parent(GtkTreeIter *iter, GtkTreePath *path);
void pm_close_parent(GtkTreeIter *iter, GtkTreePath *path);
@@ -73,14 +68,14 @@ void l_close();
void l_load_script(const char *script_file);
void l_add_scintilla_window(GtkWidget *editor);
void l_remove_scintilla_window(GtkWidget *editor);
-void l_goto_scintilla_window(GtkWidget *editor, int n, bool absolute=true);
+void l_goto_scintilla_window(GtkWidget *editor, int n, bool absolute);
void l_set_view_global(GtkWidget *editor);
int l_add_scintilla_buffer(sptr_t doc);
void l_remove_scintilla_buffer(sptr_t doc);
-void l_goto_scintilla_buffer(GtkWidget *editor, int n, bool absolute=true);
+void l_goto_scintilla_buffer(GtkWidget *editor, int n, bool absolute);
void l_set_buffer_global(ScintillaObject *sci);
-void l_handle_error(lua_State *lua, const char *errmsg=0);
+void l_handle_error(lua_State *lua, const char *errmsg);
bool l_handle_event(const char *e);
bool l_handle_event(const char *e, const char *arg);
bool l_handle_keypress(int keyval, bool shift, bool control, bool alt);
@@ -90,14 +85,14 @@ void l_ta_command(const char *command);
bool l_cec_get_completions_for(const char *entry_text);
void l_cec_populate();
-bool l_pm_get_contents_for(const char *entry_text, bool expanding=false);
-void l_pm_populate(GtkTreeIter *initial_iter=NULL);
+bool l_pm_get_contents_for(const char *entry_text, bool expanding);
+void l_pm_populate(GtkTreeIter *initial_iter);
void l_pm_get_full_path(GtkTreePath *path);
void l_pm_perform_action();
void l_pm_popup_context_menu(GdkEventButton *event, GCallback callback);
void l_pm_perform_menu_action(const char *menu_item);
-void l_find(const char *ftext, int flags, bool next=true);
+void l_find(const char *ftext, int flags, bool next);
void l_find_replace(const char *rtext);
void l_find_replace_all(const char *ftext, const char *rtext, int flags);