diff --git a/Internal/UI/Input.lua b/Internal/UI/Input.lua index 7aa3021..0ad9053 100644 --- a/Internal/UI/Input.lua +++ b/Internal/UI/Input.lua @@ -819,6 +819,7 @@ local function GetInstance(Id) Instance.Lines = nil Instance.TextObject = nil Instance.Highlight = nil + Instance.ShouldUpdateTextObject = false table.insert(Instances, Instance) return Instance end @@ -920,7 +921,8 @@ function Input.Begin(Id, Options) ContentW, ContentH = Text.GetSizeWrap(Instance.Text, Options.MultiLineW) end - local ShouldUpdateTextObject = false + local ShouldUpdateTextObject = Instance.ShouldUpdateTextObject + Instance.ShouldUpdateTextObject = false if Instance.Lines == nil and Instance.Text ~= "" then if Options.MultiLine then @@ -952,6 +954,11 @@ function Input.Begin(Id, Options) end end end + else + if Instance.Highlight ~= nil then + Instance.Highlight = nil + ShouldUpdateTextObject = true + end end if ShouldUpdateTextObject then @@ -1185,7 +1192,7 @@ function Input.Begin(Id, Options) local WheelX, WheelY = Region.GetWheelDelta() if DeltaY ~= 0.0 or WheelY ~= 0.0 then - UpdateTextObject(Instance, Options.MultiLineW, Instance.Align, Options.Highlight, Options.TextColor) + Instance.ShouldUpdateTextObject = true end end diff --git a/SlabDebug.lua b/SlabDebug.lua index 171a2e8..1616d6d 100644 --- a/SlabDebug.lua +++ b/SlabDebug.lua @@ -449,6 +449,32 @@ function SlabDebug.Input() Slab.EndWindow() end +local SlabDebug_MultiLine_Highlight = { + ['function'] = {1, 0, 0, 1}, + ['end'] = {1, 0, 0, 1}, + ['if'] = {1, 0, 0, 1}, + ['then'] = {1, 0, 0, 1}, + ['local'] = {1, 0, 0, 1}, + ['for'] = {1, 0, 0, 1}, + ['do'] = {1, 0, 0, 1}, + ['not'] = {1, 0, 0, 1}, + ['while'] = {1, 0, 0, 1}, + ['repeat'] = {1, 0, 0, 1}, + ['until'] = {1, 0, 0, 1}, + ['break'] = {1, 0, 0, 1}, + ['else'] = {1, 0, 0, 1}, + ['elseif'] = {1, 0, 0, 1}, + ['in'] = {1, 0, 0, 1}, + ['and'] = {1, 0, 0, 1}, + ['or'] = {1, 0, 0, 1}, + ['true'] = {1, 0, 0, 1}, + ['false'] = {1, 0, 0, 1}, + ['nil'] = {1, 0, 0, 1}, + ['return'] = {1, 0, 0, 1} +} + +local SlabDebug_MultiLine_ShouldHighlight = true + function SlabDebug.MultiLine() Slab.BeginWindow('SlabDebug_MultiLine', {Title = "Multi-Line Input"}) @@ -467,11 +493,22 @@ function SlabDebug.MultiLine() end end + Slab.SameLine() + if Slab.CheckBox(SlabDebug_MultiLine_ShouldHighlight, "Use Lua Highlight") then + SlabDebug_MultiLine_ShouldHighlight = not SlabDebug_MultiLine_ShouldHighlight + end + Slab.Separator() Slab.Text("File: " .. SlabDebug_MultiLine_FileName) - if Slab.Input('SlabDebug_MultiLine', {MultiLine = true, Text = SlabDebug_MultiLine_Contents, W = 500.0, H = 500.0}) then + if Slab.Input('SlabDebug_MultiLine', { + MultiLine = true, + Text = SlabDebug_MultiLine_Contents, + W = 500.0, + H = 500.0, + Highlight = SlabDebug_MultiLine_ShouldHighlight and SlabDebug_MultiLine_Highlight or nil + }) then SlabDebug_MultiLine_Contents = Slab.GetInputText() end