ENH dynamically space module blocks

This commit is contained in:
Nathan Dwarshuis 2022-07-16 14:30:26 -04:00
parent 3046cad9bc
commit f1438af7ce
7 changed files with 23 additions and 22 deletions

View File

@ -656,10 +656,11 @@ end
local _combine_blocks = function(acc, new) local _combine_blocks = function(acc, new)
if new.active == true then if new.active == true then
local n = new.f(acc.y + new.offset) local n = new.f(acc.next_y)
table.insert(acc.objs, n.obj) table.insert(acc.objs, n.obj)
acc.w = math.max(acc.w, n.w) acc.w = math.max(acc.w, n.w)
acc.y = acc.y + n.h + new.offset acc.final_y = acc.next_y + n.h
acc.next_y = acc.final_y + new.offset
end end
return acc return acc
end end
@ -679,13 +680,13 @@ M.reduce_blocks_inner = function(f, header, point, width, blocks)
end end
local r = pure.reduce( local r = pure.reduce(
_combine_blocks, _combine_blocks,
{w = 0, y = point.y, objs = {}}, {w = 0, next_y = point.y, final_y = point.y, objs = {}},
{M.mk_block(mk_header, true, 0), table.unpack(blocks)} {M.mk_block(mk_header, true, 0), table.unpack(blocks)}
) )
local us, ss, ds = table.unpack(pure.unzip(r.objs)) local us, ss, ds = table.unpack(pure.unzip(r.objs))
return { return {
next_x = point.x + r.w, next_x = point.x + r.w,
next_y = r.y, next_y = r.final_y,
update = f(table.unpack(non_false(pure.reverse(us)))), update = f(table.unpack(non_false(pure.reverse(us)))),
static = pure.sequence(table.unpack(ss)), static = pure.sequence(table.unpack(ss)),
dynamic = pure.sequence(table.unpack(non_false(ds))) dynamic = pure.sequence(table.unpack(non_false(ds)))

View File

@ -84,9 +84,9 @@ return function(pathspecs, main_state, point)
point, point,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
{ {
common.mk_block(mk_smart, true, 0), common.mk_block(mk_smart, true, SEPARATOR_SPACING),
common.mk_block(mk_sep, true, SEPARATOR_SPACING), common.mk_block(mk_sep, true, SEPARATOR_SPACING),
common.mk_block(mk_bars, true, SEPARATOR_SPACING), common.mk_block(mk_bars, true, 0),
} }
) )
end end

View File

@ -222,15 +222,15 @@ return function(update_freq, point)
point, point,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
{ {
common.mk_block(mk_status, true, 0), common.mk_block(mk_status, true, SEPARATOR_SPACING),
common.mk_block(mk_sep, true, SEPARATOR_SPACING), common.mk_block(mk_sep, true, TEXT_SPACING),
common.mk_block(mk_temp, true, TEXT_SPACING), common.mk_block(mk_temp, true, SEPARATOR_SPACING),
common.mk_block(mk_sep, true, SEPARATOR_SPACING), common.mk_block(mk_sep, true, SEPARATOR_SPACING),
common.mk_block(mk_clock, true, SEPARATOR_SPACING), common.mk_block(mk_clock, true, SEPARATOR_SPACING),
common.mk_block(mk_sep, true, SEPARATOR_SPACING), common.mk_block(mk_sep, true, PLOT_SEC_BREAK),
common.mk_block(mk_gpu_util, true, PLOT_SEC_BREAK), common.mk_block(mk_gpu_util, true, PLOT_SEC_BREAK),
common.mk_block(mk_mem_util, true, PLOT_SEC_BREAK), common.mk_block(mk_mem_util, true, PLOT_SEC_BREAK),
common.mk_block(mk_vid_util, true, PLOT_SEC_BREAK) common.mk_block(mk_vid_util, true, 0)
} }
) )
return pure.map_at("update", function(f) return function(_) f(update_state()) end end, rbs) return pure.map_at("update", function(f) return function(_) f(update_state()) end end, rbs)

View File

@ -185,9 +185,9 @@ return function(update_freq, point)
point, point,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
{ {
common.mk_block(mk_stats, true, 0), common.mk_block(mk_stats, true, PLOT_SECTION_BREAK),
common.mk_block(mk_plot, true, PLOT_SECTION_BREAK), common.mk_block(mk_plot, true, TABLE_SECTION_BREAK),
common.mk_block(mk_tbl, true, TABLE_SECTION_BREAK), common.mk_block(mk_tbl, true, 0),
} }
) )
return pure.map_at("update", function(f) return function(_) f(read_state()) end end, rbs) return pure.map_at("update", function(f) return function(_) f(read_state()) end end, rbs)

View File

@ -117,9 +117,9 @@ return function(update_freq, battery, main_state, point)
point, point,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
{ {
common.mk_block(mk_pkg0, true, 0), common.mk_block(mk_pkg0, true, TEXT_SPACING),
common.mk_block(mk_dram, true, TEXT_SPACING), common.mk_block(mk_dram, true, TEXT_SPACING),
common.mk_block(mk_bat, true, TEXT_SPACING), common.mk_block(mk_bat, true, 0),
} }
) )
end end

View File

@ -231,11 +231,11 @@ return function(update_freq, main_state, point)
point, point,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
{ {
common.mk_block(mk_cores, true, 0), common.mk_block(mk_cores, true, TEXT_SPACING),
common.mk_block(mk_hwp_freq, true, TEXT_SPACING), common.mk_block(mk_hwp_freq, true, SEPARATOR_SPACING),
common.mk_block(mk_sep, true, SEPARATOR_SPACING), common.mk_block(mk_sep, true, SEPARATOR_SPACING),
common.mk_block(mk_load_plot, true, SEPARATOR_SPACING), common.mk_block(mk_load_plot, true, TABLE_SECTION_BREAK),
common.mk_block(mk_tbl, true, TABLE_SECTION_BREAK) common.mk_block(mk_tbl, true, 0)
} }
) )

View File

@ -56,8 +56,8 @@ return function(update_freq, devices, point)
point, point,
geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
{ {
common.mk_block(mk_reads, true, 0), common.mk_block(mk_reads, true, PLOT_SEC_BREAK),
common.mk_block(mk_writes, true, PLOT_SEC_BREAK), common.mk_block(mk_writes, true, 0),
} }
) )