Hi John,
I've created a little patch for wxLuaEdit to make it possible to call it from command line with .lua files to open directly in the editor.

This patch will make life a lot easier for win32 and also unix users IMO.

Can I apply it ?

Francesco

PS: the patch works ok when you specify zero or one file in the command line. When you specify two or more, wxLuaEditor opens only the last. This is not a bug with my patch but seems something scintilla-related: I get the same behaviour using the File->Open cmd. I.e. the new files I load do not go as additional items in the "Files" splitterwnd but rather replace the already-open file.
Is it because of wxCVS ?
I'm going to do a cvs update and recompile...




Index: apps/wxluaedit/src/wxluaedit.cpp
===================================================================
RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxluaedit.cpp,v
retrieving revision 1.5
diff -b -u -2 -r1.5 wxluaedit.cpp
--- apps/wxluaedit/src/wxluaedit.cpp    21 Feb 2006 04:20:28 -0000      1.5
+++ apps/wxluaedit/src/wxluaedit.cpp    25 Feb 2006 14:32:54 -0000
@@ -21,4 +21,5 @@
 #endif

+#include <wx/cmdline.h>
 #include "wx/image.h"
 #include "wx/stedit/stedit.h"
@@ -31,4 +32,24 @@
 extern bool wxLuaBinding_wxstc_init();

+
+// ----------------------------------------------------------------------------
+// command line options
+// ----------------------------------------------------------------------------
+
+static const wxCmdLineEntryDesc g_cmdLineDesc[] =
+{
+    // help
+    { wxCMD_LINE_SWITCH, wxT("h"), wxT("help"),
+        _("Show this help message"),
+        wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
+
+    // filenames to open in the editor
+    { wxCMD_LINE_PARAM, wxEmptyString, wxEmptyString,
+        _("lua files to open in the editor"),
+ wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
+
+    { wxCMD_LINE_NONE }
+};
+
// ----------------------------------------------------------------------------
 // resources and constants
@@ -90,4 +111,9 @@
     wxLuaBinding_wxstc_init();

+    // parse command line
+    wxCmdLineParser parser(g_cmdLineDesc, argc, argv);
+    if (parser.Parse() != 0)
+        return 0;           // help was shown / an error occurred
+
     wxLuaEditorFrame *frame = new wxLuaEditorFrame(_T("wxLuaEditor"),
wxPoint(20, 20), wxSize(600, 400));
@@ -115,6 +141,10 @@
     splitWin->SetSashPosition(splitWin->GetSize().y/2);

-    frame->Show(true);

+ // before showing the frame, load the file specified from commandline, if present
+    for (size_t i=0; i < parser.GetParamCount(); i++)
+        frame->GetEditor()->LoadFile(parser.GetParam(i));
+
+    frame->Show(true);
     return true;
 }



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wxlua-users mailing list
Wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to