REF don't build panels in module code

This commit is contained in:
Nathan Dwarshuis 2022-07-17 19:18:52 -04:00
parent aebb40db59
commit 8b3244c727
4 changed files with 15 additions and 33 deletions

View File

@ -683,7 +683,7 @@ return function(config)
style.closed_poly(thickness, CAIRO_LINE_JOIN_MITER), style.closed_poly(thickness, CAIRO_LINE_JOIN_MITER),
patterns.border patterns.border
), ),
patterns.panel patterns.panel.bg
) )
end end
@ -715,7 +715,12 @@ return function(config)
return pure.map(function(b) return mk_block(table.unpack(b)) end, bs) return pure.map(function(b) return mk_block(table.unpack(b)) end, bs)
end end
local flatten_sections = function(top, ...) local mk_separator = function(width, x, y)
local separator = M.make_separator(x, y, width)
return M.mk_acc_static(width, 0, pure.partial(line.draw, separator))
end
local flatten_sections = function(point, width, top, ...)
local f = function(acc, new) local f = function(acc, new)
if #new.blocks == 0 then if #new.blocks == 0 then
return acc return acc
@ -723,26 +728,24 @@ return function(config)
return new.blocks return new.blocks
else else
return pure.flatten( return pure.flatten(
{acc, {mk_block(new.sep_fun, true, new.top)}, new.blocks} {
acc,
{mk_block(pure.partial(mk_separator, width, point.x), true, new.top)},
new.blocks
}
) )
end end
end end
return pure.reduce(f, active_blocks(top), {...}) return pure.reduce(f, active_blocks(top), {...})
end end
M.mk_section = function(top, sep_fun, ...) M.mk_section = function(top, ...)
return { return {
top = top, top = top,
sep_fun = sep_fun,
blocks = active_blocks({...}) blocks = active_blocks({...})
} }
end end
M.mk_seperator = function(width, x, y)
local separator = M.make_separator(x, y, width)
return M.mk_acc_static(width, 0, pure.partial(line.draw, separator))
end
M.mk_acc = function(w, h, u, s, d) M.mk_acc = function(w, h, u, s, d)
return {w = w, h = h, obj = {u, s, d}} return {w = w, h = h, obj = {u, s, d}}
end end
@ -760,7 +763,7 @@ return function(config)
function(cr) M.draw_header(cr, obj) end function(cr) M.draw_header(cr, obj) end
) )
end end
local blocks = flatten_sections(top_blocks, ...) local blocks = flatten_sections(point, width, top_blocks, ...)
local r = pure.reduce( local r = pure.reduce(
_combine_blocks, _combine_blocks,
{w = 0, next_y = point.y, final_y = point.y, objs = {}}, {w = 0, next_y = point.y, final_y = point.y, objs = {}},

View File

@ -27,8 +27,6 @@ return function(config, main_state, common, width, point)
) )
end end
local mk_sep = pure.partial(common.mk_seperator, width, point.x)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- filesystem bar chart -- filesystem bar chart
@ -75,6 +73,6 @@ return function(config, main_state, common, width, point)
width = width, width = width,
update_wrapper = nil, update_wrapper = nil,
top = {{mk_smart, config.show_smart, SEPARATOR_SPACING}}, top = {{mk_smart, config.show_smart, SEPARATOR_SPACING}},
common.mk_section(SEPARATOR_SPACING, mk_sep, {mk_bars, true, 0}) common.mk_section(SEPARATOR_SPACING, {mk_bars, true, 0})
} }
end end

View File

@ -71,12 +71,6 @@ return function(update_freq, config, common, width, point)
return common.mk_acc(width, 0, update, static, dynamic) return common.mk_acc(width, 0, update, static, dynamic)
end end
local mk_sep = pure.partial(
common.mk_seperator,
width,
point.x
)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- gpu temperature -- gpu temperature
@ -223,17 +217,14 @@ return function(update_freq, config, common, width, point)
top = {{mk_status, true, SEPARATOR_SPACING}}, top = {{mk_status, true, SEPARATOR_SPACING}},
common.mk_section( common.mk_section(
SEPARATOR_SPACING, SEPARATOR_SPACING,
mk_sep,
{mk_temp, config.show_temp, SEPARATOR_SPACING} {mk_temp, config.show_temp, SEPARATOR_SPACING}
), ),
common.mk_section( common.mk_section(
SEPARATOR_SPACING, SEPARATOR_SPACING,
mk_sep,
{mk_clock, config.show_clock, SEPARATOR_SPACING} {mk_clock, config.show_clock, SEPARATOR_SPACING}
), ),
common.mk_section( common.mk_section(
SEPARATOR_SPACING, SEPARATOR_SPACING,
mk_sep,
{mk_gpu_util, config.show_gpu_util, PLOT_SEC_BREAK}, {mk_gpu_util, config.show_gpu_util, PLOT_SEC_BREAK},
{mk_mem_util, config.show_mem_util, PLOT_SEC_BREAK}, {mk_mem_util, config.show_mem_util, PLOT_SEC_BREAK},
{mk_vid_util, config.show_vid_util, 0} {mk_vid_util, config.show_vid_util, 0}

View File

@ -131,15 +131,6 @@ return function(update_freq, config, main_state, common, width, point)
) )
end end
-----------------------------------------------------------------------------
-- frequency
local mk_sep = pure.partial(
common.mk_seperator,
width,
point.x
)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- total load plot -- total load plot
@ -229,7 +220,6 @@ return function(update_freq, config, main_state, common, width, point)
}, },
common.mk_section( common.mk_section(
SEPARATOR_SPACING, SEPARATOR_SPACING,
mk_sep,
{mk_load_plot, config.show_plot, TABLE_SECTION_BREAK}, {mk_load_plot, config.show_plot, TABLE_SECTION_BREAK},
{mk_tbl, config.show_table, 0} {mk_tbl, config.show_table, 0}
) )