From 987b002e0d28a6c3cf5aea63883a63f09d7ef0d5 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 14 Nov 2020 11:08:37 +0800 Subject: [PATCH] improve mconfdialog --- src/ltui/mconfdialog.lua | 8 +++++--- tests/mconfdialog.lua | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ltui/mconfdialog.lua b/src/ltui/mconfdialog.lua index 21cb2d5..1857131 100644 --- a/src/ltui/mconfdialog.lua +++ b/src/ltui/mconfdialog.lua @@ -252,14 +252,16 @@ function mconfdialog:show_help() if config.kind then text = text .. "\ntype: " .. config.kind end - if config.default then - text = text .. "\ndefault: " .. tostring(config.default) - end if config.kind == "choice" then + if config.default and config.values[config.default] then + text = text .. "\ndefault: " .. config.values[config.default] + end text = text .. "\nvalues: " for _, value in ipairs(config.values) do text = text .. "\n - " .. value end + elseif config.default then + text = text .. "\ndefault: " .. tostring(config.default) end if config.path then text = text .. "\npath: " .. config.path diff --git a/tests/mconfdialog.lua b/tests/mconfdialog.lua index 031f535..50290d0 100644 --- a/tests/mconfdialog.lua +++ b/tests/mconfdialog.lua @@ -69,7 +69,7 @@ function demo:init() table.insert(configs, menuconf.number {value = 6, default = 10, description = "number config item"}) table.insert(configs, menuconf.string {value = "x86_64", description = "string config item"}) table.insert(configs, menuconf.menu {description = "menu config item", configs = configs_sub}) - table.insert(configs, menuconf.choice {value = 3, values = {1, 5, 6, 7}, description = "choice config item"}) + table.insert(configs, menuconf.choice {value = 3, values = {1, 5, 6, 7}, default = 2, description = "choice config item"}) -- init menu config dialog self:dialog_mconf():load(configs)