From 1342d5655da85c87c3ff1d5441ffd5117effc07f Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 27 Mar 2014 00:03:34 +1000 Subject: More notes, TODO, and default Thing pattern. --- ClientHamr/GuiLua/GuiLua.c | 6 ++++++ ClientHamr/GuiLua/skang.lua | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c index 87766b0..3588ea0 100644 --- a/ClientHamr/GuiLua/GuiLua.c +++ b/ClientHamr/GuiLua/GuiLua.c @@ -172,6 +172,12 @@ of telling if the number is pixels or character cells. Also, relative to what part of the other widget? Some more thought needs to be put into this. +Another idea for relative numbers could be to have a coord object with +various methods, so we could have something like - + +widget:bottom(-10):right(5) -- 10 pixels below the bottom of widget, 5 pixels to the right of the right edge of widget. +widget:width("12") -- 12 characters longer than the width of widget. + */ diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index b8e418b..e89de8e 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua @@ -212,6 +212,26 @@ Other Thing things are - Actually, not sure matrix-RAD solved that either. lol ]] +--[[ ideas +use a Lua pattern instead of a mask, with ^ and $ automatically added at the ends. +__newindex could catch a table being assigned - test.foo = {widget = '...', acl='...'} + though that interferes with using tables for Stuff + test.someStuff = {key='blah', field0='something', field1=1, ...} + test.someStuff.key + happily Lua function call syntax supports test.foo{ ... } as a function call with a table argument. B-) + so maybe a use for __call after all, if the argument is that table + the table itself is passed to __call as the first argument, the rest of the arguments follow. + test.foo(1, 'two') -> __call(foo, 1, 'two') + foo has to be a table value though, with a metatable + and the rest of skang is treating test.foo as a nil value so that __index and __newindex work. B-( + test itself is a table, so all is not lost - + test{'foo', widget='...', acl='..'} -> __call(test, {'foo', ...}) + which would assign stuff to skang.things.foo.widget and skang.things.foo.acl + as opposed to - + skang.things.foo = {widget='...', acl='...'} + which blanks out the other stuff. +]] + -- Default things values. Thing.help = 'No description supplied.' Thing.types = {'string'} @@ -221,6 +241,7 @@ Thing.required = false Thing.action = 'nada' -- An optional action to perform. Thing.tell = '' -- The skang command that created this Thing. +Thing.pattern = '.*' -- A pattern to restrict values. Thing.isReadOnly = false -- Is this Thing read only? Thing.isServer = false -- Is this Thing server side? @@ -256,6 +277,7 @@ Thing.__index = function (table, key) -- First see if this is a Thing. -- TODO - Java skang called isValid() on get(). On the other hand, doesn't seem to call it on set(), but calls it on append(). -- Ah, it was doing isValid() on setStufflet(). + -- TODO - Call thing.func() if it exists. if thing then return thing.value or thing.default end -- Then see if we can inherit it from Thing. @@ -322,6 +344,7 @@ thing = function (names, help, default, types, widget, required, acl, boss) n[i] = v i = i + 1 end + -- TODO - Should bitch and return if no names, has to be at least one name. local name = n[1] -- Find type, default to string, then break out the other types. -- cgit v1.1