diff --git a/drawing/common.lua b/drawing/common.lua index f5d6836..1c59597 100644 --- a/drawing/common.lua +++ b/drawing/common.lua @@ -667,8 +667,19 @@ local non_false = function(xs) return pure.filter(function(x) return x ~= false end, xs) end -M.reduce_blocks_inner = function(f, y, blocks) - local r = pure.reduce(_combine_blocks, {y = y, objs = {}}, blocks) +M.reduce_blocks_inner = function(f, header, point, width, blocks) + local mk_header = function(y) + local obj = M.make_header(point.x, y, width, header) + return M.mk_acc_static( + obj.bottom_y - y, + function(cr) M.draw_header(cr, obj) end + ) + end + local r = pure.reduce( + _combine_blocks, + {y = point.y, objs = {}}, + {M.mk_block(mk_header, true, 0), table.unpack(blocks)} + ) local us, ss, ds = table.unpack(pure.unzip(r.objs)) return { y = r.y, @@ -694,14 +705,6 @@ M.mk_block = function(f, active, offset) return {f = f, active = active, offset = offset} end -M.mk_header = function(header_text, width, x, y) - local header = M.make_header(x, y, width, header_text) - return M.mk_acc_static( - header.bottom_y - y, - function(cr) M.draw_header(cr, header) end - ) -end - M.mk_seperator = function(width, x, y) local separator = M.make_separator(x, y, width) return M.mk_acc_static(0, pure.partial(line.draw, separator)) diff --git a/drawing/filesystem.lua b/drawing/filesystem.lua index d062b65..b7cd13f 100644 --- a/drawing/filesystem.lua +++ b/drawing/filesystem.lua @@ -9,16 +9,6 @@ return function(pathspecs, point) local BAR_PAD = 100 local SEPARATOR_SPACING = 20 - ----------------------------------------------------------------------------- - -- header - - local mk_header = pure.partial( - common.mk_header, - 'FILE SYSTEMS', - geometry.SECTION_WIDTH, - point.x - ) - ----------------------------------------------------------------------------- -- smartd @@ -88,9 +78,10 @@ return function(pathspecs, point) -- main functions return common.reduce_blocks_( - point.y, + 'FILE SYSTEMS', + point, + geometry.SECTION_WIDTH, { - common.mk_block(mk_header, true, 0), common.mk_block(mk_smart, true, 0), common.mk_block(mk_sep, true, SEPARATOR_SPACING), common.mk_block(mk_bars, true, SEPARATOR_SPACING), diff --git a/drawing/graphics.lua b/drawing/graphics.lua index 23239b9..d8e9790 100644 --- a/drawing/graphics.lua +++ b/drawing/graphics.lua @@ -45,16 +45,6 @@ return function(update_freq, point) return common.mk_acc(PLOT_HEIGHT + PLOT_SEC_BREAK, update, static, dynamic) end - ----------------------------------------------------------------------------- - -- header - - local mk_header = pure.partial( - common.mk_header, - 'NVIDIA GRAPHICS', - geometry.SECTION_WIDTH, - point.x - ) - ----------------------------------------------------------------------------- -- gpu status @@ -222,9 +212,10 @@ return function(update_freq, point) -- main drawing functions local rbs = common.reduce_blocks_( - point.y, + 'NVIDIA GRAPHICS', + point, + geometry.SECTION_WIDTH, { - common.mk_block(mk_header, true, 0), common.mk_block(mk_status, true, 0), common.mk_block(mk_sep, true, SEPARATOR_SPACING), common.mk_block(mk_temp, true, TEXT_SPACING), diff --git a/drawing/memory.lua b/drawing/memory.lua index bb46c43..ec00e6d 100644 --- a/drawing/memory.lua +++ b/drawing/memory.lua @@ -20,16 +20,6 @@ return function(update_freq, point) local __string_match = string.match local __math_floor = math.floor - ----------------------------------------------------------------------------- - -- header - - local mk_header = pure.partial( - common.mk_header, - 'MEMORY', - geometry.SECTION_WIDTH, - point.x - ) - ----------------------------------------------------------------------------- -- mem stats (dial + text) @@ -189,9 +179,10 @@ return function(update_freq, point) -- main functions local rbs = common.reduce_blocks_( - point.y, + 'MEMORY', + point, + geometry.SECTION_WIDTH, { - common.mk_block(mk_header, true, 0), common.mk_block(mk_stats, true, 0), common.mk_block(mk_plot, true, PLOT_SECTION_BREAK), common.mk_block(mk_tbl, true, TABLE_SECTION_BREAK), diff --git a/drawing/network.lua b/drawing/network.lua index 670f25f..4615ce7 100644 --- a/drawing/network.lua +++ b/drawing/network.lua @@ -35,6 +35,9 @@ return function(update_freq, point) return format.precision_round_to_string(value, 3)..' '..unit..'b/s' end + ----------------------------------------------------------------------------- + -- down/up plots + local mk_plot = function(label, key, y) local obj = common.make_rate_timeseries( point.x, @@ -57,19 +60,6 @@ return function(update_freq, point) ) end - ----------------------------------------------------------------------------- - -- header - - local mk_header = pure.partial( - common.mk_header, - 'NETWORK', - geometry.SECTION_WIDTH, - point.x - ) - - ----------------------------------------------------------------------------- - -- down/up plots - local mk_rx = pure.partial(mk_plot, 'Download', 'rx_bits') local mk_tx = pure.partial(mk_plot, 'Upload', 'tx_bits') @@ -77,9 +67,10 @@ return function(update_freq, point) -- main drawing functions local rbs = common.reduce_blocks_( - point.y, + 'NETWORK', + point, + geometry.SECTION_WIDTH, { - common.mk_block(mk_header, true, 0), common.mk_block(mk_rx, true, 0), common.mk_block(mk_tx, true, PLOT_SEC_BREAK), } diff --git a/drawing/pacman.lua b/drawing/pacman.lua index fb5c3e3..d2354d8 100644 --- a/drawing/pacman.lua +++ b/drawing/pacman.lua @@ -8,13 +8,6 @@ return function(point) local __string_match = string.match local __string_gmatch = string.gmatch - local mk_header = pure.partial( - common.mk_header, - 'PACMAN', - geometry.SECTION_WIDTH, - point.x - ) - local mk_stats = function(y) local obj = common.make_text_rows( point.x, @@ -46,10 +39,9 @@ return function(point) end return common.reduce_blocks_( - point.y, - { - common.mk_block(mk_header, true, 0), - common.mk_block(mk_stats, true, 0), - } + 'PACMAN', + point, + geometry.SECTION_WIDTH, + {common.mk_block(mk_stats, true, 0)} ) end diff --git a/drawing/power.lua b/drawing/power.lua index ee6aa02..757cdf5 100644 --- a/drawing/power.lua +++ b/drawing/power.lua @@ -60,16 +60,6 @@ return function(update_freq, battery, point) ) end - ----------------------------------------------------------------------------- - -- header - - local mk_header = pure.partial( - common.mk_header, - 'POWER', - geometry.SECTION_WIDTH, - point.x - ) - ----------------------------------------------------------------------------- -- package 0 power plot @@ -118,9 +108,10 @@ return function(update_freq, battery, point) -- main functions return common.reduce_blocks_( - point.y, + 'POWER', + point, + geometry.SECTION_WIDTH, { - common.mk_block(mk_header, true, 0), common.mk_block(mk_pkg0, true, 0), common.mk_block(mk_dram, true, TEXT_SPACING), common.mk_block(mk_bat, true, TEXT_SPACING), diff --git a/drawing/processor.lua b/drawing/processor.lua index 38a41fb..bb62817 100644 --- a/drawing/processor.lua +++ b/drawing/processor.lua @@ -23,16 +23,6 @@ return function(update_freq, point) local TABLE_SECTION_BREAK = 20 local TABLE_HEIGHT = 114 - ----------------------------------------------------------------------------- - -- header - - local mk_header = pure.partial( - common.mk_header, - 'PROCESSOR', - geometry.SECTION_WIDTH, - point.x - ) - ----------------------------------------------------------------------------- -- cores (loads and temps) @@ -213,9 +203,10 @@ return function(update_freq, point) -- main functions local rbs = common.reduce_blocks( - point.y, + 'PROCESSOR', + point, + geometry.SECTION_WIDTH, { - common.mk_block(mk_header, true, 0), common.mk_block(mk_cores, true, 0), common.mk_block(mk_hwp_freq, true, TEXT_SPACING), common.mk_block(mk_sep, true, SEPARATOR_SPACING), diff --git a/drawing/system.lua b/drawing/system.lua index b893a79..b10b2fc 100644 --- a/drawing/system.lua +++ b/drawing/system.lua @@ -8,13 +8,6 @@ return function(point) local __string_match = string.match - local mk_header = pure.partial( - common.mk_header, - 'SYSTEM', - geometry.SECTION_WIDTH, - point.x - ) - local mk_stats = function(y) local obj = common.make_text_rows( point.x, @@ -40,10 +33,9 @@ return function(point) end return common.reduce_blocks_( - point.y, - { - common.mk_block(mk_header, true, 0), - common.mk_block(mk_stats, true, 0), - } + 'SYSTEM', + point, + geometry.SECTION_WIDTH, + {common.mk_block(mk_stats, true, 0)} ) end