-- TshwaneLex / TshwaneTerm/tlTerm sample Lua script. -- http://tshwanedje.com/ -- -- Assign random colours to each element and attribute in the current styles local Doc=tApp():GetCurrentDoc(); if Doc==nil then return "No open document"; end -- Get current 'set of styles' local Styles = Doc:GetCurrentStyles(); if Styles==nil then return "No current styles"; end local i,j; for i=0,Styles:GetNumStyles()-1,1 do local Style = Styles:GetStyle(i); -- j: Red,Green,Blue (Generates a hex colour string) local sFore = ""; for j=0,2,1 do local n = math.random(0,180); sFore = sFore..string.upper(string.format("%02x", n)); end Style:SetColourF(sFore); end Doc:SetDirty(); --Trigger a styles changed event so that the relevant parts of the program (e.g. Preview) can be refreshed. Evt_StylesChanged:Trigger(nil, Styles); return "Done";