From: John L. <jr...@us...> - 2006-12-15 19:04:51
|
Update of /cvsroot/wxlua/wxLua/apps/wxluaedit/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv26807/wxLua/apps/wxluaedit/src Modified Files: wxledit.cpp wxledit.h wxluaedit.cpp Log Message: make the wxLuaEditor a little nicer, more checks and add help info Index: wxledit.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxledit.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** wxledit.h 15 Dec 2006 05:16:01 -0000 1.16 --- wxledit.h 15 Dec 2006 19:04:48 -0000 1.17 *************** *** 106,121 **** wxLuaState GetwxLuaState() const { return m_wxlState; } // Set this shell to use another interpreter, will close it if !is_static - // note shell has built in function virtual void SetwxLuaState(const wxLuaState& wxlState, bool is_static); ! // Used to create/recreate local interpreter ! // Can be subclassed to use your own interpreter derived from a wxLuaState ! // or a new interpreter can be set in by catching the wxEVT_LUASHELL_wxLUA_CREATION ! // wxLuaEvent that's sent with this control's id and *this as the GetEventObject ! // the preferred window ID is in event.GetExtraLong() ! // if you call event.SetwxLuaState(wxLuaState(...)) ! // and event.SetInt(1 for static interpreter or 0 for not static) ! // then SetLuaIntpreter(event.GetLuaInterpreter(), event.GetInt() == 1) ! // is called. You'll probably want to set the lua interpreter's eventhandler ! // to this as well as it's win id virtual bool RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id); --- 106,130 ---- wxLuaState GetwxLuaState() const { return m_wxlState; } // Set this shell to use another interpreter, will close it if !is_static virtual void SetwxLuaState(const wxLuaState& wxlState, bool is_static); ! // RecreatewxLuaState - Used to create/recreate local interpreter ! // Can be subclassed to use your own interpreter derived from a wxLuaState. ! // ! // Using a customized wxLuaState by handling wxEVT_LUASHELL_wxLUA_CREATION event: ! // The RecreatewxLuaState function sends a wxLuaEvent with this control's id ! // in GetId(), *this as the GetEventObject(), and the preferred window ID ! // for the new wxLuaState in event.GetExtraLong() (typically wxID_ANY) and ! // the current wxLuaState in GetwxLuaState(). ! // ! // Your wxEVT_LUASHELL_wxLUA_CREATION event handler can set the new wxLuaState ! // by calling event.SetwxLuaState(wxLuaState(...)) ! // and event.SetInt(1 for static interpreter or 0 for not static), where ! // static means that the wxLuaShell will not close the wxLuaState on exit. ! // You'll probably want to set the new wxLuaState's eventhandler ! // to this as well as it's win id. ! // ! // If the event is skipped or not handled the RecreatewxLuaState will call ! // SetLuaIntpreter(event.GetLuaInterpreter(), event.GetInt() == 1) ! // if the event's wxLuaState is valid. You can not skip the event to not have ! // the wxLuaState recreated at all. virtual bool RecreatewxLuaState(wxEvtHandler *wxlStateEvtHandler, int win_id); Index: wxluaedit.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxluaedit.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** wxluaedit.cpp 15 Dec 2006 05:16:01 -0000 1.28 --- wxluaedit.cpp 15 Dec 2006 19:04:48 -0000 1.29 *************** *** 457,460 **** --- 457,468 ---- m_sideSplitter->SplitVertically(m_sideNotebook, m_wxluaIDE, 150); + wxLuaShell *shell = m_wxluaIDE->GetLuaShellWin(); + shell->AppendText(wxT("Welcome to the wxLuaShell, an interactive lua interpreter.\n")); + shell->AppendText(wxT(" Enter lua code and press <enter> to run it.\n")); + shell->AppendText(wxT(" Multiline code can be typed by pressing <shift>-<enter>.\n")); + shell->AppendText(wxT(" The wxLua intrepreter can be restarted with the command 'reset'.\n")); + shell->MarkerDeleteAll(wxSTEditorShell::markerPrompt); + shell->CheckPrompt(true); + return true; } *************** *** 505,509 **** wxString script; ! script += wxT("local msg = \"Welcome to wxLuaEditor\\n\""); script += wxT("msg = msg..\"Written by John Labenski\\n\\n\""); script += wxT("msg = msg..string.format(\"%s\", \"This dialog is created from a wxLua script.\")"); --- 513,518 ---- wxString script; ! script += wxT("local msg = \"Welcome to wxLuaEditor using \"..wx.WXLUA_VERSION_STRING..\"\\n\""); ! script += wxT("msg = msg..\"and compiled with \"..wx.wxVERSION_STRING..\"\\n\""); script += wxT("msg = msg..\"Written by John Labenski\\n\\n\""); script += wxT("msg = msg..string.format(\"%s\", \"This dialog is created from a wxLua script.\")"); Index: wxledit.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxledit.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** wxledit.cpp 15 Dec 2006 05:16:01 -0000 1.29 --- wxledit.cpp 15 Dec 2006 19:04:47 -0000 1.30 *************** *** 83,91 **** if (m_wxlState.Ok() && !m_wxlstate_static) { if (m_wxlState.IsRunning()) m_wxlState.DebugHookBreak(); m_wxlState.CloseLuaState(true); // force closing it since we own it - m_wxlState.Destroy(); // unref it so it's invalid } --- 83,94 ---- if (m_wxlState.Ok() && !m_wxlstate_static) { + // try to close it nicely first if (m_wxlState.IsRunning()) + { + wxSafeYield(); m_wxlState.DebugHookBreak(); + } m_wxlState.CloseLuaState(true); // force closing it since we own it } *************** *** 97,105 **** { // ask if anyone else wants to create the wxLuaState for us ! wxLuaEvent event(wxEVT_LUASHELL_wxLUA_CREATION, GetId(), wxNullLuaState); event.SetEventObject(this); event.SetInt(0); event.SetExtraLong(win_id); ! GetEventHandler()->ProcessEvent( event ); if (event.GetwxLuaState().Ok()) --- 100,110 ---- { // ask if anyone else wants to create the wxLuaState for us ! wxLuaEvent event(wxEVT_LUASHELL_wxLUA_CREATION, GetId(), m_wxlState); event.SetEventObject(this); event.SetInt(0); event.SetExtraLong(win_id); ! // return if handled, but not skipped. ! if (GetEventHandler()->ProcessEvent(event)) ! return false; if (event.GetwxLuaState().Ok()) *************** *** 529,537 **** if (m_wxlState.Ok() && !m_wxlstate_static) { if (m_wxlState.IsRunning()) m_wxlState.DebugHookBreak(); m_wxlState.CloseLuaState(true); // force closing it since we own it - m_wxlState.Destroy(); // unref it so it's invalid } --- 534,545 ---- if (m_wxlState.Ok() && !m_wxlstate_static) { + // try to close it nicely first if (m_wxlState.IsRunning()) + { + wxSafeYield(); m_wxlState.DebugHookBreak(); + } m_wxlState.CloseLuaState(true); // force closing it since we own it } *************** *** 641,649 **** editor->MarkerDeleteAll(wxLuaEditor::markerError); m_luaOutput->SetReadOnly(false); m_luaOutput->ClearAll(); m_luaOutput->MarkerDeleteAll(wxLuaShell::markerPrompt); ! WriteMessage(m_luaOutput, wxT("Running lua script : ") + wxNow() + wxT("\n")); wxStopWatch stopWatch; //m_luaOutput->SetReadOnly(true); --- 649,658 ---- editor->MarkerDeleteAll(wxLuaEditor::markerError); + wxString name = m_editorNotebook->GetPageText(m_editorNotebook->GetSelection()); m_luaOutput->SetReadOnly(false); m_luaOutput->ClearAll(); m_luaOutput->MarkerDeleteAll(wxLuaShell::markerPrompt); ! WriteMessage(m_luaOutput, wxT("Running lua script '") + name + wxT("' : ") + wxNow() + wxT("\n")); wxStopWatch stopWatch; //m_luaOutput->SetReadOnly(true); *************** *** 670,675 **** m_wxlState.SetLuaDebugHook(1000, 100, false, LUA_MASKCALL|LUA_MASKRET|LUA_MASKLINE|LUA_MASKCOUNT); - wxString name = m_editorNotebook->GetPageText(m_editorNotebook->GetSelection()); - m_luaOutput->SetReadOnly(true); editor->SetReadOnly(true); --- 679,682 ---- *************** *** 695,699 **** m_wxlState.DebugHookBreak(wxT("Interpreter stopped")); } ! else if (m_luaShell->GetwxLuaState().Ok() && m_luaShell->GetwxLuaState().IsRunning()) { m_luaShell->GetwxLuaState().DebugHookBreak(wxT("Interpreter stopped")); --- 702,706 ---- m_wxlState.DebugHookBreak(wxT("Interpreter stopped")); } ! else if (m_luaShell && m_luaShell->GetwxLuaState().Ok() && m_luaShell->GetwxLuaState().IsRunning()) { m_luaShell->GetwxLuaState().DebugHookBreak(wxT("Interpreter stopped")); |