From: John L. <jr...@us...> - 2006-09-25 22:24:50
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1920/wxLua/samples Modified Files: editor.wx.lua Log Message: more cleanup in editor, fix debugger exit socket error add more process debugging to socket code Index: editor.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/editor.wx.lua,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** editor.wx.lua 25 Sep 2006 19:22:27 -0000 1.24 --- editor.wx.lua 25 Sep 2006 22:24:46 -0000 1.25 *************** *** 306,310 **** if filePath and (string.len(filePath) > 0) and oldModTime and oldModTime:IsValid() then local modTime = GetFileModTime(filePath) ! if modTime:IsValid() and oldModTime:IsEarlierThan(modTime) then local ret = wx.wxMessageBox(fileName.." has been modified on disk. Do you want to reload it?", "wxLua Message", --- 306,310 ---- if filePath and (string.len(filePath) > 0) and oldModTime and oldModTime:IsValid() then local modTime = GetFileModTime(filePath) ! if modTime and modTime:IsValid() and oldModTime:IsEarlierThan(modTime) then local ret = wx.wxMessageBox(fileName.." has been modified on disk. Do you want to reload it?", "wxLua Message", *************** *** 355,359 **** editor:StyleSetFont(1, fontItalic) --editor:StyleSetUnderline(1, false) ! editor:StyleSetForeground(2, wx.wxColour(0, 127, 0)) -- Line Comment editor:StyleSetFont(2, fontItalic) -- Doc. Comment --editor:StyleSetUnderline(2, false) --- 355,359 ---- editor:StyleSetFont(1, fontItalic) --editor:StyleSetUnderline(1, false) ! editor:StyleSetForeground(2, wx.wxColour(0, 127, 0)) -- Line Comment editor:StyleSetFont(2, fontItalic) -- Doc. Comment --editor:StyleSetUnderline(2, false) *************** *** 398,404 **** editor:StyleSetForeground(32, wx.wxColour(224, 192, 224)) -- Line number editor:StyleSetBackground(33, wx.wxColour(192, 192, 192)) -- Brace highlight ! editor:StyleSetForeground(34, wx.wxColour(0, 0, 255)) editor:StyleSetBold(34, true) -- Brace incomplete highlight ! editor:StyleSetForeground(35, wx.wxColour(255, 0, 0)) editor:StyleSetBold(35, true) -- Indentation guides editor:StyleSetForeground(37, wx.wxColour(192, 192, 192)) --- 398,404 ---- editor:StyleSetForeground(32, wx.wxColour(224, 192, 224)) -- Line number editor:StyleSetBackground(33, wx.wxColour(192, 192, 192)) -- Brace highlight ! editor:StyleSetForeground(34, wx.wxColour(0, 0, 255)) editor:StyleSetBold(34, true) -- Brace incomplete highlight ! editor:StyleSetForeground(35, wx.wxColour(255, 0, 0)) editor:StyleSetBold(35, true) -- Indentation guides editor:StyleSetForeground(37, wx.wxColour(192, 192, 192)) *************** *** 433,448 **** local ch = event:GetKey() if (ch == char_CR) or (ch == char_LF) then ! local lineNum = editor:LineFromPosition(editor:GetCurrentPos()) ! local lineLength = editor:LineLength(lineNum) ! if (lineNum > 0) and (lineLength <= 2) then ! lineNum = lineNum - 1 ! local lineLength = editor:LineLength(lineNum) ! local prevLine = editor:GetLine(lineNum) ! for lineOffset = 1, lineLength do ! ch = string.byte(prevLine, lineOffset) ! if (ch ~= char_Sp) and (ch ~= char_Tab) then ! editor:ReplaceSelection(string.sub(prevLine, 1, lineOffset - 1)) ! break ! end end end --- 433,444 ---- local ch = event:GetKey() if (ch == char_CR) or (ch == char_LF) then ! local pos = editor:GetCurrentPos() ! local line = editor:LineFromPosition(pos) ! ! if (line > 0) and (editor:LineLength(line) == 0) then ! local indent = editor:GetLineIndentation(line - 1) ! if indent > 0 then ! editor:SetLineIndentation(line, indent) ! editor:GotoPos(pos + indent) end end *************** *** 474,478 **** editor:Connect(wx.wxEVT_STC_SAVEPOINTREACHED, function (event) ! SetDocumentModified(editor:GetId(), nil, false) end) --- 470,474 ---- editor:Connect(wx.wxEVT_STC_SAVEPOINTREACHED, function (event) ! SetDocumentModified(editor:GetId(), false, false) end) *************** *** 490,499 **** local id = editor:GetId() local document = {} - document.isModified = nil - document.fileName = nil - document.filePath = nil document.editor = editor document.index = notebook:GetSelection() document.modTime = nil openDocuments[id] = document end --- 486,495 ---- local id = editor:GetId() local document = {} document.editor = editor document.index = notebook:GetSelection() + document.fileName = nil + document.filePath = nil document.modTime = nil + document.isModified = nil openDocuments[id] = document end *************** *** 503,507 **** function IsLuaFile(filePath) ! return string.lower(string.sub(filePath, -4)) == ".lua" end --- 499,503 ---- function IsLuaFile(filePath) ! return (string.len(filePath) > 4) and (string.lower(string.sub(filePath, -4)) == ".lua") end *************** *** 593,608 **** -- Create the watch window - function FindSelectedWatchItem() - local count = watchListCtrl:GetSelectedItemCount() - if count > 0 then - for idx = 0, watchListCtrl:GetItemCount() - 1 do - if watchListCtrl:GetItemState(idx, wx.wxLIST_STATE_FOCUSED) ~= 0 then - return idx - end - end - end - return -1 - end - function ProcessWatches() if watchListCtrl and debugServer then --- 589,592 ---- *************** *** 623,627 **** function CreateWatchWindow() ! watchWindow = wx.wxFrame( frame, wx.wxID_ANY, "wxLua Watch Window", wx.wxDefaultPosition, wx.wxSize(190, 160)) local watchMenu = wx.wxCreateMenu{ --- 607,613 ---- function CreateWatchWindow() ! local width = 180 ! watchWindow = wx.wxFrame(frame, wx.wxID_ANY, "wxLua Watch Window", ! wx.wxDefaultPosition, wx.wxSize(width, 160)) local watchMenu = wx.wxCreateMenu{ *************** *** 630,653 **** { ID_REMOVEWATCH, "&Remove Watch" }, { ID_EVALUATEWATCH, "Evaluate &Watches" }} - local watchMenuBar = wx.wxMenuBar() watchMenuBar:Append(watchMenu, "&Watches") watchWindow:SetMenuBar(watchMenuBar) - local x, y = watchWindow:GetClientSize() watchListCtrl = wx.wxListCtrl(watchWindow, ID_WATCH_WINDOW, ! wx.wxPoint(0, 0), wx.wxSize(x, y), wx.wxLC_REPORT + wx.wxLC_EDIT_LABELS) - x, y = watchListCtrl:GetClientSize() - local info = wx.wxListItem() info:SetMask(wx.wxLIST_MASK_TEXT + wx.wxLIST_MASK_WIDTH) info:SetText("Expression") ! info:SetWidth(x / 2) watchListCtrl:InsertColumn(0, info) info:SetText("Value") ! info:SetWidth(x / 2) watchListCtrl:InsertColumn(1, info) --- 616,636 ---- { ID_REMOVEWATCH, "&Remove Watch" }, { ID_EVALUATEWATCH, "Evaluate &Watches" }} + local watchMenuBar = wx.wxMenuBar() watchMenuBar:Append(watchMenu, "&Watches") watchWindow:SetMenuBar(watchMenuBar) watchListCtrl = wx.wxListCtrl(watchWindow, ID_WATCH_WINDOW, ! wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxLC_REPORT + wx.wxLC_EDIT_LABELS) local info = wx.wxListItem() info:SetMask(wx.wxLIST_MASK_TEXT + wx.wxLIST_MASK_WIDTH) info:SetText("Expression") ! info:SetWidth(width / 2) watchListCtrl:InsertColumn(0, info) info:SetText("Value") ! info:SetWidth(width / 2) watchListCtrl:InsertColumn(1, info) *************** *** 656,671 **** watchWindow:Show(true) watchWindow:Connect( wx.wxEVT_CLOSE_WINDOW, function (event) ConfigSaveFramePosition(watchWindow, "WatchWindow") - event:Skip() watchWindow = nil watchListCtrl = nil - end) - - watchWindow:Connect( wx.wxEVT_SIZE, - function (event) - local x, y = watchWindow:GetClientSize() - watchListCtrl:SetSize(x, y) event:Skip() end) --- 639,659 ---- watchWindow:Show(true) + local function FindSelectedWatchItem() + local count = watchListCtrl:GetSelectedItemCount() + if count > 0 then + for idx = 0, watchListCtrl:GetItemCount() - 1 do + if watchListCtrl:GetItemState(idx, wx.wxLIST_STATE_FOCUSED) ~= 0 then + return idx + end + end + end + return -1 + end + watchWindow:Connect( wx.wxEVT_CLOSE_WINDOW, function (event) ConfigSaveFramePosition(watchWindow, "WatchWindow") watchWindow = nil watchListCtrl = nil event:Skip() end) *************** *** 731,735 **** function UpdateUIMenuItems() if frame and frame:GetMenuBar() then ! for n = 0, frame:GetMenuBar():GetMenuCount() do frame:GetMenuBar():GetMenu(n):UpdateUI() end --- 719,723 ---- function UpdateUIMenuItems() if frame and frame:GetMenuBar() then ! for n = 0, frame:GetMenuBar():GetMenuCount()-1 do frame:GetMenuBar():GetMenu(n):UpdateUI() end *************** *** 751,755 **** function NewFile(event) local editor = CreateEditor("Untitled") ! SetupKeywords(editor, 1) end --- 739,743 ---- function NewFile(event) local editor = CreateEditor("Untitled") ! SetupKeywords(editor, true) end *************** *** 760,765 **** local editor = nil for id, document in pairs(openDocuments) do ! local filePath = document.filePath ! if (not document.isModified) and (not filePath) and not (document.editor:GetReadOnly() == true) then editor = document.editor --- 748,753 ---- local editor = nil for id, document in pairs(openDocuments) do ! if (document.editor:GetLength() == 0) and ! (not document.isModified) and (not document.filePath) and not (document.editor:GetReadOnly() == true) then editor = document.editor *************** *** 792,796 **** openDocuments[id].filePath = filePath openDocuments[id].fileName = fileName ! SetDocumentModified(id, nil, true) result = editor end --- 780,784 ---- openDocuments[id].filePath = filePath openDocuments[id].fileName = fileName ! SetDocumentModified(id, false, true) result = editor end *************** *** 822,826 **** handle:close() editor:EmptyUndoBuffer() ! SetDocumentModified(editor:GetId(), nil, true) return true end --- 810,814 ---- handle:close() editor:EmptyUndoBuffer() ! SetDocumentModified(editor:GetId(), false, true) return true end *************** *** 902,906 **** SaveFileAs(editor) elseif SaveFile(editor, filePath) then ! SetDocumentModified(editor:GetId(), nil, false) end end --- 890,894 ---- SaveFileAs(editor) elseif SaveFile(editor, filePath) then ! SetDocumentModified(editor:GetId(), false, false) end end *************** *** 1562,1565 **** --- 1550,1554 ---- if debugServer then debugServer:Reset() + wx.wxMilliSleep(500) -- allow client to exit cleanly debugServer:Delete() debugServer = nil *************** *** 1954,1962 **** else local editor = CreateEditor("Untitled") ! SetupKeywords(editor, 1) end else local editor = CreateEditor("Untitled") ! SetupKeywords(editor, 1) end --- 1943,1951 ---- else local editor = CreateEditor("Untitled") ! SetupKeywords(editor, true) end else local editor = CreateEditor("Untitled") ! SetupKeywords(editor, true) end |