Skip to content

Commit

Permalink
[Input]: Update multiline text when the region is scrolled on the nex…
Browse files Browse the repository at this point in the history
…t frame to account for transformation changes.

[Slab Debug]: Multiline option to use lua highlighting on loaded file.
  • Loading branch information
coding-jackalope committed Jul 10, 2019
1 parent 7e56551 commit c3bbc41
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
11 changes: 9 additions & 2 deletions Internal/UI/Input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
39 changes: 38 additions & 1 deletion SlabDebug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"})

Expand All @@ -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

Expand Down

0 comments on commit c3bbc41

Please sign in to comment.