diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-06-12 15:55:23 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-16 23:51:49 (GMT) |
commit | 28cce15aa3bd123e2875d4f76d2dbae7c4c3b233 (patch) | |
tree | f31b9f7fc8608dd42392cfd04f5a0a85f1b20466 /src/FbTk | |
parent | 946bc2edb60836bb0d939d850543d1c9ab683dc9 (diff) | |
download | fluxbox_pavel-28cce15aa3bd123e2875d4f76d2dbae7c4c3b233.zip fluxbox_pavel-28cce15aa3bd123e2875d4f76d2dbae7c4c3b233.tar.bz2 |
Lua resources: Add support for saving of boolean values
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/LResourceHelper.lua | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/FbTk/LResourceHelper.lua b/src/FbTk/LResourceHelper.lua index dd4ac2e..b16e756 100644 --- a/src/FbTk/LResourceHelper.lua +++ b/src/FbTk/LResourceHelper.lua | |||
@@ -102,11 +102,7 @@ local function register_resource(root, name, object) | |||
102 | end; | 102 | end; |
103 | 103 | ||
104 | local function dump_(key, value, fd) | 104 | local function dump_(key, value, fd) |
105 | if type(value) == 'string' then | 105 | if type(value) == 'table' then |
106 | fd:write(key, ' = ', string.format('%q', value), '\n'); | ||
107 | elseif type(value) == 'number' then | ||
108 | fd:write(key, ' = ', string.format('%g', value), '\n'); | ||
109 | elseif type(value) == 'table' then | ||
110 | fd:write(key, ' = {}\n'); | 106 | fd:write(key, ' = {}\n'); |
111 | for k, v in pairs(value) do | 107 | for k, v in pairs(value) do |
112 | k = append_name(key, k); | 108 | k = append_name(key, k); |
@@ -124,7 +120,20 @@ local function dump_(key, value, fd) | |||
124 | end; | 120 | end; |
125 | fd:write('\n'); | 121 | fd:write('\n'); |
126 | else | 122 | else |
127 | error('Unsupported value type: ' .. type(val)); | 123 | if type(value) == 'string' then |
124 | value = string.format('%q', value); | ||
125 | elseif type(value) == 'number' then | ||
126 | value = string.format('%g', value); | ||
127 | elseif type(value) == 'boolean' then | ||
128 | if value then | ||
129 | value = "true"; | ||
130 | else | ||
131 | value = "false"; | ||
132 | end; | ||
133 | else | ||
134 | error('Unsupported value type for ' .. key .. ': ' .. type(value)); | ||
135 | end; | ||
136 | fd:write(key, ' = ', value, '\n'); | ||
128 | end; | 137 | end; |
129 | end; | 138 | end; |
130 | 139 | ||