diff options
| author | ruki <[email protected]> | 2018-02-01 23:15:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-02-01 13:32:01 +0800 |
| commit | dc29eb443366d6ff754c7f0c05e51e7d1aab3c21 (patch) | |
| tree | 2d418994d0244358127a92c2dfb37c909eb4a1c0 | |
| parent | 0ee92c0da0bfd6d9215622fedbd321aabf87f061 (diff) | |
improve console menu options
| -rw-r--r-- | xmake/actions/config/menuconf.lua | 2 | ||||
| -rw-r--r-- | xmake/core/base/option.lua | 15 | ||||
| -rw-r--r-- | xmake/core/language/menu.lua | 10 | ||||
| -rw-r--r-- | xmake/core/platform/menu.lua | 10 |
4 files changed, 19 insertions, 18 deletions
diff --git a/xmake/actions/config/menuconf.lua b/xmake/actions/config/menuconf.lua index 19c1bb840..8f0c267a1 100644 --- a/xmake/actions/config/menuconf.lua +++ b/xmake/actions/config/menuconf.lua @@ -162,6 +162,8 @@ function app:_make_configs_by_category(options_by_category, get_option_info) table.insert(subconfigs, menu_index, menuconf.string {name = info.name, value = value, default = info.default, description = info.description}) elseif info.kind == "boolean" then table.insert(subconfigs, menu_index, menuconf.boolean {name = info.name, value = value, default = info.default, description = info.description}) + elseif info.kind == "choice" then + table.insert(subconfigs, menu_index, menuconf.choice {name = info.name, value = value, default = info.default, values = info.values, description = info.description}) end end end diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua index 8d43fabe5..4037e6331 100644 --- a/xmake/core/base/option.lua +++ b/xmake/core/base/option.lua @@ -983,7 +983,22 @@ function option.show_options(options) -- the padding spaces local padding = 42 + -- remove repeat empty lines + local emptyline_count = 0 + local printed_options = {} + for _, opt in ipairs(options) do + if not opt[1] and not opt[2] then + emptyline_count = emptyline_count + 1 + else + emptyline_count = 0 + end + if emptyline_count < 2 then + table.insert(printed_options, opt) + end + end + -- print options + options = printed_options for _, opt in ipairs(options) do -- init the option info diff --git a/xmake/core/language/menu.lua b/xmake/core/language/menu.lua index 03fcb127e..89c80dc29 100644 --- a/xmake/core/language/menu.lua +++ b/xmake/core/language/menu.lua @@ -47,7 +47,6 @@ function menu.options(action) -- load and merge all language options local exist = {} local results = {} - local newline = false for _, instance in pairs(languages) do -- get menu @@ -67,22 +66,15 @@ function menu.options(action) if not exist[name] then table.insert(results, option) exist[name] = true - newline = false end - elseif option.category or not newline then + else table.insert(results, option) - newline = true end end end end end - -- remove the last empty option - if results[#results][2] == nil then - table.remove(results) - end - -- ok? return results end diff --git a/xmake/core/platform/menu.lua b/xmake/core/platform/menu.lua index 8231117e8..d638484ac 100644 --- a/xmake/core/platform/menu.lua +++ b/xmake/core/platform/menu.lua @@ -45,7 +45,6 @@ function menu.options(action) -- load and merge all platform options local exist = {} local results = {} - local newline = false for _, plat in ipairs(plats) do -- load platform @@ -71,22 +70,15 @@ function menu.options(action) if not exist[name] then table.insert(results, option) exist[name] = true - newline = false end - elseif option.category or not newline then + else table.insert(results, option) - newline = true end end end end end - -- remove the last empty option - if results[#results][2] == nil then - table.remove(results) - end - -- ok? return results end |
