From: John L. <jr...@us...> - 2006-09-25 19:22:34
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv26951/samples Modified Files: editor.wx.lua Log Message: more cleanup and formatting Index: editor.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/editor.wx.lua,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** editor.wx.lua 22 Sep 2006 22:29:21 -0000 1.23 --- editor.wx.lua 25 Sep 2006 19:22:27 -0000 1.24 *************** *** 79,90 **** fHaveFound = nil -- true when string has been found editorApp = wx.wxGetApp() debugServer = nil -- wxLuaDebuggerServer object when debugging fIsRunning = nil -- true when the debuggee is running fIsConnected = nil -- true when a client has connected portNumber = 1551 -- the port # to use for debugging watchWindow = nil -- the watchWindow watchListCtrl = nil -- the child listctrl in the watchWindow ! notebook = nil -- the notebook of editors ! errorLog = nil -- the log window for errors openDocuments = {} -- table of open documents[winId] = {editor, index, filePath, fileName, modTime, isModified} ignoredFilesList = {} --- 79,96 ---- fHaveFound = nil -- true when string has been found editorApp = wx.wxGetApp() + debugServer = nil -- wxLuaDebuggerServer object when debugging fIsRunning = nil -- true when the debuggee is running fIsConnected = nil -- true when a client has connected portNumber = 1551 -- the port # to use for debugging + + -- wxWindow variables + frame = nil -- wxFrame the main top level window + splitter = nil -- wxSplitterWindow for the notebook and errorLog + notebook = nil -- wxNotebook of editors + errorLog = nil -- wxStyledTextCtrl log window for errors watchWindow = nil -- the watchWindow watchListCtrl = nil -- the child listctrl in the watchWindow ! openDocuments = {} -- table of open documents[winId] = {editor, index, filePath, fileName, modTime, isModified} ignoredFilesList = {} *************** *** 93,112 **** autoCompleteEnable = true wxkeywords = nil -- a string of the keywords for scintilla of wxLua's wx.XXX items ! -- Fonts to use for the editor ! function GetFonts() ! local font, fontItalic ! if wx.__WXMSW__ then ! font = wx.wxFont(10, wx.wxNORMAL, wx.wxNORMAL, wx.wxNORMAL, false, "Andale Mono") ! fontItalic = wx.wxFont(10, wx.wxNORMAL, wx.wxFONTSTYLE_ITALIC, wx.wxNORMAL, false, "Andale Mono") ! else ! font = wx.wxFont(10, wx.wxNORMAL, wx.wxNORMAL, wx.wxNORMAL, false, "lucidatypewriter") ! fontItalic = wx.wxFont(10, wx.wxNORMAL, wx.wxFONTSTYLE_ITALIC, wx.wxNORMAL, false, "lucidatypewriter") ! end ! return font, fontItalic ! end ! font, fontItalic = GetFonts() -- Initialize the wxConfig for loading/saving the preferences editorApp:SetVendorName("Lomtick Software") --- 99,116 ---- autoCompleteEnable = true wxkeywords = nil -- a string of the keywords for scintilla of wxLua's wx.XXX items + font = nil -- fonts to use for the editor + fontItalic = nil ! -- ---------------------------------------------------------------------------- ! if wx.__WXMSW__ then ! font = wx.wxFont(10, wx.wxNORMAL, wx.wxNORMAL, wx.wxNORMAL, false, "Andale Mono") ! fontItalic = wx.wxFont(10, wx.wxNORMAL, wx.wxFONTSTYLE_ITALIC, wx.wxNORMAL, false, "Andale Mono") ! else ! font = wx.wxFont(10, wx.wxNORMAL, wx.wxNORMAL, wx.wxNORMAL, false, "lucidatypewriter") ! fontItalic = wx.wxFont(10, wx.wxNORMAL, wx.wxFONTSTYLE_ITALIC, wx.wxNORMAL, false, "lucidatypewriter") ! end + -- ---------------------------------------------------------------------------- -- Initialize the wxConfig for loading/saving the preferences editorApp:SetVendorName("Lomtick Software") *************** *** 234,238 **** function GetEditor(selection) local editor = nil ! if not selection then selection = notebook:GetSelection() end --- 238,242 ---- function GetEditor(selection) local editor = nil ! if selection == nil then selection = notebook:GetSelection() end *************** *** 283,288 **** -- Get/Check file on disk datetime and if modified function GetFileModTime(filePath) ! local fileName = wx.wxFileName(filePath) ! return fileName:GetModificationTime(); end --- 287,298 ---- -- Get/Check file on disk datetime and if modified function GetFileModTime(filePath) ! if filePath and (string.len(filePath) > 0) then ! local fn = wx.wxFileName(filePath) ! if fn:FileExists() then ! return fn:GetModificationTime(); ! end ! end ! ! return wx.wxDateTime() -- invalid datetime end *************** *** 311,318 **** function SetDocumentModified(id, modified, resetModTime) ! local fileName = openDocuments[id].fileName ! if not fileName then ! fileName = "Untitled" ! end if modified then openDocuments[id].isModified = true --- 321,326 ---- function SetDocumentModified(id, modified, resetModTime) ! local fileName = openDocuments[id].fileName or "Untitled" ! if modified then openDocuments[id].isModified = true *************** *** 343,397 **** editor:StyleSetFont(wx.wxSTC_STYLE_DEFAULT, font) ! editor:StyleSetForeground(0, wx.wxColour(128, 128, 128)) -- White space ! editor:StyleSetForeground(1, wx.wxColour(0, 127, 0)) -- Comment 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) ! editor:StyleSetForeground(3, wx.wxColour(127, 127, 127)) -- Number ! editor:StyleSetForeground(4, wx.wxColour(0, 127, 127)) -- Keyword ! editor:StyleSetForeground(5, wx.wxColour(0, 0, 127)) -- Double quoted string editor:StyleSetBold(5, true) --editor:StyleSetUnderline(5, false) ! editor:StyleSetForeground(6, wx.wxColour(127, 0, 127)) -- Single quoted string ! editor:StyleSetForeground(7, wx.wxColour(127, 0, 127)) -- not used ! editor:StyleSetForeground(8, wx.wxColour(0, 127, 127)) -- Literal strings ! editor:StyleSetForeground(9, wx.wxColour(127, 127, 0)) -- Preprocessor ! editor:StyleSetForeground(10, wx.wxColour(0, 0, 0)) -- Operators --editor:StyleSetBold(10, true) ! editor:StyleSetForeground(11, wx.wxColour(0, 0, 0)) -- Identifiers ! editor:StyleSetForeground(12, wx.wxColour(0, 0, 0)) -- Unterminated strings editor:StyleSetBackground(12, wx.wxColour(224, 192, 224)) editor:StyleSetBold(12, true) editor:StyleSetEOLFilled(12, true) ! editor:StyleSetForeground(13, wx.wxColour(0, 0, 95)) -- Keyword highlighting styles ! editor:StyleSetForeground(14, wx.wxColour(0, 95, 0)) ! editor:StyleSetForeground(15, wx.wxColour(127, 0, 0)) ! editor:StyleSetForeground(16, wx.wxColour(127, 0, 95)) ! editor:StyleSetForeground(17, wx.wxColour(35, 95, 175)) ! editor:StyleSetForeground(18, wx.wxColour(0, 127, 127)) -- Nested literal strings ??? ! editor:StyleSetBackground(18, wx.wxColour(240,255,255)) ! editor:StyleSetForeground(19, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(19, wx.wxColour(224,255,255)) ! editor:StyleSetForeground(20, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(20, wx.wxColour(192,255,255)) ! editor:StyleSetForeground(21, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(21, wx.wxColour(176,255,255)) ! editor:StyleSetForeground(22, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(22, wx.wxColour(160,255,255)) ! editor:StyleSetForeground(23, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(23, wx.wxColour(144,255,255)) ! editor:StyleSetForeground(24, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(24, wx.wxColour(128,155,255)) ! 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)) editor:StyleSetBackground(37, wx.wxColour(255, 255, 255)) --- 351,405 ---- editor:StyleSetFont(wx.wxSTC_STYLE_DEFAULT, font) ! editor:StyleSetForeground(0, wx.wxColour(128, 128, 128)) -- White space ! editor:StyleSetForeground(1, wx.wxColour(0, 127, 0)) -- Comment 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) ! editor:StyleSetForeground(3, wx.wxColour(127, 127, 127)) -- Number ! editor:StyleSetForeground(4, wx.wxColour(0, 127, 127)) -- Keyword ! editor:StyleSetForeground(5, wx.wxColour(0, 0, 127)) -- Double quoted string editor:StyleSetBold(5, true) --editor:StyleSetUnderline(5, false) ! editor:StyleSetForeground(6, wx.wxColour(127, 0, 127)) -- Single quoted string ! editor:StyleSetForeground(7, wx.wxColour(127, 0, 127)) -- not used ! editor:StyleSetForeground(8, wx.wxColour(0, 127, 127)) -- Literal strings ! editor:StyleSetForeground(9, wx.wxColour(127, 127, 0)) -- Preprocessor ! editor:StyleSetForeground(10, wx.wxColour(0, 0, 0)) -- Operators --editor:StyleSetBold(10, true) ! editor:StyleSetForeground(11, wx.wxColour(0, 0, 0)) -- Identifiers ! editor:StyleSetForeground(12, wx.wxColour(0, 0, 0)) -- Unterminated strings editor:StyleSetBackground(12, wx.wxColour(224, 192, 224)) editor:StyleSetBold(12, true) editor:StyleSetEOLFilled(12, true) ! editor:StyleSetForeground(13, wx.wxColour(0, 0, 95)) -- Keyword highlighting styles ! editor:StyleSetForeground(14, wx.wxColour(0, 95, 0)) ! editor:StyleSetForeground(15, wx.wxColour(127, 0, 0)) ! editor:StyleSetForeground(16, wx.wxColour(127, 0, 95)) ! editor:StyleSetForeground(17, wx.wxColour(35, 95, 175)) ! editor:StyleSetForeground(18, wx.wxColour(0, 127, 127)) -- Nested literal strings ??? ! editor:StyleSetBackground(18, wx.wxColour(240, 255, 255)) ! editor:StyleSetForeground(19, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(19, wx.wxColour(224, 255, 255)) ! editor:StyleSetForeground(20, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(20, wx.wxColour(192, 255, 255)) ! editor:StyleSetForeground(21, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(21, wx.wxColour(176, 255, 255)) ! editor:StyleSetForeground(22, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(22, wx.wxColour(160, 255, 255)) ! editor:StyleSetForeground(23, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(23, wx.wxColour(144, 255, 255)) ! editor:StyleSetForeground(24, wx.wxColour(0, 127, 127)) ! editor:StyleSetBackground(24, wx.wxColour(128, 155, 255)) ! 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)) editor:StyleSetBackground(37, wx.wxColour(255, 255, 255)) *************** *** 407,420 **** editor:SetMarginWidth(0, editor:TextWidth(32, "99999_")) -- line # margin - editor:SetMarginWidth(2, 16) -- folding margin ! editor:SetMarginSensitive(1, true) -- marker margin ! editor:MarkerDefine(BREAKPOINT_MARKER, wx.wxSTC_MARK_CIRCLE, wx.wxGREEN, wx.wxGREEN) ! editor:MarkerDefine(CURRENT_LINE_MARKER, wx.wxSTC_MARK_ARROW, wx.wxRED, wx.wxRED) editor:Connect(wx.wxEVT_STC_MARGINCLICK, function (event) ! local row = editor:LineFromPosition(event:GetPosition()) ! ToggleDebugMarker(editor, row) end) --- 415,429 ---- editor:SetMarginWidth(0, editor:TextWidth(32, "99999_")) -- line # margin ! editor:SetMarginWidth(1, 16) -- marker margin ! editor:SetMarginType(1, wx.wxSTC_MARGIN_SYMBOL); ! editor:SetMarginSensitive(1, true) ! editor:MarkerDefine(BREAKPOINT_MARKER, wx.wxSTC_MARK_ROUNDRECT, wx.wxWHITE, wx.wxRED) ! editor:MarkerDefine(CURRENT_LINE_MARKER, wx.wxSTC_MARK_ARROW, wx.wxBLACK, wx.wxGREEN) editor:Connect(wx.wxEVT_STC_MARGINCLICK, function (event) ! local line = editor:LineFromPosition(event:GetPosition()) ! ToggleDebugMarker(editor, line) end) *************** *** 722,726 **** function UpdateUIMenuItems() if frame and frame:GetMenuBar() then ! for n = 0, frame:GetMenuBar():GetCount() do frame:GetMenuBar():GetMenu(n):UpdateUI() end --- 731,735 ---- function UpdateUIMenuItems() if frame and frame:GetMenuBar() then ! for n = 0, frame:GetMenuBar():GetMenuCount() do frame:GetMenuBar():GetMenu(n):UpdateUI() end |