From: John L. <jr...@us...> - 2006-12-05 23:38:32
|
Update of /cvsroot/wxlua/wxLua/apps/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv14362/wxLua/apps/wxlua/src Modified Files: editor.h lconsole.cpp lconsole.h wxlua.cpp Log Message: cleanup the wxLuaConsole fix the editor saving before running code, print process id and use the wxLuaConsole when running Index: wxlua.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/wxlua.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** wxlua.cpp 4 Oct 2006 05:55:02 -0000 1.38 --- wxlua.cpp 5 Dec 2006 23:38:28 -0000 1.39 *************** *** 222,225 **** --- 222,232 ---- } + // check to see if there is a toplevel window open for the user to close, else exit + if (fOk) + { + if (GetTopWindow() == NULL) + fOk = false; + } + return (m_luaConsole != NULL) || fOk; } *************** *** 275,279 **** else #ifdef __WXMSW__ ! wxMessageBox(errorStr, wxT("wxLua")); #else fprintf(stderr, wx2lua(errorStr + wxT("\n"))); --- 282,286 ---- else #ifdef __WXMSW__ ! wxMessageBox(errorStr, wxT("wxLua Error")); #else fprintf(stderr, wx2lua(errorStr + wxT("\n"))); *************** *** 336,342 **** else #ifdef __WXMSW__ ! wxMessageBox(event.GetString(), wxT("wxLua")); #else fprintf(stderr, wx2lua(event.GetString() + wxT("\n"))); #endif // __WXMSW__ } --- 343,350 ---- else #ifdef __WXMSW__ ! wxMessageBox(event.GetString(), wxT("wxLua Print")); #else fprintf(stderr, wx2lua(event.GetString() + wxT("\n"))); + //wxPrintf(event.GetString() + wxT("\n")); #endif // __WXMSW__ } Index: lconsole.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/lconsole.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** lconsole.h 5 Sep 2006 21:48:10 -0000 1.6 --- lconsole.h 5 Dec 2006 23:38:28 -0000 1.7 *************** *** 21,28 **** // ---------------------------------------------------------------------------- ! class wxLuaDebugPanel : public wxPanel { public: ! wxLuaDebugPanel(wxWindow *parent, const wxLuaState& wxlState); void FillListbox(); --- 21,28 ---- // ---------------------------------------------------------------------------- ! class wxLuaDebugListBox : public wxListBox { public: ! wxLuaDebugListBox(wxWindow *parent, const wxLuaState& wxlState); void FillListbox(); *************** *** 30,39 **** protected: wxLuaState m_wxlState; - wxListBox* m_listBox; - - void OnSizeWindow(wxSizeEvent& event); - void OnEraseBackground(wxEraseEvent& WXUNUSED(event)) {} - - DECLARE_EVENT_TABLE() }; --- 30,33 ---- *************** *** 46,60 **** public: wxLuaConsole(wxLuaStandaloneApp *pApp, const wxLuaState& wxlState); ! void DisplayText(wxString msg, bool fError = false); protected: void OnCloseWindow(wxCloseEvent& event); - void OnEraseBackground(wxEraseEvent& WXUNUSED(event)) {} - void FillListbox(); wxSplitterWindow *m_splitter; wxTextCtrl *m_textCtrl; wxLuaStandaloneApp *m_pApp; ! wxLuaDebugPanel *m_panel; bool m_fError; --- 40,52 ---- public: wxLuaConsole(wxLuaStandaloneApp *pApp, const wxLuaState& wxlState); ! void DisplayText(const wxString& msg, bool fError = false); protected: void OnCloseWindow(wxCloseEvent& event); wxSplitterWindow *m_splitter; wxTextCtrl *m_textCtrl; wxLuaStandaloneApp *m_pApp; ! wxLuaDebugListBox *m_debugListBox; bool m_fError; Index: editor.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/editor.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** editor.h 5 Oct 2006 05:10:44 -0000 1.26 --- editor.h 5 Dec 2006 23:38:28 -0000 1.27 *************** *** 5,2006 **** #include <stdio.h> /* for size_t */ ! /* Original filename: '../../../samples/editor.wx.lua' */ extern const size_t wxLuaEditor_len; extern const unsigned char wxLuaEditor[]; ! const size_t wxLuaEditor_len = 73920; ! const unsigned char wxLuaEditor[73921] = { ! 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 61, 45, 45, 45, 10, ! 45, 45, 32, 78, 97,109,101, 58, 32, 32, 32, 32, 32, 32, 32, 32, 69,100,105,116,111,114, 46,119,120, 46,108,117, 97, 10, [...3998 lines suppressed...] ! 13, 10, ! 32, 32, 32, 32,102,111,114, 32,105,110,100,101,120, 32, 61, 32, 49, 44, 32, 35, 97,114,103, 32,100,111, 13, 10, ! 32, 32, 32, 32, 32, 32, 32, 32,102,105,108,101, 78, 97,109,101, 32, 61, 32, 97,114,103, 91,105,110,100,101,120, 93, 13, 10, ! 32, 32, 32, 32, 32, 32, 32, 32, 76,111, 97,100, 70,105,108,101, 40,102,105,108,101, 78, 97,109,101, 44, 32,102,105,108,101, 78, 97,109,101, 41, 13, 10, ! 32, 32, 32, 32,101,110,100, 13, 10, ! 13, 10, ! 32, 32, 32, 32,105,102, 32,110,111,116,101, 98,111,111,107, 58, 71,101,116, 80, 97,103,101, 67,111,117,110,116, 40, 41, 32, 62, 32, 48, 32,116,104,101,110, 13, 10, ! 32, 32, 32, 32, 32, 32, 32, 32,110,111,116,101, 98,111,111,107, 58, 83,101,116, 83,101,108,101, 99,116,105,111,110, 40, 48, 41, 13, 10, ! 32, 32, 32, 32,101,108,115,101, 13, 10, ! 32, 32, 32, 32, 32, 32, 32,108,111, 99, 97,108, 32,101,100,105,116,111,114, 32, 61, 32, 67,114,101, 97,116,101, 69,100,105,116,111,114, 40, 34, 85,110,116,105,116,108,101,100, 34, 41, 13, 10, ! 32, 32, 32, 32, 32, 32, 32, 83,101,116,117,112, 75,101,121,119,111,114,100,115, 40,101,100,105,116,111,114, 44, 32,116,114,117,101, 41, 13, 10, ! 32, 32, 32, 32,101,110,100, 13, 10, ! 101,108,115,101, 13, 10, ! 32, 32, 32, 32,108,111, 99, 97,108, 32,101,100,105,116,111,114, 32, 61, 32, 67,114,101, 97,116,101, 69,100,105,116,111,114, 40, 34, 85,110,116,105,116,108,101,100, 34, 41, 13, 10, ! 32, 32, 32, 32, 83,101,116,117,112, 75,101,121,119,111,114,100,115, 40,101,100,105,116,111,114, 44, 32,116,114,117,101, 41, 13, 10, ! 101,110,100, 13, 10, ! 13, 10, ! 45, 45,102,114, 97,109,101, 58, 83,101,116, 73, 99,111,110, 40,119,120, 76,117, 97, 69,100,105,116,111,114, 73, 99,111,110, 41, 32, 45, 45, 70, 73, 88, 77, 69, 32, 97,100,100, 32,116,104,105,115, 32, 98, 97, 99,107, 13, 10, 0 }; Index: lconsole.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/lconsole.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** lconsole.cpp 7 Sep 2006 04:20:53 -0000 1.11 --- lconsole.cpp 5 Dec 2006 23:38:28 -0000 1.12 *************** *** 37,60 **** // ---------------------------------------------------------------------------- ! BEGIN_EVENT_TABLE(wxLuaDebugPanel, wxPanel) ! EVT_ERASE_BACKGROUND(wxLuaDebugPanel::OnEraseBackground) ! EVT_SIZE(wxLuaDebugPanel::OnSizeWindow) ! END_EVENT_TABLE() ! ! wxLuaDebugPanel::wxLuaDebugPanel(wxWindow *parent, const wxLuaState& wxlState) ! : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(50, 1500)) { ! m_wxlState = wxlState; ! m_listBox = new wxListBox( this, wxID_ANY, wxPoint(0, 20), wxSize(0, 130), ! 0, NULL, wxLB_SINGLE); ! } ! void wxLuaDebugPanel::OnSizeWindow(wxSizeEvent& event) ! { ! wxSize size = event.GetSize(); ! m_listBox->SetSize(0, 0, size.x, size.y); } ! void wxLuaDebugPanel::FillListbox() { wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); --- 37,51 ---- // ---------------------------------------------------------------------------- ! wxLuaDebugListBox::wxLuaDebugListBox(wxWindow *parent, const wxLuaState& wxlState) ! :wxListBox() { ! if (!wxListBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, ! 0, NULL, wxLB_SINGLE)) ! return; ! m_wxlState = wxlState; } ! void wxLuaDebugListBox::FillListbox() { wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); *************** *** 63,67 **** wxString buffer; ! m_listBox->Clear(); lua_State* L = m_wxlState.GetLuaState(); --- 54,58 ---- wxString buffer; ! Clear(); lua_State* L = m_wxlState.GetLuaState(); *************** *** 75,80 **** { if (luaDebug.name != NULL) ! buffer.Printf(wxT("function %s"), ! luaDebug.name); else buffer.Printf(wxT("{global}")); --- 66,71 ---- { if (luaDebug.name != NULL) ! buffer.Printf(wxT("function %s"), ! lua2wx(luaDebug.name).c_str()); else buffer.Printf(wxT("{global}")); *************** *** 83,91 **** { if (luaDebug.name != NULL) ! buffer.Printf(wxT("function %s line %u"), ! luaDebug.name, lineNumber); else ! buffer.Printf(wxT("{global} line %u"), lineNumber); } --- 74,82 ---- { if (luaDebug.name != NULL) ! buffer.Printf(wxT("function %s line %d"), ! lua2wx(luaDebug.name).c_str(), lineNumber); else ! buffer.Printf(wxT("{global} line %d"), lineNumber); } *************** *** 93,97 **** // skip over ourselves on the stack if (nIndex > 0) ! m_listBox->Append(buffer, (void *) nIndex); } nIndex++; --- 84,88 ---- // skip over ourselves on the stack if (nIndex > 0) ! Append(buffer, (void *) nIndex); } nIndex++; *************** *** 105,113 **** BEGIN_EVENT_TABLE(wxLuaConsole, wxFrame) EVT_CLOSE(wxLuaConsole::OnCloseWindow) - EVT_ERASE_BACKGROUND(wxLuaConsole::OnEraseBackground) END_EVENT_TABLE() wxLuaConsole::wxLuaConsole(wxLuaStandaloneApp *pApp, const wxLuaState& wxlState) ! : wxFrame(NULL, wxID_ANY, wxT("wxLua Console"), wxDefaultPosition, wxSize(250, 340)), m_pApp(pApp), m_fError(false) { --- 96,103 ---- BEGIN_EVENT_TABLE(wxLuaConsole, wxFrame) EVT_CLOSE(wxLuaConsole::OnCloseWindow) END_EVENT_TABLE() wxLuaConsole::wxLuaConsole(wxLuaStandaloneApp *pApp, const wxLuaState& wxlState) ! : wxFrame(NULL, wxID_ANY, wxT("wxLua Console"), wxDefaultPosition, wxSize(300, 340)), m_pApp(pApp), m_fError(false) { *************** *** 115,121 **** m_splitter = new wxSplitterWindow(this, wxID_ANY, ! wxPoint(0, 0), wxSize(0, 0), wxSP_3DSASH); m_textCtrl = new wxTextCtrl( m_splitter, wxID_ANY, wxT(""), ! wxPoint(0, 0), wxSize(0, 0), wxTE_MULTILINE | wxTE_READONLY #ifdef __WXMSW__ --- 105,112 ---- m_splitter = new wxSplitterWindow(this, wxID_ANY, ! wxDefaultPosition, wxDefaultSize, ! wxSP_3DSASH); m_textCtrl = new wxTextCtrl( m_splitter, wxID_ANY, wxT(""), ! wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY #ifdef __WXMSW__ *************** *** 123,129 **** #endif ); ! m_panel = new wxLuaDebugPanel( m_splitter, wxlState); ! m_splitter->SplitHorizontally( m_textCtrl, m_panel, 150); ! m_splitter->SetMinimumPaneSize(50); pApp->SetLuaConsole(this); --- 114,122 ---- #endif ); ! m_debugListBox = new wxLuaDebugListBox( m_splitter, wxlState); ! m_debugListBox->Show(false); ! ! // listbox is shown only when used ! m_splitter->Initialize(m_textCtrl); pApp->SetLuaConsole(this); *************** *** 139,149 **** } ! void wxLuaConsole::DisplayText(wxString msg, bool fError) { if (fError) m_fError = true; ! msg += wxString(wxT("\n")); ! m_textCtrl->AppendText(msg); if (fError) ! m_panel->FillListbox(); } --- 132,153 ---- } ! void wxLuaConsole::DisplayText(const wxString& msg, bool fError) { if (fError) m_fError = true; ! ! m_textCtrl->AppendText(msg + wxT("\n")); ! if (fError) ! { ! m_debugListBox->FillListbox(); ! ! // only show the listbox if it has anything in it ! if (m_debugListBox->GetCount() && !m_splitter->IsSplit()) ! { ! m_splitter->SplitHorizontally( m_textCtrl, m_debugListBox, 150); ! m_splitter->SetMinimumPaneSize(50); ! } ! ! } } |