code cleanup
This commit is contained in:
@@ -44,8 +44,9 @@ local function data(args)
|
||||
e.window.setCursorPos(1, 1)
|
||||
e.window.write(args.label)
|
||||
|
||||
local label_len = string.len(args.label)
|
||||
local data_start = 1
|
||||
local value_color = e.fg_bg.fgd
|
||||
local label_len = string.len(args.label)
|
||||
local data_start = 1
|
||||
local clear_width = args.width
|
||||
|
||||
if label_len > 0 then
|
||||
@@ -53,8 +54,6 @@ local function data(args)
|
||||
clear_width = args.width - (label_len + 1)
|
||||
end
|
||||
|
||||
local value_color = e.fg_bg.fgd
|
||||
|
||||
-- on state change
|
||||
---@param value any new value
|
||||
function e.on_update(value)
|
||||
|
||||
@@ -56,7 +56,7 @@ local function listbox(args)
|
||||
local mouse_last_y = 0 -- last reported y coordinate of drag
|
||||
|
||||
-- draw scroll bar arrows, optionally showing one of them as pressed
|
||||
---@param pressed_arrow? integer arrow to show as pressed (1 = scroll up, 0 = neither, -1 = scroll down)
|
||||
---@param pressed_arrow? 1|0|-1 arrow to show as pressed (1 = scroll up, 0 = neither, -1 = scroll down)
|
||||
local function draw_arrows(pressed_arrow)
|
||||
local nav_fg_bg = args.nav_fg_bg or e.fg_bg
|
||||
local active_fg_bg = args.nav_active or nav_fg_bg
|
||||
@@ -200,7 +200,7 @@ local function listbox(args)
|
||||
end
|
||||
|
||||
-- handle a child element having been added to the list
|
||||
---@param id string|integer element identifier
|
||||
---@param id element_id element identifier
|
||||
---@param child graphics_element child element
|
||||
function e.on_added(id, child)
|
||||
table.insert(list, { id = id, e = child, y = 0, h = child.get_height() })
|
||||
@@ -208,7 +208,7 @@ local function listbox(args)
|
||||
end
|
||||
|
||||
-- handle a child element having been removed from the list
|
||||
---@param id string|integer element identifier
|
||||
---@param id element_id element identifier
|
||||
function e.on_removed(id)
|
||||
for idx, elem in ipairs(list) do
|
||||
if elem.id == id then
|
||||
|
||||
Reference in New Issue
Block a user