diff options
-rw-r--r-- | core/file_io.lua | 2 | ||||
-rw-r--r-- | core/init.lua | 6 | ||||
-rw-r--r-- | src/lua_interface.c | 3 | ||||
-rw-r--r-- | src/textadept.c | 17 | ||||
-rw-r--r-- | src/textadept.h | 8 |
5 files changed, 35 insertions, 1 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index 36117ebf..ecfb35e0 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -171,6 +171,7 @@ end -- @return true if the session file was opened and read; false otherwise. -- @usage textadept.io.load_session(filename) function load_session(filename, only_pm) + if WIN32 then return end -- TODO: local textadept = textadept local f = io.open(filename or os.getenv('HOME')..'/.ta_session') local current_view, splits = 1, { [0] = {} } @@ -229,6 +230,7 @@ end -- $HOME/.ta_session if not specified. -- @usage textadept.io.save_session(filename) function save_session(filename) + if WIN32 then return end -- TODO: local session = '' local buffer_line = "buffer: %d %d %d %s\n" -- anchor, cursor, line, filename local split_line = "%ssplit%d: %s %d\n" -- level, number, type, size diff --git a/core/init.lua b/core/init.lua index 3acd3875..82348f1f 100644 --- a/core/init.lua +++ b/core/init.lua @@ -1,7 +1,11 @@ -- Copyright 2007-2008 Mitchell mitchell<att>caladbolg.net. See LICENSE. package.path = _HOME..'/core/?.lua;'..package.path -package.cpath = _HOME..'/core/?.so;'..package.cpath +if not WIN32 then + package.cpath = _HOME..'/core/?.so;'..package.cpath +else + package.cpath = _HOME..'/core/?.dll;'..package.cpath +end require 'iface' require 'events' diff --git a/src/lua_interface.c b/src/lua_interface.c index 08ad97c6..8a1fc675 100644 --- a/src/lua_interface.c +++ b/src/lua_interface.c @@ -111,6 +111,9 @@ void l_init(int argc, char **argv, bool reinit) { lua_getfield(lua, LUA_REGISTRYINDEX, "arg"); lua_setglobal(lua, "arg"); lua_pushstring(lua, textadept_home); lua_setglobal(lua, "_HOME"); +#ifdef WIN32 + lua_pushboolean(lua, 1); lua_setglobal(lua, "WIN32"); +#endif l_load_script("core/init.lua"); } diff --git a/src/textadept.c b/src/textadept.c index 26bce179..6872e872 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -2,6 +2,11 @@ #include "textadept.h" +#ifdef WIN32 +#include "Windows.h" +#define strcasecmp _stricmp +#endif + #define signal(o, s, c) g_signal_connect(G_OBJECT(o), s, G_CALLBACK(c), 0) // Textadept @@ -72,6 +77,18 @@ int main(int argc, char **argv) { return 0; } +#ifdef WIN32 +int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int) { + // TODO: lpCmdLine contains command line string, pass to Lua + gtk_init(0, NULL); + l_init(0, NULL, false); + create_ui(); + l_load_script("init.lua"); + gtk_main(); + return 0; +} +#endif + /** * Creates the user interface. * The UI consists of: diff --git a/src/textadept.h b/src/textadept.h index 8c858142..395a462f 100644 --- a/src/textadept.h +++ b/src/textadept.h @@ -26,13 +26,21 @@ extern GtkWidget extern GtkEntryCompletion *command_entry_completion; extern GtkTreeStore *cec_store, *pm_store; extern lua_State *lua; +#ifndef WIN32 static const char *textadept_home = "/usr/share/textadept/"; +#else +static const char *textadept_home = "C:\\Program Files\\textadept"; +#endif static long SS(ScintillaObject *sci, unsigned int msg, unsigned long wParam=0, long lParam=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); |