Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PANEL = vgui.Register("lua_editor", {}, "Panel")
- function PANEL:Init()
- self.Error = vgui.Create( "DLabel", self )
- self.Error:SetTextColor( Color( 255, 0, 0, 255 ) )
- self.Error:SetFont("UIBold")
- self.Error:Dock( BOTTOM )
- self.Error:SetVisible( false )
- self.HTML = vgui.Create( "HTML", self )
- self.HTML:SetURL("http://matt-zone.com/leditor/")
- self.HTML:Dock( FILL )
- self.HTML:SetVerticalScrollbarEnabled( true )
- self.Content = ""
- self:SetCode("Asjidjaisd")
- self.HTML.PageTitleChanged = function(HTML, title)
- print(title)
- if title and title ~= "" then
- local decoded = ""
- local i = 1
- while i < #title do
- decoded = decoded .. string.char(tonumber(title:sub(i,i+1), 16))
- i = i + 2
- end
- if self.Content != decoded then
- self.Content = decoded
- self:OnCodeChanged(decoded)
- local var = CompileString(decoded, "lua_editor", false)
- if type(var) == "string" then
- self:SetError(var)
- else
- self:SetError(false)
- end
- end
- end
- end
- end
- function PANEL:OnCodeChanged(code)
- end
- function PANEL:GetCode()
- return self.Content
- end
- function PANEL:SetCode(content)
- local encoded = ""
- for i=1, #content do
- encoded = encoded .. ("%02X"):format(content[i]:byte())
- end
- self.Content = content
- self.HTML:RunJavascript("SetContent(\"" .. encoded .. "\")")
- end
- function PANEL:SetError( err )
- if err then
- if not self.Error:IsVisible() then
- self.Error:SetVisible( true )
- self:InvalidateLayout()
- end
- self.Error:SetText( err )
- self.Error:SizeToContents()
- else
- if self.Error:IsVisible() then
- self.Error:SetVisible( false )
- self:InvalidateLayout()
- end
- end
- end
- print("uhoh")
Advertisement
Add Comment
Please, Sign In to add comment