diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-06-12 15:55:23 (GMT) |
---|---|---|
committer | Paul Tagliamonte <paultag@fluxbox.org> | 2012-04-07 02:10:41 (GMT) |
commit | e4f171a2e2257992c821a47f5a72ad20294fe418 (patch) | |
tree | 69cb4d6c4ae7f0ebd1c1da2e53042318a84d3b8b | |
parent | 872c5e3d744341c5bc91f4559e20d249651ed77e (diff) | |
download | fluxbox_paul-e4f171a2e2257992c821a47f5a72ad20294fe418.zip fluxbox_paul-e4f171a2e2257992c821a47f5a72ad20294fe418.tar.bz2 |
Lua resources: Add support for saving of boolean values
-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 | ||