#63 cleanup and assertions

This commit is contained in:
Mikayla Fischler
2022-06-11 17:06:32 -04:00
parent 4488a0594f
commit 89437b2be9
12 changed files with 46 additions and 23 deletions

View File

@@ -13,11 +13,14 @@ local element = require("graphics.element")
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field height? integer parent height if omitted
---@field fg_bg cpair foreground/background colors
---@field fg_bg? cpair foreground/background colors
-- new push button
---@param args push_button_args
local function push_button(args)
assert(type(args.text) == "string", "graphics.elements.button_push: text is a required field")
assert(type(args.callback) == "function", "graphics.elements.button_push: callback is a required field")
local text_width = string.len(args.text)
args.width = math.max(text_width + 2, args.min_width)