REF move header setup code to common
This commit is contained in:
parent
a1f25285ac
commit
1e09124a0c
|
@ -667,8 +667,19 @@ local non_false = function(xs)
|
||||||
return pure.filter(function(x) return x ~= false end, xs)
|
return pure.filter(function(x) return x ~= false end, xs)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.reduce_blocks_inner = function(f, y, blocks)
|
M.reduce_blocks_inner = function(f, header, point, width, blocks)
|
||||||
local r = pure.reduce(_combine_blocks, {y = y, objs = {}}, 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))
|
local us, ss, ds = table.unpack(pure.unzip(r.objs))
|
||||||
return {
|
return {
|
||||||
y = r.y,
|
y = r.y,
|
||||||
|
@ -694,14 +705,6 @@ M.mk_block = function(f, active, offset)
|
||||||
return {f = f, active = active, offset = offset}
|
return {f = f, active = active, offset = offset}
|
||||||
end
|
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)
|
M.mk_seperator = function(width, x, y)
|
||||||
local separator = M.make_separator(x, y, width)
|
local separator = M.make_separator(x, y, width)
|
||||||
return M.mk_acc_static(0, pure.partial(line.draw, separator))
|
return M.mk_acc_static(0, pure.partial(line.draw, separator))
|
||||||
|
|
|
@ -9,16 +9,6 @@ return function(pathspecs, point)
|
||||||
local BAR_PAD = 100
|
local BAR_PAD = 100
|
||||||
local SEPARATOR_SPACING = 20
|
local SEPARATOR_SPACING = 20
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- header
|
|
||||||
|
|
||||||
local mk_header = pure.partial(
|
|
||||||
common.mk_header,
|
|
||||||
'FILE SYSTEMS',
|
|
||||||
geometry.SECTION_WIDTH,
|
|
||||||
point.x
|
|
||||||
)
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- smartd
|
-- smartd
|
||||||
|
|
||||||
|
@ -88,9 +78,10 @@ return function(pathspecs, point)
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
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_smart, true, 0),
|
||||||
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, SEPARATOR_SPACING),
|
||||||
|
|
|
@ -45,16 +45,6 @@ return function(update_freq, point)
|
||||||
return common.mk_acc(PLOT_HEIGHT + PLOT_SEC_BREAK, update, static, dynamic)
|
return common.mk_acc(PLOT_HEIGHT + PLOT_SEC_BREAK, update, static, dynamic)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- header
|
|
||||||
|
|
||||||
local mk_header = pure.partial(
|
|
||||||
common.mk_header,
|
|
||||||
'NVIDIA GRAPHICS',
|
|
||||||
geometry.SECTION_WIDTH,
|
|
||||||
point.x
|
|
||||||
)
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- gpu status
|
-- gpu status
|
||||||
|
|
||||||
|
@ -222,9 +212,10 @@ return function(update_freq, point)
|
||||||
-- main drawing functions
|
-- main drawing functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
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_status, true, 0),
|
||||||
common.mk_block(mk_sep, true, SEPARATOR_SPACING),
|
common.mk_block(mk_sep, true, SEPARATOR_SPACING),
|
||||||
common.mk_block(mk_temp, true, TEXT_SPACING),
|
common.mk_block(mk_temp, true, TEXT_SPACING),
|
||||||
|
|
|
@ -20,16 +20,6 @@ return function(update_freq, point)
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
local __math_floor = math.floor
|
local __math_floor = math.floor
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- header
|
|
||||||
|
|
||||||
local mk_header = pure.partial(
|
|
||||||
common.mk_header,
|
|
||||||
'MEMORY',
|
|
||||||
geometry.SECTION_WIDTH,
|
|
||||||
point.x
|
|
||||||
)
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- mem stats (dial + text)
|
-- mem stats (dial + text)
|
||||||
|
|
||||||
|
@ -189,9 +179,10 @@ return function(update_freq, point)
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
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_stats, true, 0),
|
||||||
common.mk_block(mk_plot, true, PLOT_SECTION_BREAK),
|
common.mk_block(mk_plot, true, PLOT_SECTION_BREAK),
|
||||||
common.mk_block(mk_tbl, true, TABLE_SECTION_BREAK),
|
common.mk_block(mk_tbl, true, TABLE_SECTION_BREAK),
|
||||||
|
|
|
@ -35,6 +35,9 @@ return function(update_freq, point)
|
||||||
return format.precision_round_to_string(value, 3)..' '..unit..'b/s'
|
return format.precision_round_to_string(value, 3)..' '..unit..'b/s'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- down/up plots
|
||||||
|
|
||||||
local mk_plot = function(label, key, y)
|
local mk_plot = function(label, key, y)
|
||||||
local obj = common.make_rate_timeseries(
|
local obj = common.make_rate_timeseries(
|
||||||
point.x,
|
point.x,
|
||||||
|
@ -57,19 +60,6 @@ return function(update_freq, point)
|
||||||
)
|
)
|
||||||
end
|
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_rx = pure.partial(mk_plot, 'Download', 'rx_bits')
|
||||||
local mk_tx = pure.partial(mk_plot, 'Upload', 'tx_bits')
|
local mk_tx = pure.partial(mk_plot, 'Upload', 'tx_bits')
|
||||||
|
|
||||||
|
@ -77,9 +67,10 @@ return function(update_freq, point)
|
||||||
-- main drawing functions
|
-- main drawing functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
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_rx, true, 0),
|
||||||
common.mk_block(mk_tx, true, PLOT_SEC_BREAK),
|
common.mk_block(mk_tx, true, PLOT_SEC_BREAK),
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,6 @@ return function(point)
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
local __string_gmatch = string.gmatch
|
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 mk_stats = function(y)
|
||||||
local obj = common.make_text_rows(
|
local obj = common.make_text_rows(
|
||||||
point.x,
|
point.x,
|
||||||
|
@ -46,10 +39,9 @@ return function(point)
|
||||||
end
|
end
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
return common.reduce_blocks_(
|
||||||
point.y,
|
'PACMAN',
|
||||||
{
|
point,
|
||||||
common.mk_block(mk_header, true, 0),
|
geometry.SECTION_WIDTH,
|
||||||
common.mk_block(mk_stats, true, 0),
|
{common.mk_block(mk_stats, true, 0)}
|
||||||
}
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,16 +60,6 @@ return function(update_freq, battery, point)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- header
|
|
||||||
|
|
||||||
local mk_header = pure.partial(
|
|
||||||
common.mk_header,
|
|
||||||
'POWER',
|
|
||||||
geometry.SECTION_WIDTH,
|
|
||||||
point.x
|
|
||||||
)
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- package 0 power plot
|
-- package 0 power plot
|
||||||
|
|
||||||
|
@ -118,9 +108,10 @@ return function(update_freq, battery, point)
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
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_pkg0, true, 0),
|
||||||
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, TEXT_SPACING),
|
||||||
|
|
|
@ -23,16 +23,6 @@ return function(update_freq, point)
|
||||||
local TABLE_SECTION_BREAK = 20
|
local TABLE_SECTION_BREAK = 20
|
||||||
local TABLE_HEIGHT = 114
|
local TABLE_HEIGHT = 114
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
-- header
|
|
||||||
|
|
||||||
local mk_header = pure.partial(
|
|
||||||
common.mk_header,
|
|
||||||
'PROCESSOR',
|
|
||||||
geometry.SECTION_WIDTH,
|
|
||||||
point.x
|
|
||||||
)
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- cores (loads and temps)
|
-- cores (loads and temps)
|
||||||
|
|
||||||
|
@ -213,9 +203,10 @@ return function(update_freq, point)
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks(
|
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_cores, true, 0),
|
||||||
common.mk_block(mk_hwp_freq, true, TEXT_SPACING),
|
common.mk_block(mk_hwp_freq, true, TEXT_SPACING),
|
||||||
common.mk_block(mk_sep, true, SEPARATOR_SPACING),
|
common.mk_block(mk_sep, true, SEPARATOR_SPACING),
|
||||||
|
|
|
@ -8,13 +8,6 @@ return function(point)
|
||||||
|
|
||||||
local __string_match = string.match
|
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 mk_stats = function(y)
|
||||||
local obj = common.make_text_rows(
|
local obj = common.make_text_rows(
|
||||||
point.x,
|
point.x,
|
||||||
|
@ -40,10 +33,9 @@ return function(point)
|
||||||
end
|
end
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
return common.reduce_blocks_(
|
||||||
point.y,
|
'SYSTEM',
|
||||||
{
|
point,
|
||||||
common.mk_block(mk_header, true, 0),
|
geometry.SECTION_WIDTH,
|
||||||
common.mk_block(mk_stats, true, 0),
|
{common.mk_block(mk_stats, true, 0)}
|
||||||
}
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue