From: Francesco M. <f18...@ya...> - 2006-02-25 14:36:34
|
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; } |
From: John L. <jla...@gm...> - 2006-02-25 16:28:27
|
On 2/25/06, Francesco Montorsi <f18...@ya...> wrote: > 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 ? Yes. > 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 ? You have to add files to the wxSTEditorNotebook not to the editor, add the first file to the editor and remaining ones to the notebook. See the wxstedit sample. http://cvs.sourceforge.net/viewcvs.py/wxcode/wxCode/components/wxstedit/sam= ples/stedit/wxstedit.cpp?view=3Dmarkup see the code below this comment // If there are any good files left, try to load them -John > > Index: apps/wxluaedit/src/wxluaedit.cpp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > 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[] =3D > +{ > + // 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() !=3D 0) > + return 0; // help was shown / an error occurred > + > wxLuaEditorFrame *frame =3D 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=3D0; 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 langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Wxlua-users mailing list > Wxl...@li... > https://lists.sourceforge.net/lists/listinfo/wxlua-users > |
From: Francesco M. <f18...@ya...> - 2006-02-25 21:04:55
|
Hi, John Labenski ha scritto: > On 2/25/06, Francesco Montorsi <f18...@ya...> wrote: >> 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 ? > > Yes. > >> 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 ? > > You have to add files to the wxSTEditorNotebook not to the editor, add > the first file to the editor and remaining ones to the notebook. See > the wxstedit sample. > http://cvs.sourceforge.net/viewcvs.py/wxcode/wxCode/components/wxstedit/samples/stedit/wxstedit.cpp?view=markup > > see the code below this comment > // If there are any good files left, try to load them > > -John That was very useful ! I've copied also some other code to make it warn the user about eventually-unloadable files and committed it. However there is still another problem I see: unlike wxlua, wxluaedit always opens the user-chosen files on the same notebook page. I searched the code which does this but I couldn't found it by sure. Is it the fileLoad() function in the editor.wx.lua file ? In any case I think it would be nice to have the File->Open menuitem of wxLuaEdit to open files in new notebook pages. Francesco |
From: John L. <jla...@gm...> - 2006-02-26 01:40:36
|
On 2/25/06, Francesco Montorsi <f18...@ya...> wrote: > However there is still another problem I see: unlike wxlua, wxluaedit > always opens the user-chosen files on the same notebook page. Fixed, you need to checkout wxStEdit again. > I searched the code which does this but I couldn't found it by sure. Is > it the fileLoad() function in the editor.wx.lua file ? > In any case I think it would be nice to have the File->Open menuitem of > wxLuaEdit to open files in new notebook pages. editor.wx.lua is the editor for apps/wxlua. The apps/wxluaedit is strictly C++ and uses the wxstedit as the editor with no lua code at all. I've also changed this to add a new page for both as well. -John |
From: Francesco M. <f18...@ya...> - 2006-02-27 19:50:57
|
Hi, John Labenski ha scritto: > On 2/25/06, Francesco Montorsi <f18...@ya...> wrote: >> However there is still another problem I see: unlike wxlua, wxluaedit >> always opens the user-chosen files on the same notebook page. > > Fixed, you need to checkout wxStEdit again. thanks, now it works nicely ! > >> I searched the code which does this but I couldn't found it by sure. Is >> it the fileLoad() function in the editor.wx.lua file ? >> In any case I think it would be nice to have the File->Open menuitem of >> wxLuaEdit to open files in new notebook pages. > > editor.wx.lua is the editor for apps/wxlua. The apps/wxluaedit is > strictly C++ and uses the wxstedit as the editor with no lua code at > all. ok, I missed that Francesco |