decouple icon from text, see #19

This commit is contained in:
airstruck
2016-02-23 01:29:28 -05:00
parent 774d2856c1
commit 5f67a77114
11 changed files with 295 additions and 82 deletions

32
luigi/cleaner.lua Normal file
View File

@@ -0,0 +1,32 @@
local Cleaner = {}
local marked = {}
local watched = setmetatable({}, { __mode = 'k' })
function Cleaner.mark (t, key)
local length = #marked
local keys = watched[t]
if not keys then
keys = {}
watched[t] = keys
elseif keys[key] then
return
end
keys[key] = true
local i = length + 1
marked[i] = t
marked[i + 1] = key
end
function Cleaner.clean ()
for i = #marked - 1, 1, -2 do
local t = marked[i]
local key = marked[i + 1]
t[key] = nil
marked[i] = nil
marked[i + 1] = nil
watched[t][key] = nil
end
end
return Cleaner