From: John L. <jr...@us...> - 2008-12-03 05:26:08
|
Update of /cvsroot/wxlua/wxLua/apps/wxluaedit/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3179/wxLua/apps/wxluaedit/src Modified Files: wxledit.cpp wxluaedit.cpp Log Message: Make wxLuaEdit print items on the stack and use '=' as the Lua executable. Changed wxLuaState::RunBuffer() to take const char*, not const unsigned char*. Allow wxLuaState::RunString/Buffer() to leave values on the stack. Index: wxluaedit.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxluaedit.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** wxluaedit.cpp 20 Jul 2007 01:39:05 -0000 1.38 --- wxluaedit.cpp 3 Dec 2008 05:26:03 -0000 1.39 *************** *** 456,459 **** --- 456,460 ---- 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(" Values can be printed by prepending '=' or 'return'.\n")); shell->AppendText(wxT(" The wxLua intrepreter can be restarted with the command 'reset'.\n")); shell->MarkerDeleteAll(wxSTEditorShell::markerPrompt); Index: wxledit.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxledit.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** wxledit.cpp 26 Jan 2008 23:27:24 -0000 1.35 --- wxledit.cpp 3 Dec 2008 05:26:03 -0000 1.36 *************** *** 127,135 **** } ! bool wxLuaShell::RunString(const wxString& string, bool append_text) { bool ret = false; ! if (string.IsEmpty()) return ret; --- 127,137 ---- } ! bool wxLuaShell::RunString(const wxString& string_, bool append_text) { bool ret = false; ! wxString string(string_); ! ! if (string.Trim(true).Trim(false).IsEmpty()) return ret; *************** *** 163,167 **** } else if (m_wxlState.Ok()) ! ret = m_wxlState.RunString(string, wxT("wxLuaShell")) == 0; else AppendText(wxT("The lua interpreter is not available - try running 'reset'.\n")); --- 165,192 ---- } else if (m_wxlState.Ok()) ! { ! // allow for syntax of "= 1+2+3" to print result ! if (string.Trim(true).Find(wxT('=')) == 0) ! string = wxT("return ") + string.AfterFirst('='); ! ! if (0 != m_wxlState.CompileString(string)) ! { ! // try to see if we can return the value w/o error to print it ! if (0 == m_wxlState.CompileString(wxT("return ") + string)) ! string = wxT("return ") + string; ! } ! ! int top1 = m_wxlState.lua_GetTop(); ! ret = m_wxlState.RunString(string, wxT("wxLuaShell"), LUA_MULTRET) == 0; ! int top2 = m_wxlState.lua_GetTop(); ! ! if (ret && (top2 > top1)) ! { ! for (int n = top1+1; n <= top2; n++) ! AppendText(m_wxlState.lua_TowxString(n) + wxT("\n")); ! } ! ! m_wxlState.lua_SetTop(top1); ! } else AppendText(wxT("The lua interpreter is not available - try running 'reset'.\n")); |