aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/skang.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-20 16:21:27 +1000
committerDavid Walter Seikel2014-03-20 16:21:27 +1000
commitcf446f7c39e032849bd89ae77ae7376f0015876d (patch)
treed8a14e27e1f158d49bac18d4fd7ec8c2f37739ec /ClientHamr/GuiLua/skang.lua
parentFirst hack at Thing. (diff)
downloadSledjHamr-cf446f7c39e032849bd89ae77ae7376f0015876d.zip
SledjHamr-cf446f7c39e032849bd89ae77ae7376f0015876d.tar.gz
SledjHamr-cf446f7c39e032849bd89ae77ae7376f0015876d.tar.bz2
SledjHamr-cf446f7c39e032849bd89ae77ae7376f0015876d.tar.xz
TODO++
Diffstat (limited to 'ClientHamr/GuiLua/skang.lua')
-rw-r--r--ClientHamr/GuiLua/skang.lua24
1 files changed, 20 insertions, 4 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index dbbe19c..eccd9d8 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -1,5 +1,4 @@
1-- TODO - This should be in C, but so far development has been quite rapid doing it in Lua. 1-- TODO - This should be in C, but so far development has been quite rapid doing it in Lua.
2--[[
3 2
4--[[ Skang package 3--[[ Skang package
5 4
@@ -213,12 +212,11 @@ moduleEnd = function (module)
213 setfenv(2, module.savedEnvironment) 212 setfenv(2, module.savedEnvironment)
214end 213end
215 214
216--[[
217 215
218-- skang.newParam stashes the default value into _M['bar'], and the details into ThingSpace.parameters['bar']. 216-- skang.newParam stashes the default value into _M['bar'], and the details into ThingSpace.parameters['bar'].
219-- TODO - If it's not required, and there's no default, then skip setting _M['bar']. 217-- TODO - If it's not required, and there's no default, then skip setting _M['bar'].
220-- TODO - Could even use __index to skip setting it if it's not required and there is a default. 218-- TODO - Could even use __index to skip setting it if it's not required and there is a default.
221-- TODO - Should add a metatable, and __newindex() that passes all setting of this variable to skang so it can update other stuff like linked widgets. 219-- TODO - if default is a function, or a pre existing module[name] is a function, then set the Thing .func to that function.
222-- TODO - Users might want to use two or more copies of this module. Keep that in mind. local a = require 'test', b = require 'test' might handle that though? 220-- TODO - Users might want to use two or more copies of this module. Keep that in mind. local a = require 'test', b = require 'test' might handle that though?
223-- Not unless skang.newParam() knows about a and b, which it wont. 221-- Not unless skang.newParam() knows about a and b, which it wont.
224-- Both a and b get the same table, not different copies of it. 222-- Both a and b get the same table, not different copies of it.
@@ -226,6 +224,7 @@ end
226-- Then we have to deal with widgets linking to specific clones. 224-- Then we have to deal with widgets linking to specific clones.
227-- Actually, not sure matrix-RAD solved that either. lol 225-- Actually, not sure matrix-RAD solved that either. lol
228-- TODO - This could even be done with an array of these arguments, not including the _M. 226-- TODO - This could even be done with an array of these arguments, not including the _M.
227-- TODO - Maybe combine name and shortcut - 'name,s'. Make it generic, add aliases to. Any that are single characters can be shortcuts.
229newParam = function (module, name, required, shortcut, default, help, acl, boss) 228newParam = function (module, name, required, shortcut, default, help, acl, boss)
230 module[name] = default 229 module[name] = default
231 ThingSpace.parameters[name] = {module = module, name = name, required = required, shortcut = shortcut, default = default, help = help, acl = acl, boss = boss, } 230 ThingSpace.parameters[name] = {module = module, name = name, required = required, shortcut = shortcut, default = default, help = help, acl = acl, boss = boss, }
@@ -233,8 +232,25 @@ newParam = function (module, name, required, shortcut, default, help, acl, boss)
233 print(name .. ' -> ' .. shortcut .. ' -> ' .. help) 232 print(name .. ' -> ' .. shortcut .. ' -> ' .. help)
234end 233end
235 234
235--[[ TODO - It might be worth it to combine parameters and commands, since in Lua, functions are first class types like numbers and strings.
236 Merging widgets might work to. B-)
237
238 Parameter gets a type, which might help since Lua is untyped, versus Java being strongly typed.
239 Widgets get a type as well, which would be label, button, edit, grid, etc.
240 A grid could even have sub types - grid,number,string,button,date. B-)
241
242 Required commands makes no sense, but can just be ignored.
243 A required widget might mean that the window HAS to have one.
244
245 Default for a command would be the actual function.
246 Default being a function makes this Thing a command.
247 Default for a widget could be the default creation arguments - '"Press me", 1, 1, 10, 50'
248
249 Or we could merge the other way -
250 Each Thing has names (including shortcuts and aliases), type, required, widget default arguments, default value, function, help text.
251]]
252
236-- skang.newCommand stashes the function into _M['func'], and stashes it all (including the function) into ThingSpace.commands['func']. 253-- skang.newCommand stashes the function into _M['func'], and stashes it all (including the function) into ThingSpace.commands['func'].
237-- TODO - Could use __call so that ThingSpace.commands['foo'](arg) works.
238newCommand = function (module, name, types, help, func, acl, boss) 254newCommand = function (module, name, types, help, func, acl, boss)
239 module[name] = func 255 module[name] = func
240 ThingSpace.commands[name] = {module = module, name = name, help = help, func = func, acl = acl, boss = boss, } 256 ThingSpace.commands[name] = {module = module, name = name, help = help, func = func, acl = acl, boss = boss, }