2
DebugLocals = DebugInstrument:extend
7
onNew = function (self)
8
self.title.text = 'Locals'
9
self.names = self:add(Text:new{ font = self.font })
10
self.values = self:add(Text:new{ font = self.font })
11
self.lineHeight = self.names._fontObj:getHeight()
13
debugger.showLocals = function (level) self:showLocals(level) end
14
debugger.hideLocals = function (level) self.visible = false end
18
-- Makes the instrument visible and shows all locals at a stack level.
19
-- To hide this instrument, just set its visible property to false.
22
-- level - level to show
27
showLocals = function (self, level)
29
self.contentHeight = 2 * self.spacing
36
local name, value = debug.getlocal(level, i)
37
if not name then break end
39
-- skip variables named (*temporary*)
41
if not string.match(name, '^%(') then
42
self.names.text = self.names.text .. name .. '\n'
43
self.values.text = self.values.text .. tostring(value) .. '\n'
44
self.contentHeight = self.contentHeight + self.lineHeight
51
onResize = function (self, x, y, width, height)
52
self.names.y, self.values.y = y + self.spacing, y + self.spacing
53
self.names.height, self.values.height = height, height
55
self.names.x = x + self.spacing
56
self.names.width = width * 0.3 - self.spacing * 2
58
self.values.x = self.names.x + self.names.width + self.spacing
59
self.values.width = width * 0.7