use consistent font height for header lines, align service names to the right, move output to full-width

This commit is contained in:
Franzi 2023-03-06 06:40:50 +01:00
parent 5a1658478a
commit 0773db6933
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 15 additions and 19 deletions

View file

@ -65,19 +65,15 @@ function node.render()
local y = CONFIG.output_size*2 local y = CONFIG.output_size*2
for idx, serv in ipairs(services.services) do for idx, serv in ipairs(services.services) do
host_size = CONFIG.header_size header_font_size = CONFIG.header_size
svc_size = CONFIG.header_size
margin = math.min(CONFIG.output_size, 20) margin = math.min(CONFIG.output_size, 20)
while CONFIG.header_font:width(serv.host, host_size) > real_width/2-margin*1.5 do header_width = real_width-20-margin*2
host_size = host_size - 1 while (CONFIG.header_font:width(serv.host, header_font_size) + CONFIG.header_font:width(serv.service, header_font_size)) > header_width do
end header_font_size = header_font_size - 1
while CONFIG.header_font:width(serv.service, svc_size) > real_width/2-margin*1.5 do
svc_size = svc_size - 1
end end
my_height = (#serv.output*CONFIG.output_size*1.5)+margin*2+CONFIG.header_size+CONFIG.output_size*0.5 my_height = (#serv.output*CONFIG.output_size*1.5) + margin*3 + CONFIG.header_size
indent = math.min(host_width, real_width/2-margin*1.5)+margin*2
if serv.type == 0 then if serv.type == 0 then
c_soft[serv.state]:draw(0, y, real_width, y+my_height) c_soft[serv.state]:draw(0, y, real_width, y+my_height)
@ -85,21 +81,21 @@ function node.render()
c_hard[serv.state]:draw(0, y, real_width, y+my_height) c_hard[serv.state]:draw(0, y, real_width, y+my_height)
end end
y = y+margin y = y + margin
CONFIG.header_font:write(10, y, serv.host, host_size, c_text[serv.state][1],c_text[serv.state][2],c_text[serv.state][2],1) service_x = real_width - margin - CONFIG.header_font:width(serv.service, header_font_size)
CONFIG.header_font:write(indent, y, serv.service, svc_size, c_text[serv.state][1],c_text[serv.state][2],c_text[serv.state][3],1)
y = y+CONFIG.header_size+CONFIG.output_size*0.5 CONFIG.header_font:write(margin, y, serv.host, header_font_size, c_text[serv.state][1],c_text[serv.state][2],c_text[serv.state][2],1)
CONFIG.header_font:write(service_x, y, serv.service, header_font_size, c_text[serv.state][1],c_text[serv.state][2],c_text[serv.state][3],1)
CONFIG.output_font:write(10, y, serv.ack, CONFIG.output_size, c_text[serv.state][1],c_text[serv.state][2],c_text[serv.state][2],1) y = y + CONFIG.header_size + margin
for idx, line in ipairs(serv.output) do for idx, line in ipairs(serv.output) do
CONFIG.output_font:write(indent, y, line, CONFIG.output_size, c_text[serv.state][1],c_text[serv.state][2],c_text[serv.state][3],1) CONFIG.output_font:write(margin, y, line, CONFIG.output_size, c_text[serv.state][1],c_text[serv.state][2],c_text[serv.state][3],1)
y = y+CONFIG.output_size*1.5 y = y + CONFIG.output_size * 1.5
end end
y = y+margin+2 y = y + margin + 2
if y > real_height then if y > real_height then
break break

View file

@ -80,7 +80,7 @@ def regenerate():
if not CONFIG['show_ack']: if not CONFIG['show_ack']:
continue continue
ack = 'ACKNOWLEDGED' ack = '[ACK] '
else: else:
ack = '' ack = ''
@ -88,7 +88,7 @@ def regenerate():
continue continue
services['services'].append({ services['services'].append({
'host': host['attrs']['display_name'], 'host': ack + host['attrs']['display_name'],
'service': '-- HOST --', 'service': '-- HOST --',
'state': 2, 'state': 2,
'type': int(host['attrs']['state_type']), 'type': int(host['attrs']['state_type']),