From: John L. <jr...@us...> - 2006-12-07 01:22:06
|
Update of /cvsroot/wxlua/wxLua/apps/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv7442/wxLua/apps/wxlua/src Modified Files: lconsole.cpp lconsole.h wxlua.cpp wxlua.h Log Message: fix warnings in wxlstate for VC cleanup wxlcallb rename m_deleteTable to m_winDestroyTable since it's the tag for EVT_DESTROY simplify the wxLua editor app and add more messages, make the console really work nicely Index: wxlua.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/wxlua.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** wxlua.cpp 5 Dec 2006 23:38:28 -0000 1.39 --- wxlua.cpp 7 Dec 2006 01:22:02 -0000 1.40 *************** *** 24,34 **** #endif - #include "wx/splitter.h" #include "wx/cmdline.h" #include "wx/fs_mem.h" #include "wx/image.h" #include "wxlua/include/wxlua.h" #include "wxluasocket/include/wxldserv.h" #include "wxlua.h" #include "art/wxluasmall.xpm" --- 24,35 ---- #endif #include "wx/cmdline.h" #include "wx/fs_mem.h" #include "wx/image.h" + #include "wxlua/include/wxlua.h" #include "wxluasocket/include/wxldserv.h" #include "wxlua.h" + #include "editor.h" #include "art/wxluasmall.xpm" *************** *** 39,47 **** } // Declare the binding initialization functions as extern so we don't have to // #include the binding header for simplicity. ! extern bool wxLuaBinding_wx_init(); // modules/wxbind ! extern bool wxLuaBinding_wxstc_init(); // modules/wxstcbind ! extern bool wxLuaBinding_wxluasocket_init(); // modules/wxluasocket // --------------------------------------------------------------------------- --- 40,50 ---- } + #define ID_WXLUA_CONSOLE 100 + // Declare the binding initialization functions as extern so we don't have to // #include the binding header for simplicity. ! extern bool wxLuaBinding_wx_init(); // modules/wxbind ! extern bool wxLuaBinding_wxstc_init(); // modules/wxstcbind ! extern bool wxLuaBinding_wxluasocket_init(); // modules/wxluasocket // --------------------------------------------------------------------------- *************** *** 54,61 **** wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_OPTION_HELP }, ! { wxCMD_LINE_SWITCH, wxT("c"), wxT("console"), wxT("show message console"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, ! { wxCMD_LINE_OPTION, wxT("d"), wxT("debuggee"), wxT("run as debuggee, internal use"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, --- 57,64 ---- wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_OPTION_HELP }, ! { wxCMD_LINE_SWITCH, wxT("c"), wxT("console"), wxT("show message console for print statements"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, ! { wxCMD_LINE_OPTION, wxT("d"), wxT("debuggee"), wxT("run as debuggee, -d[host]:[port]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, *************** *** 66,70 **** wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_NEEDS_SEPARATOR }, ! { wxCMD_LINE_PARAM, wxT(""), wxT(""), wxT("run wxLua program w/ command line args"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_PARAM_MULTIPLE }, --- 69,76 ---- wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_NEEDS_SEPARATOR }, ! { wxCMD_LINE_SWITCH, wxT("q"), wxT("quit"), wxT("Do not exit even if there are no top level windows open."), ! wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, ! ! { wxCMD_LINE_PARAM, wxT(""), wxT(""), wxT("run wxLua program w/ command line args"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_PARAM_MULTIPLE }, *************** *** 75,79 **** // wxLuaStandaloneApp // --------------------------------------------------------------------------- - IMPLEMENT_APP(wxLuaStandaloneApp) --- 81,84 ---- *************** *** 85,96 **** bool wxLuaStandaloneApp::OnInit() ! { ! m_luaConsole = NULL; ! m_fMemoryBitmapAdded = false; m_pDebugTarget = NULL; ! wxString errorStr; ! int argCount = 0; ! bool fOk = false; #if defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) --- 90,103 ---- bool wxLuaStandaloneApp::OnInit() ! { ! m_programName = argv[0]; // The name of this program ! m_luaConsole = NULL; ! m_want_console = false; m_pDebugTarget = NULL; + m_mem_bitmap_added = false; ! int arg_count = 0; // counter for args used during parsing ! bool run_ok = false; // has the lua program executed ok ! bool dont_quit = false; // user specified -q switch to not quit #if defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) *************** *** 100,110 **** #endif // defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) - // The name of this program - m_programName = argv[0]; - wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxMemoryFSHandler); wxMemoryFSHandler::AddFile(wxT("wxLua"), wxBitmap(wxLuaSmall_xpm), wxBITMAP_TYPE_XPM); ! m_fMemoryBitmapAdded = true; #ifdef __WXGTK__ --- 107,114 ---- #endif // defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxMemoryFSHandler); wxMemoryFSHandler::AddFile(wxT("wxLua"), wxBitmap(wxLuaSmall_xpm), wxBITMAP_TYPE_XPM); ! m_mem_bitmap_added = true; #ifdef __WXGTK__ *************** *** 125,129 **** wxLuaBinding_wxluasocket_init(); ! m_wxlState = wxLuaState(this, -1); if (!m_wxlState.Ok()) return false; --- 129,133 ---- wxLuaBinding_wxluasocket_init(); ! m_wxlState = wxLuaState(this, wxID_ANY); if (!m_wxlState.Ok()) return false; *************** *** 140,212 **** case 0: { - argCount = 0; wxString value; - if (parser.Found(wxT("d"), &value)) - { - // Note: wxLuaDebuggerServer::StartClient() runs wxExecute(m_programName -d[host]:[port], ...) ! // Set up for debugging ! wxString serverName(value.BeforeFirst(wxT(':'))); ! ! long portNumber = 0; ! if (value.AfterFirst(wxT(':')).ToLong(&portNumber)) ! { ! m_pDebugTarget = new wxLuaDebugTarget(m_wxlState, serverName, (int)portNumber); ! if (m_pDebugTarget != NULL) ! return m_pDebugTarget->Run(); ! } ! return false; ! } // Check if we are to display the console if (parser.Found(wxT("c"))) { ! argCount++; ! if (!m_luaConsole) ! { ! wxLuaConsole *wxlConsole = new wxLuaConsole(this, m_wxlState); ! wxlConsole->Show(true); ! } } ! // See if a file has been specified that we are to edit ! if (parser.Found(wxT("e"), &value)) { ! argCount++; ! wxString fileName = value; ! PushArgs(argv, argc, argCount); ! int rc = RunEditor(); ! fOk = wxLuaState::CheckRunError(rc, &errorStr); ! if (!fOk) ! DisplayError(errorStr); ! break; } ! if (parser.GetParamCount() == 0) { ! PushArgs(argv, argc, argCount); ! int rc = RunEditor(); ! fOk = wxLuaState::CheckRunError(rc, &errorStr); ! if (!fOk) ! DisplayError(errorStr); break; } // See if we are to run the specified file with command-line arguments. //if (parser.Found(wxT("r"), &value)) { ! argCount++; // skip the program we're running wxString fileName = parser.GetParam(0); // already handled 0 params ! PushArgs(argv, argc, argCount); int rc = m_wxlState.RunFile(fileName); ! fOk = wxLuaState::CheckRunError(rc, &errorStr); ! if (!fOk) ! DisplayError(errorStr); break; --- 144,224 ---- case 0: { wxString value; ! // don't quit the program for no top level windows ! if (parser.Found(wxT("q"))) ! dont_quit = true; // Check if we are to display the console if (parser.Found(wxT("c"))) { ! arg_count++; ! m_want_console = true; ! m_luaConsole = new wxLuaConsole(NULL, ID_WXLUA_CONSOLE); ! m_luaConsole->Show(true); } ! // set up for debugging ! if (parser.Found(wxT("d"), &value)) { ! // Note: wxLuaDebuggerServer::StartClient() runs ! // wxExecute(m_programName -d[host]:[port], ...) ! wxString serverName(value.BeforeFirst(wxT(':'))); ! if (serverName.IsEmpty()) ! { ! DisplayMessage(_("The wxLua debugger server host name is empty : wxLua -d[host]:[port]\n"), true); ! } ! else ! { ! long portNumber = 0; ! if (value.AfterFirst(wxT(':')).ToLong(&portNumber)) ! { ! m_pDebugTarget = new wxLuaDebugTarget(m_wxlState, serverName, (int)portNumber); ! if (m_pDebugTarget != NULL) ! return m_pDebugTarget->Run(); ! else ! DisplayMessage(_("The wxLua debug target cannot start.\n"), true); ! } ! else ! DisplayMessage(_("The wxLua debugger server port is not a number : wxLua -d[host]:[port]\n"), true); ! } ! return (m_luaConsole != NULL); // will exit app when console is closed } ! // See if a file has been specified to edit or just start editor ! bool run_editor = parser.Found(wxT("e"), &value); ! if (run_editor || (parser.GetParamCount() == 0)) { ! // remove -e arg, but push the args in any case ! if (run_editor) arg_count++; ! PushArgs(argv, argc, arg_count); ! int rc = m_wxlState.RunBuffer(wxLuaEditor, wxLuaEditor_len, m_programName); ! wxString errorStr; ! run_ok = wxLuaState::CheckRunError(rc, &errorStr); ! if (!run_ok) ! DisplayMessage(errorStr, true, m_wxlState); break; } + // at least one parameter was specified, it must be a program to run. + // See if we are to run the specified file with command-line arguments. + // This is the default action if r is not specified. //if (parser.Found(wxT("r"), &value)) { ! arg_count++; // skip the program we're running wxString fileName = parser.GetParam(0); // already handled 0 params ! PushArgs(argv, argc, arg_count); int rc = m_wxlState.RunFile(fileName); ! wxString errorStr; ! run_ok = wxLuaState::CheckRunError(rc, &errorStr); ! if (!run_ok) ! DisplayMessage(errorStr, true, m_wxlState); break; *************** *** 223,233 **** // 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; } --- 235,245 ---- // check to see if there is a toplevel window open for the user to close, else exit ! if (run_ok && !dont_quit) { if (GetTopWindow() == NULL) ! run_ok = false; } ! return (m_luaConsole != NULL) || run_ok; } *************** *** 242,245 **** --- 254,262 ---- } + m_wxlState.CloseLuaState(true); + m_wxlState.Destroy(); + + m_want_console = false; // no more messages + if (m_luaConsole) { *************** *** 248,260 **** } ! if (m_fMemoryBitmapAdded) wxMemoryFSHandler::RemoveFile(wxT("wxLua")); - m_wxlState.CloseLuaState(true); - m_wxlState.Destroy(); - wxSafeYield(); // make sure windows get destroyed ! wxApp::OnExit(); #if defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) --- 265,274 ---- } ! if (m_mem_bitmap_added) wxMemoryFSHandler::RemoveFile(wxT("wxLua")); wxSafeYield(); // make sure windows get destroyed ! int ret = wxApp::OnExit(); #if defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) *************** *** 262,290 **** #endif // defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) ! return 0; } ! #include "editor.h" ! ! int wxLuaStandaloneApp::RunEditor() { ! return m_wxlState.RunBuffer(wxLuaEditor, wxLuaEditor_len, m_programName); ! } ! void wxLuaStandaloneApp::DisplayError(const wxString &errorStr) const ! { ! if (m_pDebugTarget != NULL) ! m_pDebugTarget->DisplayError(errorStr); ! else { if (m_luaConsole != NULL) ! m_luaConsole->DisplayText(errorStr, true); else #ifdef __WXMSW__ ! wxMessageBox(errorStr, wxT("wxLua Error")); #else ! fprintf(stderr, wx2lua(errorStr + wxT("\n"))); #endif // __WXMSW__ ! } } --- 276,325 ---- #endif // defined(__WXMSW__) && wxCHECK_VERSION(2, 3, 3) ! return ret; } ! void wxLuaStandaloneApp::DisplayMessage(const wxString &msg, bool is_error, ! const wxLuaState& wxlState) { ! // If they closed the console, but specified they wanted it ! // on the command-line, recreate it. ! if (m_want_console && (m_luaConsole == NULL)) ! { ! m_luaConsole = new wxLuaConsole(NULL, ID_WXLUA_CONSOLE); ! m_luaConsole->Show(true); ! } ! if (!is_error) { if (m_luaConsole != NULL) ! m_luaConsole->DisplayText(msg); else + { #ifdef __WXMSW__ ! wxMessageBox(msg, wxT("wxLua Print")); #else ! fprintf(stderr, wx2lua(msg + wxT("\n"))); ! //wxPrintf(msg + wxT("\n")); #endif // __WXMSW__ ! } ! } ! else ! { ! if (m_pDebugTarget != NULL) ! m_pDebugTarget->DisplayError(msg); ! else if (m_luaConsole != NULL) ! { ! m_luaConsole->DisplayText(msg); ! m_luaConsole->SetExitOnError(is_error); ! m_luaConsole->DisplayStack(wxlState); ! } ! else ! { ! #ifdef __WXMSW__ ! wxMessageBox(msg, wxT("wxLua Error")); ! #else ! fprintf(stderr, wx2lua(msg + wxT("\n"))); ! #endif // __WXMSW__ ! } } } *************** *** 314,335 **** lua_rawseti(L, -2, 0); lua_setglobal(L, "arg"); - - return narg; } ! luaL_checkstack(L, narg + 3, "too many arguments to script"); ! for (i = start_n+1; i < argc; i++) ! lua_pushstring(L, wx2lua(argv[i])); ! lua_createtable(L, narg, start_n + 1); ! for (i = 0; i < argc; i++) ! { ! lua_pushstring(L, wx2lua(argv[i])); ! lua_rawseti(L, -2, i - start_n); } - lua_setglobal(L, "arg"); - return narg; } --- 349,370 ---- lua_rawseti(L, -2, 0); lua_setglobal(L, "arg"); } + else + { + luaL_checkstack(L, narg + 3, "too many arguments to script"); + for (i = start_n+1; i < argc; i++) + lua_pushstring(L, wx2lua(argv[i])); ! lua_createtable(L, narg, start_n + 1); ! for (i = 0; i < argc; i++) ! { ! lua_pushstring(L, wx2lua(argv[i])); ! lua_rawseti(L, -2, i - start_n); ! } ! lua_setglobal(L, "arg"); } return narg; } *************** *** 337,355 **** void wxLuaStandaloneApp::OnLua( wxLuaEvent &event ) { ! if (event.GetEventType() == wxEVT_LUA_PRINT) ! { ! if (m_luaConsole != NULL) ! m_luaConsole->DisplayText(event.GetString()); ! else ! #ifdef __WXMSW__ ! wxMessageBox(event.GetString(), wxT("wxLua Print")); ! #else ! fprintf(stderr, wx2lua(event.GetString() + wxT("\n"))); ! //wxPrintf(event.GetString() + wxT("\n")); ! #endif // __WXMSW__ ! } ! else if (event.GetEventType() == wxEVT_LUA_ERROR) ! { ! DisplayError(event.GetString()); ! } } --- 372,376 ---- void wxLuaStandaloneApp::OnLua( wxLuaEvent &event ) { ! DisplayMessage(event.GetString(), event.GetEventType() == wxEVT_LUA_ERROR, ! event.GetwxLuaState()); } Index: lconsole.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/lconsole.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** lconsole.h 5 Dec 2006 23:38:28 -0000 1.7 --- lconsole.h 7 Dec 2006 01:22:02 -0000 1.8 *************** *** 14,37 **** #endif ! class wxLuaStandaloneApp; #include "wxlua/include/wxlua.h" // ---------------------------------------------------------------------------- ! // wxLuaDebugPanel ! // ---------------------------------------------------------------------------- ! ! class wxLuaDebugListBox : public wxListBox ! { ! public: ! wxLuaDebugListBox(wxWindow *parent, const wxLuaState& wxlState); ! ! void FillListbox(); ! ! protected: ! wxLuaState m_wxlState; ! }; ! ! // ---------------------------------------------------------------------------- ! // wxLuaConsole - define our console class // ---------------------------------------------------------------------------- --- 14,22 ---- #endif ! #include "wx/frame.h" #include "wxlua/include/wxlua.h" // ---------------------------------------------------------------------------- ! // wxLuaConsole - define a console class to display print statements // ---------------------------------------------------------------------------- *************** *** 39,54 **** { 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; DECLARE_EVENT_TABLE() }; --- 24,51 ---- { public: ! wxLuaConsole(wxWindow* parent, wxWindowID id, ! const wxString& title = wxT("wxLua console"), ! const wxPoint& pos = wxDefaultPosition, ! const wxSize& size = wxSize(300, 400), ! long style = wxDEFAULT_FRAME_STYLE, ! const wxString& name = wxT("wxLuaConsole")); ! ! // Display a message in the console ! void DisplayText(const wxString& msg); ! // Display the stack in a wxListBox, but only if there are any items in it ! void DisplayStack(const wxLuaState& wxlState); ! // An error has occurred, when this window is closed call wxExit to close ! // the app. ! void SetExitOnError(bool is_error) { m_exit_on_error = m_exit_on_error || is_error; } protected: void OnCloseWindow(wxCloseEvent& event); ! wxSplitterWindow *m_splitter; ! wxTextCtrl *m_textCtrl; ! wxListBox *m_debugListBox; ! bool m_exit_on_error; + private: DECLARE_EVENT_TABLE() }; Index: wxlua.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/wxlua.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** wxlua.h 3 Oct 2006 05:12:44 -0000 1.21 --- wxlua.h 7 Dec 2006 01:22:02 -0000 1.22 *************** *** 17,23 **** #endif - #include "lconsole.h" - #include "wxluasocket/include/wxldtarg.h" #include "wx/app.h" class WXDLLIMPEXP_WXLUA wxLuaEvent; --- 17,23 ---- #endif #include "wx/app.h" + #include "wxluasocket/include/wxldtarg.h" + #include "lconsole.h" class WXDLLIMPEXP_WXLUA wxLuaEvent; *************** *** 34,43 **** virtual int OnExit(); ! void DisplayError(const wxString &strError) const; ! ! // set the lua console ! void SetLuaConsole(wxLuaConsole *pConsole) { m_luaConsole = pConsole; } ! ! int RunEditor(); void CreateSimpleArgs(); --- 34,39 ---- virtual int OnExit(); ! void DisplayMessage(const wxString &msg, bool is_error, ! const wxLuaState& wxlState = wxNullLuaState); void CreateSimpleArgs(); *************** *** 49,53 **** wxLuaState m_wxlState; wxLuaConsole *m_luaConsole; ! bool m_fMemoryBitmapAdded; wxLuaDebugTarget *m_pDebugTarget; --- 45,50 ---- wxLuaState m_wxlState; wxLuaConsole *m_luaConsole; ! bool m_want_console; ! bool m_mem_bitmap_added; wxLuaDebugTarget *m_pDebugTarget; Index: lconsole.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/lconsole.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** lconsole.cpp 5 Dec 2006 23:38:28 -0000 1.12 --- lconsole.cpp 7 Dec 2006 01:22:02 -0000 1.13 *************** *** 34,59 **** // ---------------------------------------------------------------------------- ! // wxLuaDebugPanel // ---------------------------------------------------------------------------- ! 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")); int nIndex = 0; lua_Debug luaDebug; wxString buffer; ! Clear(); ! lua_State* L = m_wxlState.GetLuaState(); while (lua_getstack(L, nIndex, &luaDebug) != 0) --- 34,90 ---- // ---------------------------------------------------------------------------- ! // wxLuaConsole // ---------------------------------------------------------------------------- ! BEGIN_EVENT_TABLE(wxLuaConsole, wxFrame) ! EVT_CLOSE(wxLuaConsole::OnCloseWindow) ! END_EVENT_TABLE() ! ! wxLuaConsole::wxLuaConsole(wxWindow* parent, wxWindowID id, const wxString& title, ! const wxPoint& pos, const wxSize& size, ! long style, const wxString& name) ! :wxFrame(parent, id, title, pos, size, style, name), m_exit_on_error(false) { ! SetIcon(wxICON(LUA)); ! m_splitter = new wxSplitterWindow(this, wxID_ANY, ! wxDefaultPosition, wxDefaultSize, ! wxSP_3DSASH); ! m_textCtrl = new wxTextCtrl(m_splitter, wxID_ANY, wxEmptyString, ! wxDefaultPosition, wxDefaultSize, ! wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH); ! m_debugListBox = new wxListBox(m_splitter, wxID_ANY, ! wxDefaultPosition, wxDefaultSize, ! 0, NULL, wxLB_SINGLE); ! m_debugListBox->Show(false); ! ! // listbox is shown only when used ! m_splitter->Initialize(m_textCtrl); } ! void wxLuaConsole::OnCloseWindow(wxCloseEvent&) { ! if (wxGetApp().m_luaConsole == this) ! wxGetApp().m_luaConsole = NULL; ! ! Destroy(); ! if (m_exit_on_error) ! wxExit(); ! } ! ! void wxLuaConsole::DisplayText(const wxString& msg) ! { ! m_textCtrl->AppendText(msg + wxT("\n")); ! } ! ! void wxLuaConsole::DisplayStack(const wxLuaState& wxlState) ! { ! wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); int nIndex = 0; lua_Debug luaDebug; wxString buffer; ! m_debugListBox->Clear(); ! lua_State* L = wxlState.GetLuaState(); while (lua_getstack(L, nIndex, &luaDebug) != 0) *************** *** 84,153 **** // skip over ourselves on the stack if (nIndex > 0) ! Append(buffer, (void *) nIndex); } nIndex++; } - } - - // ---------------------------------------------------------------------------- - // wxLuaConsole - // ---------------------------------------------------------------------------- ! 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) ! { ! SetIcon(wxICON(LUA)); ! ! 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__ ! | wxTE_RICH ! #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); ! } ! ! void wxLuaConsole::OnCloseWindow(wxCloseEvent&) ! { ! m_pApp->SetLuaConsole(NULL); ! ! Destroy(); ! if (m_fError) ! wxExit(); ! } ! ! 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); ! } ! } } --- 115,128 ---- // skip over ourselves on the stack if (nIndex > 0) ! m_debugListBox->Append(buffer, (void *) nIndex); } nIndex++; } ! // 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); } } |