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
This commit is contained in:
parent
dcff9b85a3
commit
e910f63bba
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user