Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if !epoe.GUI.RichText then return end
- local test=[[Hai! 'derp'
- ]]
- local white=Color(255,255,255,255)
- local red=Color(255,0,0,255)
- local colors={
- [":"] = Color(0,255,0)
- , ["["] = Color(255,0,0)
- , ["]"] = Color(255,0,0)
- , ["'"] = Color(100,230,255)
- , ['"'] = Color(100,230,255)
- , ["!"] = Color(255,0,0)
- , ["#"] = Color(255,100,0)
- , ["="] = Color(0,255,0)
- , ["?"] = Color(0,165,255)
- , ["("] = Color(0,165,255)
- , [")"] = Color(0,165,255)
- , ["-"] = Color(0,165,255)
- , ["1"] = Color(0,165,255)
- , ["2"] = Color(0,165,255)
- , ["3"] = Color(0,165,255)
- , ["4"] = Color(0,165,255)
- , ["5"] = Color(0,165,255)
- , ["6"] = Color(0,165,255)
- , ["7"] = Color(0,165,255)
- , ["8"] = Color(0,165,255)
- , ["9"] = Color(0,165,255)
- , ["0"] = Color(0,165,255)
- ,
- }
- local searchme="["
- for k,v in pairs(colors) do
- searchme=searchme..'%'..k
- end
- searchme=searchme.."1234567890]"
- print(searchme)
- RichTextHelp={}
- local cur_col=white
- function RichTextHelp:AppendString(str)
- --PrintTable(str)
- --MsgN("Append: "..tostring(str))
- epoe.GUI:AppendText(str)
- end
- function RichTextHelp:InsertColorChange(color)
- --if color==white then return end
- --MsgN("Color: "..(color==white and "white" or color==red and "red" or "??"))
- epoe.GUI:SetColor(color.r,color.g,color.b,255)
- end
- function RichTextHelp:AppendString_Syntax(str)
- str=str or test
- -- quotes highlight
- local pos=str:find([['.*']])
- local quoted= str:match( [['(.*)']] )
- len=quoted and #quoted+2
- self:InsertColorChange(white)
- if pos and len then
- local left=str:sub(1,pos-1)
- --local quote=str:sub(pos+1,pos+len-3)
- local right=str:sub(pos+len,-1)
- if #left>0 then
- self:AppendString_Syntax(left)
- end
- local quotechar=str:sub(pos,pos)
- self:InsertColorChange(red)
- self:AppendString(quotechar..quoted..quotechar)
- --MsgN("====")
- if #right>0 then
- self:AppendString_Syntax(right)
- return
- end
- end
- -- quotes highlight
- local pos=str:find([[".*"]])
- local quoted=str:match( [["(.*)"]] )
- len=quoted and #quoted+2
- self:InsertColorChange(white)
- if pos and len then
- local left=str:sub(1,pos-1)
- --local quote=str:sub(pos+1,pos+len-3)
- local right=str:sub(pos+len,-1)
- if #left>0 then
- self:AppendString_Syntax(left)
- end
- local quotechar=str:sub(pos,pos)
- self:InsertColorChange(red)
- self:AppendString(quotechar..quoted..quotechar)
- --MsgN("====")
- if #right>0 then
- self:AppendString_Syntax(right)
- return
- end
- end
- -- Normal highlight
- local pos=string.find(str,searchme)
- self:InsertColorChange(white)
- if !pos then self:AppendString(str) return end
- local left=str:sub(1,pos-1)
- local char=str:sub(pos,pos)
- local right=str:sub(pos+1,-1)
- if #left>0 then
- self:AppendString(left)
- end
- self:InsertColorChange(colors[char] or red)
- self:AppendString(char)
- --MsgN("====")
- if #right>0 then
- self:AppendString_Syntax(right)
- end
- end
- --print("Testing with: "..test)
- a=RichTextHelp
- a:AppendString_Syntax()
Advertisement
Add Comment
Please, Sign In to add comment