aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua_interface.c3
-rw-r--r--src/textadept.c51
-rw-r--r--src/textadept.h18
3 files changed, 48 insertions, 24 deletions
diff --git a/src/lua_interface.c b/src/lua_interface.c
index dc5bfa0b..4ae435f0 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -114,6 +114,9 @@ bool l_init(int argc, char **argv, bool reinit) {
#ifdef WIN32
lua_pushboolean(lua, 1); lua_setglobal(lua, "WIN32");
#endif
+#ifdef MAC
+ lua_pushboolean(lua, 1); lua_setglobal(lua, "MAC");
+#endif
return l_load_script("core/init.lua");
}
diff --git a/src/textadept.c b/src/textadept.c
index eba730a1..a3c85189 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -50,21 +50,40 @@ GtkWidget *findbox, *find_entry, *replace_entry;
GtkWidget *fnext_button, *fprev_button, *r_button, *ra_button;
GtkWidget *match_case_opt, *whole_word_opt, /**incremental_opt,*/ *lua_opt;
GtkAttachOptions
- normal = static_cast<GtkAttachOptions>(GTK_SHRINK | GTK_FILL),
- expand = static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL);
+ ao_normal = static_cast<GtkAttachOptions>(GTK_SHRINK | GTK_FILL),
+ ao_expand = static_cast<GtkAttachOptions>(GTK_EXPAND | GTK_FILL);
static gbool fe_keypress(GtkWidget*, GdkEventKey *event, gpointer);
static gbool re_keypress(GtkWidget*, GdkEventKey *event, gpointer);
static void button_clicked(GtkWidget *button, gpointer);
+#if WIN32 || MAC
+char *textadept_home;
+#endif
+
/**
- * Runs Textadept.
+ * Runs Textadept in Linux or Mac.
* Inits the Lua State, creates the user interface, and loads the core/init.lua
* script.
* @param argc The number of command line params.
* @param argv The array of command line params.
*/
int main(int argc, char **argv) {
+#ifdef MAC
+ CFBundleRef bundle = CFBundleGetMainBundle();
+ if (bundle) {
+ char path[260];
+ CFURLRef bundle_url = CFBundleCopyBundleURL(bundle);
+ CFStringRef bundle_path =
+ CFURLCopyFileSystemPath(bundle_url, kCFURLPOSIXPathStyle);
+ CFStringGetCString(bundle_path, path, 260, kCFStringEncodingASCII);
+ char *resources_path = g_strconcat(path, "/Contents/Resources/", NULL);
+ textadept_home = static_cast<char*>(resources_path);
+ g_free(path);
+ CFRelease(bundle_url);
+ CFRelease(bundle_path);
+ } else textadept_home = "";
+#endif
gtk_init(&argc, &argv);
if (l_init(argc, argv, false)) {
create_ui();
@@ -76,8 +95,6 @@ int main(int argc, char **argv) {
}
#ifdef WIN32
-char *textadept_home;
-
/**
* Runs Textadept in Windows.
* Sets textadept_home according to the directory the executable is in before
@@ -824,18 +841,18 @@ GtkWidget *find_create_ui() {
gtk_label_set_mnemonic_widget(GTK_LABEL(rlabel), replace_entry);
//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);
- attach(flabel, 0, 1, 0, 1, normal, normal, 5, 0);
- attach(rlabel, 0, 1, 1, 2, normal, normal, 5, 0);
- attach(fnext_button, 2, 3, 0, 1, normal, normal, 0, 0);
- attach(fprev_button, 3, 4, 0, 1, normal, normal, 0, 0);
- attach(r_button, 2, 3, 1, 2, normal, normal, 0, 0);
- attach(ra_button, 3, 4, 1, 2, normal, normal, 0, 0);
- attach(match_case_opt, 4, 5, 0, 1, normal, normal, 5, 0);
- attach(whole_word_opt, 4, 5, 1, 2, normal, normal, 5, 0);
- //attach(incremental_opt, 5, 6, 0, 1, normal, normal, 5, 0);
- attach(lua_opt, 5, 6, 0, 1, normal, normal, 5, 0);
+ attach(find_entry, 1, 2, 0, 1, ao_expand, ao_normal, 5, 0);
+ attach(replace_entry, 1, 2, 1, 2, ao_expand, ao_normal, 5, 0);
+ attach(flabel, 0, 1, 0, 1, ao_normal, ao_normal, 5, 0);
+ attach(rlabel, 0, 1, 1, 2, ao_normal, ao_normal, 5, 0);
+ attach(fnext_button, 2, 3, 0, 1, ao_normal, ao_normal, 0, 0);
+ attach(fprev_button, 3, 4, 0, 1, ao_normal, ao_normal, 0, 0);
+ attach(r_button, 2, 3, 1, 2, ao_normal, ao_normal, 0, 0);
+ attach(ra_button, 3, 4, 1, 2, ao_normal, ao_normal, 0, 0);
+ attach(match_case_opt, 4, 5, 0, 1, ao_normal, ao_normal, 5, 0);
+ attach(whole_word_opt, 4, 5, 1, 2, ao_normal, ao_normal, 5, 0);
+ //attach(incremental_opt, 5, 6, 0, 1, ao_normal, ao_normal, 5, 0);
+ attach(lua_opt, 5, 6, 0, 1, ao_normal, ao_normal, 5, 0);
signal(find_entry, "key_press_event", fe_keypress);
signal(replace_entry, "key_press_event", re_keypress);
diff --git a/src/textadept.h b/src/textadept.h
index 4397b5f2..ad490cf2 100644
--- a/src/textadept.h
+++ b/src/textadept.h
@@ -12,17 +12,21 @@
#include <SciLexer.h>
#include <ScintillaWidget.h>
-#ifdef WIN32
-#include "Windows.h"
-#define strcasecmp _stricmp
-#endif
-
extern "C" {
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}
+#ifdef WIN32
+#include "Windows.h"
+#define strcasecmp _stricmp
+#endif
+
+#ifdef MAC
+#include "CoreFoundation/CoreFoundation.h"
+#endif
+
// globals
extern GtkWidget
*window, *focused_editor, *command_entry,
@@ -31,7 +35,7 @@ extern GtkWidget
extern GtkEntryCompletion *command_entry_completion;
extern GtkTreeStore *cec_store, *pm_store;
extern lua_State *lua;
-#ifndef WIN32
+#if !(WIN32 || MAC)
static const char *textadept_home = "/usr/share/textadept/";
#else
extern char *textadept_home;
@@ -59,7 +63,7 @@ void pm_toggle_focus();
void pm_open_parent(GtkTreeIter *iter, GtkTreePath *path);
void pm_close_parent(GtkTreeIter *iter, GtkTreePath *path);
void pm_activate_selection();
-void pm_popup_context_menu(GdkEventButton *event, GCallback callback);
+void pm_popup_context_menu(GdkEventButton *event);
void pm_process_selected_menu_item(GtkWidget *menu_item);
GtkWidget *find_create_ui();