2
-- Shows all local variables for a particular stack level.
4
DebugLocals = DebugInstrument:extend
9
onNew = function (self)
10
self.title.text = 'Locals'
11
self.names = self:add(Text:new{ font = self.font })
12
self.values = self:add(Text:new{ font = self.font })
13
self.lineHeight = self.names._fontObj:getHeight()
15
debugger.showLocals = function (level) self:showLocals(level) end
16
debugger.hideLocals = function (level) self.visible = false end
20
-- Makes the instrument visible and shows all locals at a stack level.
21
-- To hide this instrument, just set its visible property to false.
24
-- level - level to show
29
showLocals = function (self, level)
31
self.contentHeight = 2 * self.spacing
38
local name, value = debug.getlocal(level, i)
39
if not name then break end
41
-- skip variables named (*temporary*)
43
if not string.match(name, '^%(') then
44
self.names.text = self.names.text .. name .. '\n'
45
self.values.text = self.values.text .. tostring(value) .. '\n'
46
self.contentHeight = self.contentHeight + self.lineHeight
53
onResize = function (self, x, y, width, height)
54
self.names.y, self.values.y = y + self.spacing, y + self.spacing
55
self.names.height, self.values.height = height, height
57
self.names.x = x + self.spacing
58
self.names.width = width * 0.3 - self.spacing * 2
60
self.values.x = self.names.x + self.names.width + self.spacing
61
self.values.width = width * 0.7