ENH move all geometry specs into the config.yaml file
This commit is contained in:
parent
9986969ed1
commit
6a49b2d2ce
14
config.yml
14
config.yml
|
@ -33,8 +33,16 @@ modules:
|
|||
layout:
|
||||
anchor: [12, 11]
|
||||
panels:
|
||||
- [[system, 19, graphics, 16, processor]]
|
||||
- columns:
|
||||
- {blocks: [system, 19, graphics, 16, processor], width: 436}
|
||||
margins: [20, 10]
|
||||
- 10
|
||||
- [[readwrite], 20, [network]]
|
||||
- columns:
|
||||
- {blocks: [readwrite], width: 436}
|
||||
- 20
|
||||
- {blocks: [network], width: 436}
|
||||
margins: [20, 10]
|
||||
- 10
|
||||
- [[pacman, 24, filesystem, 24, power, 19, memory]]
|
||||
- columns:
|
||||
- {blocks: [pacman, 24, filesystem, 24, power, 19, memory], width: 436}
|
||||
margins: [20, 10]
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
local i_o = require 'i_o'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
local pure = require 'pure'
|
||||
local impure = require 'impure'
|
||||
|
||||
-- ASSUME pathspecs will be at least 1 long
|
||||
return function(config, main_state, point)
|
||||
return function(config, main_state, width, point)
|
||||
local SPACING = 20
|
||||
local BAR_PAD = 100
|
||||
local SEPARATOR_SPACING = 20
|
||||
|
@ -14,12 +13,7 @@ return function(config, main_state, point)
|
|||
-- smartd
|
||||
|
||||
local mk_smart = function(y)
|
||||
local obj = common.make_text_row(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
'SMART Daemon'
|
||||
)
|
||||
local obj = common.make_text_row(point.x, y, width, 'SMART Daemon')
|
||||
local update = function()
|
||||
if main_state.trigger10 == 0 then
|
||||
local pid = i_o.execute_cmd('pidof smartd', nil, '*n')
|
||||
|
@ -27,7 +21,7 @@ return function(config, main_state, point)
|
|||
end
|
||||
end
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
0,
|
||||
update,
|
||||
pure.partial(common.text_row_draw_static, obj),
|
||||
|
@ -35,11 +29,7 @@ return function(config, main_state, point)
|
|||
)
|
||||
end
|
||||
|
||||
local mk_sep = pure.partial(
|
||||
common.mk_seperator,
|
||||
geometry.SECTION_WIDTH,
|
||||
point.x
|
||||
)
|
||||
local mk_sep = pure.partial(common.mk_seperator, width, point.x)
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- filesystem bar chart
|
||||
|
@ -55,7 +45,7 @@ return function(config, main_state, point)
|
|||
local obj = common.make_compound_bar(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
BAR_PAD,
|
||||
names,
|
||||
SPACING,
|
||||
|
@ -71,7 +61,7 @@ return function(config, main_state, point)
|
|||
end
|
||||
end
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
(#config.fs_paths - 1) * SPACING,
|
||||
update,
|
||||
pure.partial(common.compound_bar_draw_static, obj),
|
||||
|
@ -85,7 +75,7 @@ return function(config, main_state, point)
|
|||
return common.reduce_blocks_(
|
||||
'FILE SYSTEMS',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{{mk_smart, config.show_smart, SEPARATOR_SPACING}},
|
||||
common.mk_section(SEPARATOR_SPACING, mk_sep, {mk_bars, true, 0})
|
||||
)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
local pure = require 'pure'
|
||||
local i_o = require 'i_o'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
|
||||
return function(update_freq, config, point)
|
||||
return function(update_freq, config, width, point)
|
||||
local SEPARATOR_SPACING = 20
|
||||
local TEXT_SPACING = 20
|
||||
local PLOT_SEC_BREAK = 20
|
||||
|
@ -29,7 +28,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_tagged_maybe_percent_timeseries(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
PLOT_SEC_BREAK,
|
||||
label,
|
||||
|
@ -43,7 +42,7 @@ return function(update_freq, config, point)
|
|||
local static = pure.partial(common.tagged_percent_timeseries_draw_static, obj)
|
||||
local dynamic = pure.partial(common.tagged_percent_timeseries_draw_dynamic, obj)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||
update,
|
||||
static,
|
||||
|
@ -58,7 +57,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_text_row(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
'Status'
|
||||
)
|
||||
local update = function(s)
|
||||
|
@ -70,12 +69,12 @@ return function(update_freq, config, point)
|
|||
end
|
||||
local static = pure.partial(common.text_row_draw_static, obj)
|
||||
local dynamic = pure.partial(common.text_row_draw_dynamic, obj)
|
||||
return common.mk_acc(geometry.SECTION_WIDTH, 0, update, static, dynamic)
|
||||
return common.mk_acc(width, 0, update, static, dynamic)
|
||||
end
|
||||
|
||||
local mk_sep = pure.partial(
|
||||
common.mk_seperator,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
point.x
|
||||
)
|
||||
|
||||
|
@ -86,7 +85,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_threshold_text_row(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
'Internal Temperature',
|
||||
function(s)
|
||||
if s == -1 then return NA else return string.format('%s°C', s) end
|
||||
|
@ -100,7 +99,7 @@ return function(update_freq, config, point)
|
|||
)
|
||||
local static = pure.partial(common.threshold_text_row_draw_static, obj)
|
||||
local dynamic = pure.partial(common.threshold_text_row_draw_dynamic, obj)
|
||||
return common.mk_acc(geometry.SECTION_WIDTH, 0, update, static, dynamic)
|
||||
return common.mk_acc(width, 0, update, static, dynamic)
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
@ -110,7 +109,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_text_rows(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TEXT_SPACING,
|
||||
{'GPU Clock Speed', 'memory Clock Speed'}
|
||||
)
|
||||
|
@ -125,7 +124,7 @@ return function(update_freq, config, point)
|
|||
end
|
||||
local static = pure.partial(common.text_rows_draw_static, obj)
|
||||
local dynamic = pure.partial(common.text_rows_draw_dynamic, obj)
|
||||
return common.mk_acc(geometry.SECTION_WIDTH, TEXT_SPACING, update, static, dynamic)
|
||||
return common.mk_acc(width, TEXT_SPACING, update, static, dynamic)
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
@ -220,7 +219,7 @@ return function(update_freq, config, point)
|
|||
local rbs = common.reduce_blocks_(
|
||||
'NVIDIA GRAPHICS',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{{mk_status, true, SEPARATOR_SPACING}},
|
||||
common.mk_section(
|
||||
SEPARATOR_SPACING,
|
||||
|
|
|
@ -2,15 +2,9 @@ local timeseries = require 'timeseries'
|
|||
local text_table = require 'text_table'
|
||||
local i_o = require 'i_o'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
local pure = require 'pure'
|
||||
|
||||
return function(update_freq, config, point)
|
||||
-- local config = {
|
||||
-- show_stats = true,
|
||||
-- show_plot = true,
|
||||
-- show_table = true,
|
||||
-- }
|
||||
return function(update_freq, config, width, point)
|
||||
local DIAL_THICKNESS = 8
|
||||
local DIAL_RADIUS = 32
|
||||
local DIAL_SPACING = 40
|
||||
|
@ -33,7 +27,7 @@ return function(update_freq, config, point)
|
|||
local DIAL_DIAMETER = DIAL_RADIUS * 2 + DIAL_THICKNESS
|
||||
local SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_SPACING
|
||||
local CACHE_X = SWAP_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2
|
||||
local CACHE_WIDTH = point.x + geometry.SECTION_WIDTH - CACHE_X
|
||||
local CACHE_WIDTH = point.x + width - CACHE_X
|
||||
local format_percent = function(x)
|
||||
return string.format('%i%%', x)
|
||||
end
|
||||
|
@ -84,7 +78,7 @@ return function(update_freq, config, point)
|
|||
common.dial_draw_dynamic(swap, cr)
|
||||
common.text_rows_draw_dynamic(cache, cr)
|
||||
end
|
||||
return common.mk_acc(geometry.SECTION_WIDTH, DIAL_DIAMETER, update, static, dynamic)
|
||||
return common.mk_acc(width, DIAL_DIAMETER, update, static, dynamic)
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
@ -94,12 +88,12 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_percent_timeseries(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
update_freq
|
||||
)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
function(s) timeseries.update(obj, s.mem.used_percent) end,
|
||||
pure.partial(timeseries.draw_static, obj),
|
||||
|
@ -124,7 +118,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_text_table(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TABLE_HEIGHT,
|
||||
NUM_ROWS,
|
||||
'Mem (%)'
|
||||
|
@ -137,7 +131,7 @@ return function(update_freq, config, point)
|
|||
end
|
||||
end
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TABLE_HEIGHT,
|
||||
update,
|
||||
pure.partial(text_table.draw_static, obj),
|
||||
|
@ -188,7 +182,7 @@ return function(update_freq, config, point)
|
|||
local rbs = common.reduce_blocks_(
|
||||
'MEMORY',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{
|
||||
{mk_stats, config.show_stats, PLOT_SECTION_BREAK},
|
||||
{mk_plot, config.show_plot, TABLE_SECTION_BREAK},
|
||||
|
|
|
@ -2,10 +2,9 @@ local format = require 'format'
|
|||
local pure = require 'pure'
|
||||
local i_o = require 'i_o'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
local sys = require 'sys'
|
||||
|
||||
return function(update_freq, point)
|
||||
return function(update_freq, width, point)
|
||||
local PLOT_SEC_BREAK = 20
|
||||
local PLOT_HEIGHT = 56
|
||||
local INTERFACE_PATHS = sys.get_net_interface_paths()
|
||||
|
@ -42,7 +41,7 @@ return function(update_freq, point)
|
|||
local obj = common.make_rate_timeseries(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
value_format_function,
|
||||
common.converted_y_label_format_generator('b'),
|
||||
|
@ -53,7 +52,7 @@ return function(update_freq, point)
|
|||
state[key]
|
||||
)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||
function(s) common.update_rate_timeseries(obj, s[key]) end,
|
||||
pure.partial(common.tagged_scaled_timeseries_draw_static, obj),
|
||||
|
@ -70,7 +69,7 @@ return function(update_freq, point)
|
|||
local rbs = common.reduce_blocks_(
|
||||
'NETWORK',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{
|
||||
{mk_rx, true, PLOT_SEC_BREAK},
|
||||
{mk_tx, true, 0},
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
local common = require 'common'
|
||||
local pure = require 'pure'
|
||||
local geometry = require 'geometry'
|
||||
|
||||
return function(main_state, point)
|
||||
return function(main_state, width, point)
|
||||
local TEXT_SPACING = 20
|
||||
|
||||
local __string_match = string.match
|
||||
|
@ -12,7 +11,7 @@ return function(main_state, point)
|
|||
local obj = common.make_text_rows(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TEXT_SPACING,
|
||||
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
|
||||
)
|
||||
|
@ -34,7 +33,7 @@ return function(main_state, point)
|
|||
end
|
||||
end
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TEXT_SPACING * 4,
|
||||
update,
|
||||
pure.partial(common.text_rows_draw_static, obj),
|
||||
|
@ -45,7 +44,7 @@ return function(main_state, point)
|
|||
return common.reduce_blocks_(
|
||||
'PACMAN',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{{mk_stats, true, 0}}
|
||||
)
|
||||
end
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
local format = require 'format'
|
||||
local pure = require 'pure'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
local sys = require 'sys'
|
||||
|
||||
return function(update_freq, config, point)
|
||||
return function(update_freq, config, width, point)
|
||||
local TEXT_SPACING = 20
|
||||
local PLOT_SEC_BREAK = 20
|
||||
local PLOT_HEIGHT = 56
|
||||
|
@ -31,7 +30,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_rate_timeseries(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
format_rapl,
|
||||
power_label_function,
|
||||
|
@ -42,7 +41,7 @@ return function(update_freq, config, point)
|
|||
read_joules()
|
||||
)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||
function(_) common.update_rate_timeseries(obj, read_joules()) end,
|
||||
mk_static(obj),
|
||||
|
@ -81,7 +80,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_tagged_scaled_timeseries(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
format_ac,
|
||||
power_label_function,
|
||||
|
@ -91,7 +90,7 @@ return function(update_freq, config, point)
|
|||
update_freq
|
||||
)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||
function()
|
||||
common.tagged_scaled_timeseries_set(
|
||||
|
@ -110,7 +109,7 @@ return function(update_freq, config, point)
|
|||
return common.reduce_blocks_(
|
||||
'POWER',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
pure.concat(
|
||||
pure.map(mk_rate_blockspec, config.rapl_specs),
|
||||
-- TODO what happens if this is nil?
|
||||
|
|
|
@ -2,13 +2,12 @@ local compound_dial = require 'compound_dial'
|
|||
local text_table = require 'text_table'
|
||||
local i_o = require 'i_o'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
local cpu = require 'sys'
|
||||
local pure = require 'pure'
|
||||
|
||||
local __math_floor = math.floor
|
||||
|
||||
return function(update_freq, config, main_state, point)
|
||||
return function(update_freq, config, main_state, width, point)
|
||||
local DIAL_INNER_RADIUS = 30
|
||||
local DIAL_OUTER_RADIUS = 42
|
||||
local DIAL_THICKNESS = 5.5
|
||||
|
@ -63,7 +62,7 @@ return function(update_freq, config, main_state, point)
|
|||
-- TODO what happens when the number of cores changes?
|
||||
for c = 1, ncores do
|
||||
local dial_x = point.x + DIAL_OUTER_RADIUS +
|
||||
(geometry.SECTION_WIDTH - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3
|
||||
(width - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3
|
||||
local dial_y = y + DIAL_OUTER_RADIUS
|
||||
cores[c] = create_core(dial_x, dial_y)
|
||||
end
|
||||
|
@ -93,7 +92,7 @@ return function(update_freq, config, main_state, point)
|
|||
end
|
||||
end
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
DIAL_OUTER_RADIUS * 2,
|
||||
update,
|
||||
static,
|
||||
|
@ -109,7 +108,7 @@ return function(update_freq, config, main_state, point)
|
|||
local cpu_status = common.make_text_rows(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TEXT_SPACING,
|
||||
{'HWP Preference', 'Ave Freq'}
|
||||
)
|
||||
|
@ -125,7 +124,7 @@ return function(update_freq, config, main_state, point)
|
|||
local static = pure.partial(common.text_rows_draw_static, cpu_status)
|
||||
local dynamic = pure.partial(common.text_rows_draw_dynamic, cpu_status)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TEXT_SPACING,
|
||||
update,
|
||||
static,
|
||||
|
@ -138,7 +137,7 @@ return function(update_freq, config, main_state, point)
|
|||
|
||||
local mk_sep = pure.partial(
|
||||
common.mk_seperator,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
point.x
|
||||
)
|
||||
|
||||
|
@ -149,7 +148,7 @@ return function(update_freq, config, main_state, point)
|
|||
local total_load = common.make_tagged_percent_timeseries(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
PLOT_SECTION_BREAK,
|
||||
"Total Load",
|
||||
|
@ -165,7 +164,7 @@ return function(update_freq, config, main_state, point)
|
|||
local static = pure.partial(common.tagged_percent_timeseries_draw_static, total_load)
|
||||
local dynamic = pure.partial(common.tagged_percent_timeseries_draw_dynamic, total_load)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT + PLOT_SECTION_BREAK,
|
||||
update,
|
||||
static,
|
||||
|
@ -185,7 +184,7 @@ return function(update_freq, config, main_state, point)
|
|||
local tbl = common.make_text_table(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TABLE_HEIGHT,
|
||||
NUM_ROWS,
|
||||
'CPU (%)'
|
||||
|
@ -204,7 +203,7 @@ return function(update_freq, config, main_state, point)
|
|||
local static = pure.partial(text_table.draw_static, tbl)
|
||||
local dynamic = pure.partial(text_table.draw_dynamic, tbl)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TABLE_HEIGHT,
|
||||
update,
|
||||
static,
|
||||
|
@ -218,7 +217,7 @@ return function(update_freq, config, main_state, point)
|
|||
local rbs = common.reduce_blocks_(
|
||||
'PROCESSOR',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{
|
||||
{mk_cores, config.show_cores, TEXT_SPACING},
|
||||
{mk_hwp_freq, config.show_stats, SEPARATOR_SPACING},
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
local format = require 'format'
|
||||
local pure = require 'pure'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
local sys = require 'sys'
|
||||
|
||||
return function(update_freq, config, point)
|
||||
return function(update_freq, config, width, point)
|
||||
local PLOT_SEC_BREAK = 20
|
||||
local PLOT_HEIGHT = 56
|
||||
-- TODO currently this will find any block device
|
||||
|
@ -25,7 +24,7 @@ return function(update_freq, config, point)
|
|||
local obj = common.make_rate_timeseries(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT,
|
||||
format_value_function,
|
||||
common.converted_y_label_format_generator('B'),
|
||||
|
@ -37,7 +36,7 @@ return function(update_freq, config, point)
|
|||
)
|
||||
return common.mk_acc(
|
||||
-- TODO construct this more sanely without referring to hardcoded vars
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||
function() common.update_rate_timeseries(obj, state[key]) end,
|
||||
pure.partial(common.tagged_scaled_timeseries_draw_static, obj),
|
||||
|
@ -54,7 +53,7 @@ return function(update_freq, config, point)
|
|||
local rbs = common.reduce_blocks_(
|
||||
'INPUT / OUTPUT',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{
|
||||
{mk_reads, true, PLOT_SEC_BREAK},
|
||||
{mk_writes, true, 0},
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
local common = require 'common'
|
||||
local pure = require 'pure'
|
||||
local geometry = require 'geometry'
|
||||
local geom = require 'geom'
|
||||
local fill_rect = require 'fill_rect'
|
||||
|
||||
local reduce_modules_y = function(modlist, init_x, acc, new)
|
||||
local reduce_modules_y = function(modlist, init_x, width, acc, new)
|
||||
if type(new) == "number" then
|
||||
acc.next_y = acc.next_y + new
|
||||
else
|
||||
local r = modlist[new](geom.make_point(init_x, acc.next_y))
|
||||
local r = modlist[new](width, geom.make_point(init_x, acc.next_y))
|
||||
table.insert(acc.fgroups, {update = r.update, static = r.static, dynamic = r.dynamic})
|
||||
acc.next_x = math.max(acc.next_x, r.next_x)
|
||||
acc.next_y = r.next_y
|
||||
|
@ -21,9 +20,9 @@ local reduce_modules_x = function(modlist, init_y, acc, x_mods)
|
|||
acc.next_x = acc.next_x + x_mods
|
||||
else
|
||||
local r = pure.reduce(
|
||||
pure.partial(reduce_modules_y, modlist, acc.next_x),
|
||||
pure.partial(reduce_modules_y, modlist, acc.next_x, x_mods.width),
|
||||
{next_x = acc.next_x, next_y = init_y, fgroups = acc.fgroups},
|
||||
x_mods
|
||||
x_mods.blocks
|
||||
)
|
||||
acc.fgroups = r.fgroups
|
||||
acc.next_x = r.next_x
|
||||
|
@ -72,14 +71,17 @@ local build_surface = function(box, fs)
|
|||
return {x = cs_x, y = cs_y, s = cs}
|
||||
end
|
||||
|
||||
local reduce_static = function(mods, y, margins, acc, panel_mods)
|
||||
local reduce_static = function(mods, y, acc, panel_mods)
|
||||
if type(panel_mods) == "number" then
|
||||
acc.next_x = acc.next_x + panel_mods
|
||||
else
|
||||
local mpoint = geom.make_point(acc.next_x + margins.x, y + margins.y)
|
||||
local r = arrange_panel_modules(mods, mpoint, panel_mods)
|
||||
local w = r.width + margins.x * 2
|
||||
local h = r.height + margins.y * 2
|
||||
local margins = panel_mods.margins
|
||||
local margin_x = margins[1]
|
||||
local margin_y = margins[2]
|
||||
local mpoint = geom.make_point(acc.next_x + margin_x, y + margin_y)
|
||||
local r = arrange_panel_modules(mods, mpoint, panel_mods.columns)
|
||||
local w = r.width + margin_x * 2
|
||||
local h = r.height + margin_y * 2
|
||||
local pbox = geom.make_box(acc.next_x, y, w, h)
|
||||
acc.next_x = acc.next_x + w
|
||||
acc.static = pure.flatten({acc.static, {build_surface(pbox, r.static)}})
|
||||
|
@ -97,8 +99,7 @@ return function(point, mods, module_sets)
|
|||
pure.partial(
|
||||
reduce_static,
|
||||
mods,
|
||||
point.y,
|
||||
{x = geometry.PANEL_MARGIN_X, y = geometry.PANEL_MARGIN_Y}
|
||||
point.y
|
||||
),
|
||||
{next_x = point.x, static = {}, update = {}, dynamic = {}},
|
||||
module_sets
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
local i_o = require 'i_o'
|
||||
local pure = require 'pure'
|
||||
local common = require 'common'
|
||||
local geometry = require 'geometry'
|
||||
|
||||
return function(main_state, point)
|
||||
return function(main_state, width, point)
|
||||
local TEXT_SPACING = 20
|
||||
|
||||
local __string_match = string.match
|
||||
|
@ -12,7 +11,7 @@ return function(main_state, point)
|
|||
local obj = common.make_text_rows(
|
||||
point.x,
|
||||
y,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TEXT_SPACING,
|
||||
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
|
||||
)
|
||||
|
@ -33,7 +32,7 @@ return function(main_state, point)
|
|||
local static = pure.partial(common.text_rows_draw_static, obj)
|
||||
local dynamic = pure.partial(common.text_rows_draw_dynamic, obj)
|
||||
return common.mk_acc(
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
TEXT_SPACING * 3,
|
||||
update,
|
||||
static,
|
||||
|
@ -44,7 +43,7 @@ return function(main_state, point)
|
|||
return common.reduce_blocks_(
|
||||
'SYSTEM',
|
||||
point,
|
||||
geometry.SECTION_WIDTH,
|
||||
width,
|
||||
{{mk_stats, true, 0}}
|
||||
)
|
||||
end
|
||||
|
|
34
schema.yml
34
schema.yml
|
@ -124,25 +124,45 @@ properties:
|
|||
items:
|
||||
type: integer
|
||||
panels:
|
||||
description: either a panel (array) or padding between panels (int)
|
||||
description: either a panel (object) or padding between panels (int)
|
||||
type: array
|
||||
items:
|
||||
anyOf:
|
||||
- type: integer
|
||||
minimum: 0
|
||||
- type: array
|
||||
- type: object
|
||||
description: layout for a single panel
|
||||
required: [columns, margins]
|
||||
additionalProperties: false
|
||||
properties:
|
||||
margins:
|
||||
type: array
|
||||
minItems: 2
|
||||
maxItems: 2
|
||||
items:
|
||||
type: integer
|
||||
columns:
|
||||
description: |
|
||||
either a list of columns in a panel (array) or padding between
|
||||
columns (int)
|
||||
either the columns in this panel (object) or padding
|
||||
between columns (int)
|
||||
type: array
|
||||
minItems: 1
|
||||
items:
|
||||
anyOf:
|
||||
- type: integer
|
||||
minimum: 0
|
||||
- type: array
|
||||
- type: object
|
||||
required: [blocks, width]
|
||||
additionalProperties: false
|
||||
properties:
|
||||
width:
|
||||
description: the width of all modules in this column
|
||||
type: integer
|
||||
minimum: 0
|
||||
blocks:
|
||||
description: |
|
||||
either a list of modules in a panel column (array) or
|
||||
padding between modules
|
||||
either a module name (string) or padding (int)
|
||||
type: array
|
||||
minItems: 1
|
||||
items:
|
||||
anyOf:
|
||||
|
|
Loading…
Reference in New Issue