diff --git a/inspect.lua b/inspect.lua index edb8fb0..6981bca 100644 --- a/inspect.lua +++ b/inspect.lua @@ -1,4 +1,6 @@ local listview = require "listview" +local winhlp = require "winhlp" + local keys = {[1]="a", [2]="c"} local obj = {a="b", c="d"} local frame = term.current() @@ -20,7 +22,7 @@ end local function fetch(wait_for) local currentIdx = 1 for i, key in pairs(keys) do - listview.updateItemAt(currentIdx, tostring(key)..": "..tostring(obj[key])) + listview.updateItemAt(currentIdx, {key=key, value=obj[key]}) currentIdx = currentIdx + 1 end listview.clearFrom(currentIdx) @@ -34,10 +36,16 @@ local function estimatedHeight() return #keys end -local function drawLine(termlike, line) +local function drawLine(termlike, pair) termlike.setBackgroundColor(colors.black) + termlike.setTextColor(colors.yellow) + termlike.write(tostring(pair.key)) + termlike.setTextColor(colors.white) - termlike.write(line) + local value = tostring(pair.value) + local padding = winhlp.alignRightPadding(termlike, #value + 1) + termlike.write(string.format("%" .. padding .. "s", " ")) + termlike.write(value) end listview.setDrawEntryFunc(drawLine)