From: John L. <jr...@us...> - 2006-12-05 23:38:32
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv14362/wxLua/samples Modified Files: editor.wx.lua Log Message: cleanup the wxLuaConsole fix the editor saving before running code, print process id and use the wxLuaConsole when running Index: editor.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/editor.wx.lua,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** editor.wx.lua 5 Oct 2006 05:10:48 -0000 1.32 --- editor.wx.lua 5 Dec 2006 23:38:28 -0000 1.33 *************** *** 726,731 **** { ID_OPEN, "&Open...\tCtrl-O", "Open an existing document" }, { ID_SAVE, "&Save\tCtrl-S", "Save the current document" }, ! { ID_SAVEAS, "Save &As...\tCtrl-A", "Save the current document to a file with a new name" }, ! { ID_SAVEALL, "Save A&ll...", "Save all open documents" }, { ID_CLOSE, "&Close\tCtrl+W", "Close the current editor window" }, { }, --- 726,731 ---- { ID_OPEN, "&Open...\tCtrl-O", "Open an existing document" }, { ID_SAVE, "&Save\tCtrl-S", "Save the current document" }, ! { ID_SAVEAS, "Save &As...\tAlt-S", "Save the current document to a file with a new name" }, ! { ID_SAVEALL, "Save A&ll...\tCtrl-Shift-S", "Save all open documents" }, { ID_CLOSE, "&Close\tCtrl+W", "Close the current editor window" }, { }, *************** *** 797,806 **** function SaveFile(editor, filePath) ! local st = editor:GetText() ! local backPath = filePath..".bak" ! os.remove(backPath) ! os.rename(filePath, backPath) local handle = io.open(filePath, "wb") if handle then handle:write(st) handle:close() --- 797,808 ---- function SaveFile(editor, filePath) ! if filePath then ! local backPath = filePath..".bak" ! os.remove(backPath) ! os.rename(filePath, backPath) ! end local handle = io.open(filePath, "wb") if handle then + local st = editor:GetText() handle:write(st) handle:close() *************** *** 1507,1518 **** local id = editor:GetId(); if openDocuments[id].isModified then ! SaveFile(editor, openDocuments[id].filePath) ! openDocuments[id].isModified = false end ! local cmd = '"'..programName..'" '..openDocuments[id].filePath DisplayOutput("Running program: "..cmd.."\n") ! wx.wxExecute(cmd, wx.wxEXEC_ASYNC) end) frame:Connect(ID_RUN, wx.wxEVT_UPDATE_UI, --- 1509,1541 ---- local id = editor:GetId(); if openDocuments[id].isModified then ! local saved = false ! if not openDocuments[id].filePath then ! local ret = wx.wxMessageBox("You must save the program before running it.\nPress cancel to abort running.", ! "Save file?", ! wx.wxOK + wx.wxCANCEL + wx.wxCENTRE, frame) ! if ret == wx.wxOK then ! saved = SaveFileAs(editor) ! end ! else ! saved = SaveFile(editor, openDocuments[id].filePath) ! end ! ! if saved then ! openDocuments[id].isModified = false ! else ! return ! end end ! local cmd = '"'..programName..'" -c '..openDocuments[id].filePath DisplayOutput("Running program: "..cmd.."\n") ! local pid = wx.wxExecute(cmd, wx.wxEXEC_ASYNC) ! ! if pid == -1 then ! DisplayOutput(" Unknown ERROR Running program!\n") ! else ! DisplayOutput(" Process id is: "..tostring(pid).."\n") ! end end) frame:Connect(ID_RUN, wx.wxEVT_UPDATE_UI, |