diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-05-19 23:29:10 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2021-05-19 23:29:10 -0400 |
commit | e910f63bba42c7e1627a7ec906b9cff38d032f6d (patch) | |
tree | ee7b6bb74607f8f82c96e68ed86c88d854bb45f9 | |
parent | dcff9b85a3cef778af60ad4426f91262ba815931 (diff) |
lua add a way to filter settings on read
rather than dumping all the settings allow a filter function
to choose desired settings
in menucoresettings you can see an how to do exact text matches
or wilcard matches you can even use luas version of regex
Change-Id: I4c7f7592498ea194e06e9a556b77ffd57f5d4223
-rw-r--r-- | apps/plugins/lua/include_lua/menucoresettings.lua | 18 | ||||
-rw-r--r-- | apps/plugins/lua/include_lua/rbsettings.lua | 7 |
2 files changed, 17 insertions, 8 deletions
diff --git a/apps/plugins/lua/include_lua/menucoresettings.lua b/apps/plugins/lua/include_lua/menucoresettings.lua index 13f3b8ea69..27d5e86ca1 100644 --- a/apps/plugins/lua/include_lua/menucoresettings.lua +++ b/apps/plugins/lua/include_lua/menucoresettings.lua @@ -39,21 +39,27 @@ local function get_core_settings() tmploader("rbsettings") tmploader("settings") + -- these are exact matches color and talk are wildcard matches + local list_settings = "cursor_style|show_icons|statusbar|scrollbar|scrollbar_width|list_separator_height|backdrop_file|" + local function filterfn(struct, k) + k = k or "" + --rbold.splash(100, struct .. " " .. k) + return (k:find("color") or k:find("talk") or list_settings:find(k)) + end + local rb_settings = rb.settings.dump('global_settings', "system", nil, nil, filterfn) - local rb_settings = rb.settings.dump('global_settings', "system") local color_table = {} local talk_table = {} local list_settings_table = {} - local list_settings = "cursor_style|show_icons|statusbar|scrollbar|scrollbar_width|list_separator_height|backdrop_file|" for key, value in pairs(rb_settings) do key = key or "" if (key:find("color")) then - color_table[key]=value + color_table[key]=value elseif (key:find("talk")) then - talk_table[key]=value - elseif (list_settings:find(key)) then - list_settings_table[key]=value + talk_table[key]=value + else --if (list_settings:find(key)) then + list_settings_table[key]=value end end diff --git a/apps/plugins/lua/include_lua/rbsettings.lua b/apps/plugins/lua/include_lua/rbsettings.lua index defdb11b77..995e5023c9 100644 --- a/apps/plugins/lua/include_lua/rbsettings.lua +++ b/apps/plugins/lua/include_lua/rbsettings.lua @@ -151,12 +151,15 @@ function rb.settings.read(s_settings, s_var, s_groupname) return data end -function rb.settings.dump(s_settings, s_groupname, s_structname, t_output) +function rb.settings.dump(s_settings, s_groupname, s_structname, t_output, fn_filter) t_output = t_output or {} + fn_filter = fn_filter or function(s,k) return true end local tgroup = rb[s_groupname] s_structname = s_structname or s_settings for k, v in pairs(tgroup[s_structname]) do - t_output[k] = rb.settings.read(s_settings, v, s_groupname) + if fn_filter(s_structname, k) then + t_output[k] = rb.settings.read(s_settings, v, s_groupname) + end end return t_output end |