Better require regexps for submodules
This commit is contained in:
parent
77674a4830
commit
a094675a49
8 changed files with 10 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
local core = require((...):match("^(.+)%.[^%.]+") .. '.core')
|
||||
local core = require((...):match("(.-)[^%.]+$") .. 'core')
|
||||
|
||||
-- the widget
|
||||
return function(title, x,y, w,h, draw)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local core = require((...):match("^(.+)%.[^%.]+") .. '.core')
|
||||
local core = require((...):match("(.-)[^%.]+$") .. 'core')
|
||||
|
||||
return function(info, x,y, w,h, draw)
|
||||
local id = core.generateID()
|
||||
|
|
4
core.lua
4
core.lua
|
@ -1,5 +1,6 @@
|
|||
-- state
|
||||
local context = {maxid = 0}
|
||||
local draw_items = {n = 0}
|
||||
local NO_WIDGET = function()end
|
||||
|
||||
local function generateID()
|
||||
|
@ -87,7 +88,6 @@ local function save_unpack(t, i)
|
|||
return t[i], save_unpack(t, i+1)
|
||||
end
|
||||
|
||||
local draw_items = {n = 0}
|
||||
local function registerDraw(id, f, ...)
|
||||
assert(type(f) == 'function' or (getmetatable(f) or {}).__call,
|
||||
'Drawing function is not a callable type!')
|
||||
|
@ -141,7 +141,7 @@ return {
|
|||
hasKeyFocus = hasKeyFocus,
|
||||
makeTabable = makeTabable,
|
||||
|
||||
style = require((...):match("^(.+)%.[^%.]+") .. '.style-default'),
|
||||
style = require((...):match("(.-)[^%.]+$") .. '.style-default'),
|
||||
color = color,
|
||||
registerDraw = registerDraw,
|
||||
draw = draw,
|
||||
|
|
2
init.lua
2
init.lua
|
@ -1,4 +1,4 @@
|
|||
local BASE = (...) .. '.'
|
||||
local BASE = ((...):match('(.+)%.') or ...) .. '.'
|
||||
|
||||
return {
|
||||
core = require(BASE .. 'core'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local core = require((...):match("^(.+)%.[^%.]+") .. '.core')
|
||||
local core = require((...):match("(.-)[^%.]+$") .. 'core')
|
||||
|
||||
return function(info, x,y,w,h, draw)
|
||||
info.text = info.text or ""
|
||||
|
@ -10,6 +10,7 @@ return function(info, x,y,w,h, draw)
|
|||
if core.isActive(id) then core.setKeyFocus(id) end
|
||||
|
||||
core.registerDraw(id, draw or core.style.Input, info.text, info.cursor, x,y,w,h)
|
||||
if not core.hasKeyFocus(id) then return false end
|
||||
|
||||
local changed = false
|
||||
-- editing
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local core = require((...):match("^(.+)%.[^%.]+") .. '.core')
|
||||
local core = require((...):match("(.-)[^%.]+$") .. 'core')
|
||||
|
||||
return function(text, x,y,w,h,align, draw)
|
||||
local id = core.generateID()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local core = require((...):match("^(.+)%.[^%.]+") .. '.core')
|
||||
local core = require((...):match("(.-)[^%.]+$") .. 'core')
|
||||
|
||||
return function(info, x,y,w,h, draw)
|
||||
assert(type(info) == 'table' and info.value, "Incomplete slider value info")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local core = require((...):match("^(.+)%.[^%.]+") .. '.core')
|
||||
local core = require((...):match("(.-)[^%.]+$") .. 'core')
|
||||
|
||||
return function(info, x,y,w,h, draw)
|
||||
assert(type(info) == 'table' and type(info.value) == "table", "Incomplete slider value info")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue