REF make pacman module use setup framework
This commit is contained in:
parent
862241af6b
commit
a1f25285ac
|
@ -1,4 +1,5 @@
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
|
local pure = require 'pure'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
|
|
||||||
return function(point)
|
return function(point)
|
||||||
|
@ -7,44 +8,48 @@ return function(point)
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
local __string_gmatch = string.gmatch
|
local __string_gmatch = string.gmatch
|
||||||
|
|
||||||
local header = common.make_header(
|
local mk_header = pure.partial(
|
||||||
point.x,
|
common.mk_header,
|
||||||
point.y,
|
'PACMAN',
|
||||||
geometry.SECTION_WIDTH,
|
geometry.SECTION_WIDTH,
|
||||||
'PACMAN'
|
point.x
|
||||||
)
|
)
|
||||||
|
|
||||||
local rows = common.make_text_rows(
|
local mk_stats = function(y)
|
||||||
|
local obj = common.make_text_rows(
|
||||||
point.x,
|
point.x,
|
||||||
header.bottom_y,
|
y,
|
||||||
geometry.SECTION_WIDTH,
|
geometry.SECTION_WIDTH,
|
||||||
TEXT_SPACING,
|
TEXT_SPACING,
|
||||||
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
|
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
|
||||||
)
|
)
|
||||||
|
|
||||||
local update = function(pacman_stats)
|
local update = function(pacman_stats)
|
||||||
local stats = __string_match(pacman_stats, '%d+%s+[^%s]+%s+[^%s]+%s+(.*)$')
|
local stats = __string_match(pacman_stats, '%d+%s+[^%s]+%s+[^%s]+%s+(.*)$')
|
||||||
if stats then
|
if stats then
|
||||||
local i = 1
|
local i = 1
|
||||||
for v in __string_gmatch(stats, '%d+') do
|
for v in __string_gmatch(stats, '%d+') do
|
||||||
common.text_rows_set(rows, i, v)
|
common.text_rows_set(obj, i, v)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
common.text_rows_set(rows, i, 'N/A')
|
common.text_rows_set(obj, i, 'N/A')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return common.mk_acc(
|
||||||
|
TEXT_SPACING * 4,
|
||||||
|
update,
|
||||||
|
pure.partial(common.text_rows_draw_static, obj),
|
||||||
|
pure.partial(common.text_rows_draw_dynamic, obj)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
local draw_static = function(cr)
|
return common.reduce_blocks_(
|
||||||
common.draw_header(cr, header)
|
point.y,
|
||||||
common.text_rows_draw_static(rows, cr)
|
{
|
||||||
end
|
common.mk_block(mk_header, true, 0),
|
||||||
|
common.mk_block(mk_stats, true, 0),
|
||||||
local draw_dynamic = function(cr)
|
}
|
||||||
common.text_rows_draw_dynamic(rows, cr)
|
)
|
||||||
end
|
|
||||||
|
|
||||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue