Lots of fixes and improvements
This commit is contained in:
Robert Jelic
2025-02-16 14:33:07 +01:00
parent 19edc4b295
commit cc7b2de51a
27 changed files with 198 additions and 208 deletions

View File

@@ -1,4 +1,4 @@
name: Update Installer Config name: Basalt Build Pipeline
on: on:
push: push:
@@ -8,7 +8,7 @@ on:
- 'src/**' - 'src/**'
jobs: jobs:
update-config: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: write
@@ -16,6 +16,8 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Lua - name: Install Lua
run: | run: |
@@ -25,11 +27,17 @@ jobs:
- name: Generate Config - name: Generate Config
run: | run: |
lua tools/generate-config.lua lua tools/generate-config.lua
- name: Commit and Push Changes - name: Generate Changelog
id: changelog
uses: heinrichreimer/github-changelog-generator-action@v2.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Commit Changes
run: | run: |
git config --global user.name 'github-actions[bot]' git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add config.lua git add config.lua CHANGELOG.md
git commit -m "Update installer config" || exit 0 git commit -m "Update config and changelog" || exit 0
git push git push

View File

@@ -98,9 +98,7 @@ function ElementManager.loadElement(name)
for funcName, func in pairs(plugin) do for funcName, func in pairs(plugin) do
if funcName ~= "setup" and funcName ~= "hooks" then if funcName ~= "setup" and funcName ~= "hooks" then
element[funcName] = function(self, ...) element[funcName] = func
return func(self, ...)
end
end end
end end
end end

View File

@@ -46,9 +46,8 @@ end
--- @param basalt table The basalt instance --- @param basalt table The basalt instance
--- @return table The newly created BaseElement instance --- @return table The newly created BaseElement instance
--- @usage local element = BaseElement.new("myId", basalt) --- @usage local element = BaseElement.new("myId", basalt)
function BaseElement.new(props, basalt) function BaseElement.new()
local self = setmetatable({}, BaseElement):__init() local self = setmetatable({}, BaseElement):__init()
self:init(props, basalt)
return self return self
end end
@@ -57,11 +56,7 @@ end
--- @param basalt table The basalt instance --- @param basalt table The basalt instance
--- @return table self The initialized instance --- @return table self The initialized instance
function BaseElement:init(props, basalt) function BaseElement:init(props, basalt)
if(type(props) == "table")then self._props = props
for k,v in pairs(props)do
self[k] = v
end
end
self._values.id = uuid() self._values.id = uuid()
self.basalt = basalt self.basalt = basalt
self._registeredEvents = {} self._registeredEvents = {}
@@ -80,6 +75,18 @@ function BaseElement:init(props, basalt)
return self return self
end end
--- Post initialization hook
--- @return table self The BaseElement instance
function BaseElement:postInit()
if(self._props)then
for k,v in pairs(self._props)do
self.set(k, v)
end
end
self._props = nil
return self
end
--- Checks if the element is a specific type --- Checks if the element is a specific type
--- @param type string The type to check for --- @param type string The type to check for
--- @return boolean Whether the element is of the specified type --- @return boolean Whether the element is of the specified type

View File

@@ -19,11 +19,10 @@ BaseFrame.defineProperty(BaseFrame, "term", {default = nil, type = "table", sett
return value return value
end}) end})
function BaseFrame.new(props, basalt) function BaseFrame.new()
local self = setmetatable({}, BaseFrame):__init() local self = setmetatable({}, BaseFrame):__init()
self.set("term", term.current()) self.set("term", term.current())
self.set("background", colors.lightGray) self.set("background", colors.lightGray)
self:init(props, basalt)
return self return self
end end

View File

@@ -13,12 +13,11 @@ Button.defineProperty(Button, "text", {default = "Button", type = "string", canT
Button.listenTo(Button, "mouse_click") Button.listenTo(Button, "mouse_click")
Button.listenTo(Button, "mouse_up") Button.listenTo(Button, "mouse_up")
function Button.new(props, basalt) function Button.new()
local self = setmetatable({}, Button):__init() local self = setmetatable({}, Button):__init()
self.set("width", 10) self.set("width", 10)
self.set("height", 3) self.set("height", 3)
self.set("z", 5) self.set("z", 5)
self:init(props, basalt)
return self return self
end end

View File

@@ -13,11 +13,10 @@ Checkbox.defineProperty(Checkbox, "symbol", {default = "x", type = "string"})
Checkbox.listenTo(Checkbox, "mouse_click") Checkbox.listenTo(Checkbox, "mouse_click")
function Checkbox.new(props, basalt) function Checkbox.new()
local self = setmetatable({}, Checkbox):__init() local self = setmetatable({}, Checkbox):__init()
self.set("width", 1) self.set("width", 1)
self.set("height", 1) self.set("height", 1)
self:init(props, basalt)
return self return self
end end

View File

@@ -57,6 +57,7 @@ for k, _ in pairs(elementManager:getElementList()) do
expect(1, self, "table") expect(1, self, "table")
local element = self.basalt.create(k, ...) local element = self.basalt.create(k, ...)
self:addChild(element) self:addChild(element)
element:postInit()
return element return element
end end
Container["addDelayed"..capitalizedName] = function(self, prop) Container["addDelayed"..capitalizedName] = function(self, prop)
@@ -67,9 +68,8 @@ for k, _ in pairs(elementManager:getElementList()) do
end end
end end
function Container.new(props, basalt) function Container.new()
local self = setmetatable({}, Container):__init() local self = setmetatable({}, Container):__init()
self:init(props, basalt)
return self return self
end end

View File

@@ -11,12 +11,11 @@ Dropdown.defineProperty(Dropdown, "dropdownHeight", {default = 5, type = "number
Dropdown.defineProperty(Dropdown, "selectedText", {default = "", type = "string"}) Dropdown.defineProperty(Dropdown, "selectedText", {default = "", type = "string"})
Dropdown.defineProperty(Dropdown, "dropSymbol", {default = "\31", type = "string"}) -- ▼ Symbol Dropdown.defineProperty(Dropdown, "dropSymbol", {default = "\31", type = "string"}) -- ▼ Symbol
function Dropdown.new(props, basalt) function Dropdown.new()
local self = setmetatable({}, Dropdown):__init() local self = setmetatable({}, Dropdown):__init()
self.set("width", 16) self.set("width", 16)
self.set("height", 1) -- Dropdown ist initial nur 1 Zeile hoch self.set("height", 1)
self.set("z", 8) self.set("z", 8)
self:init(props, basalt)
return self return self
end end

View File

@@ -226,11 +226,9 @@ local function updateLayout(self, direction, spacing, justifyContent, wrap)
end end
--- Creates a new Flexbox instance --- Creates a new Flexbox instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return Flexbox object The newly created Flexbox instance --- @return Flexbox object The newly created Flexbox instance
--- @usage local element = Flexbox.new("myId", basalt) --- @usage local element = Flexbox.new("myId", basalt)
function Flexbox.new(props, basalt) function Flexbox.new()
local self = setmetatable({}, Flexbox):__init() local self = setmetatable({}, Flexbox):__init()
self.set("width", 12) self.set("width", 12)
self.set("height", 6) self.set("height", 6)
@@ -238,7 +236,6 @@ function Flexbox.new(props, basalt)
self.set("z", 10) self.set("z", 10)
self:observe("width", function() self.set("flexUpdateLayout", true) end) self:observe("width", function() self.set("flexUpdateLayout", true) end)
self:observe("height", function() self.set("flexUpdateLayout", true) end) self:observe("height", function() self.set("flexUpdateLayout", true) end)
self:init(props, basalt)
return self return self
end end

View File

@@ -6,17 +6,14 @@ local Frame = setmetatable({}, Container)
Frame.__index = Frame Frame.__index = Frame
--- Creates a new Frame instance --- Creates a new Frame instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return Frame object The newly created Frame instance --- @return Frame object The newly created Frame instance
--- @usage local element = Frame.new("myId", basalt) --- @usage local element = Frame.new("myId", basalt)
function Frame.new(props, basalt) function Frame.new()
local self = setmetatable({}, Frame):__init() local self = setmetatable({}, Frame):__init()
self.set("width", 12) self.set("width", 12)
self.set("height", 6) self.set("height", 6)
self.set("background", colors.gray) self.set("background", colors.gray)
self.set("z", 10) self.set("z", 10)
self:init(props, basalt)
return self return self
end end

View File

@@ -26,15 +26,12 @@ Input.listenTo(Input, "key")
Input.listenTo(Input, "char") Input.listenTo(Input, "char")
--- Creates a new Input instance --- Creates a new Input instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return Input object The newly created Input instance --- @return Input object The newly created Input instance
--- @usage local element = Input.new("myId", basalt) --- @usage local element = Input.new("myId", basalt)
function Input.new(props, basalt) function Input.new()
local self = setmetatable({}, Input):__init() local self = setmetatable({}, Input):__init()
self.set("width", 8) self.set("width", 8)
self.set("z", 3) self.set("z", 3)
self:init(id, basalt)
return self return self
end end

View File

@@ -13,16 +13,13 @@ Label.defineProperty(Label, "text", {default = "Label", type = "string", setter
end}) end})
--- Creates a new Label instance --- Creates a new Label instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return Label object The newly created Label instance --- @return Label object The newly created Label instance
--- @usage local element = Label.new("myId", basalt) --- @usage local element = Label.new("myId", basalt)
function Label.new(props, basalt) function Label.new()
local self = setmetatable({}, Label):__init() local self = setmetatable({}, Label):__init()
self.set("z", 3) self.set("z", 3)
self.set("foreground", colors.black) self.set("foreground", colors.black)
self.set("backgroundEnabled", false) self.set("backgroundEnabled", false)
self:init(props, basalt)
return self return self
end end

View File

@@ -18,12 +18,11 @@ List.defineProperty(List, "selectedColor", {default = colors.blue, type = "numbe
List.listenTo(List, "mouse_click") List.listenTo(List, "mouse_click")
List.listenTo(List, "mouse_scroll") List.listenTo(List, "mouse_scroll")
function List.new(props, basalt) function List.new()
local self = setmetatable({}, List):__init() local self = setmetatable({}, List):__init()
self.set("width", 16) self.set("width", 16)
self.set("height", 8) self.set("height", 8)
self.set("background", colors.gray) self.set("background", colors.gray)
self:init(props, basalt)
return self return self
end end

View File

@@ -8,12 +8,11 @@ Menu.__index = Menu
Menu.defineProperty(Menu, "separatorColor", {default = colors.gray, type = "number"}) Menu.defineProperty(Menu, "separatorColor", {default = colors.gray, type = "number"})
function Menu.new(props, basalt) function Menu.new()
local self = setmetatable({}, Menu):__init() local self = setmetatable({}, Menu):__init()
self.set("width", 30) self.set("width", 30)
self.set("height", 1) self.set("height", 1)
self.set("background", colors.gray) self.set("background", colors.gray)
self:init(props, basalt)
return self return self
end end

View File

@@ -108,16 +108,13 @@ function BasaltProgram:stop()
end end
--- Creates a new Program instance --- Creates a new Program instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return Program object The newly created Program instance --- @return Program object The newly created Program instance
--- @usage local element = Program.new("myId", basalt) --- @usage local element = Program.new("myId", basalt)
function Program.new(props, basalt) function Program.new()
local self = setmetatable({}, Program):__init() local self = setmetatable({}, Program):__init()
self.set("z", 5) self.set("z", 5)
self.set("width", 30) self.set("width", 30)
self.set("height", 12) self.set("height", 12)
self:init(props, basalt)
return self return self
end end

View File

@@ -11,11 +11,10 @@ ProgressBar.defineProperty(ProgressBar, "showPercentage", {default = false, type
---@property progressColor color Progress bar color ---@property progressColor color Progress bar color
ProgressBar.defineProperty(ProgressBar, "progressColor", {default = colors.lime, type = "number"}) ProgressBar.defineProperty(ProgressBar, "progressColor", {default = colors.lime, type = "number"})
function ProgressBar.new(props, basalt) function ProgressBar.new()
local self = setmetatable({}, ProgressBar):__init() local self = setmetatable({}, ProgressBar):__init()
self.set("width", 10) self.set("width", 10)
self.set("height", 1) self.set("height", 1)
self:init(props, basalt)
return self return self
end end

View File

@@ -19,12 +19,11 @@ Slider.listenTo(Slider, "mouse_click")
Slider.listenTo(Slider, "mouse_drag") Slider.listenTo(Slider, "mouse_drag")
Slider.listenTo(Slider, "mouse_up") Slider.listenTo(Slider, "mouse_up")
function Slider.new(props, basalt) function Slider.new()
local self = setmetatable({}, Slider):__init() local self = setmetatable({}, Slider):__init()
self.set("width", 8) self.set("width", 8)
self.set("height", 1) self.set("height", 1)
self.set("backgroundEnabled", false) self.set("backgroundEnabled", false)
self:init(props, basalt)
return self return self
end end

View File

@@ -18,12 +18,11 @@ Table.defineProperty(Table, "scrollOffset", {default = 0, type = "number", canTr
Table.listenTo(Table, "mouse_click") Table.listenTo(Table, "mouse_click")
Table.listenTo(Table, "mouse_scroll") Table.listenTo(Table, "mouse_scroll")
function Table.new(props, basalt) function Table.new()
local self = setmetatable({}, Table):__init() local self = setmetatable({}, Table):__init()
self.set("width", 30) self.set("width", 30)
self.set("height", 10) self.set("height", 10)
self.set("z", 5) self.set("z", 5)
self:init(props, basalt)
return self return self
end end

View File

@@ -15,12 +15,11 @@ Tree.defineProperty(Tree, "selectedColor", {default = colors.lightBlue, type = "
Tree.listenTo(Tree, "mouse_click") Tree.listenTo(Tree, "mouse_click")
Tree.listenTo(Tree, "mouse_scroll") Tree.listenTo(Tree, "mouse_scroll")
function Tree.new(props, basalt) function Tree.new()
local self = setmetatable({}, Tree):__init() local self = setmetatable({}, Tree):__init()
self.set("width", 30) self.set("width", 30)
self.set("height", 10) self.set("height", 10)
self.set("z", 5) self.set("z", 5)
self:init(props, basalt)
return self return self
end end

View File

@@ -75,9 +75,8 @@ local max, min = math.max, math.min
--- @param basalt table The basalt instance --- @param basalt table The basalt instance
--- @return VisualElement object The newly created VisualElement instance --- @return VisualElement object The newly created VisualElement instance
--- @usage local element = VisualElement.new("myId", basalt) --- @usage local element = VisualElement.new("myId", basalt)
function VisualElement.new(props, basalt) function VisualElement.new()
local self = setmetatable({}, VisualElement):__init() local self = setmetatable({}, VisualElement):__init()
self:init(props, basalt)
return self return self
end end

View File

@@ -24,6 +24,22 @@ function utils.deepCopy(obj)
return copy return copy
end end
function utils.copy(obj)
local new = {}
for k,v in pairs(obj)do
new[k] = v
end
return new
end
function utils.reverse(t)
local reversed = {}
for i = #t, 1, -1 do
table.insert(reversed, t[i])
end
return reversed
end
function utils.uuid() function utils.uuid()
return string.format('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', return string.format('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
math.random(0, 0xffff), math.random(0, 0xffff), math.random(0, 0xffff), math.random(0, 0xffff), math.random(0, 0xffff), math.random(0, 0xffff),

View File

@@ -73,7 +73,9 @@ function basalt.create(type, properties, lazyLoading, parent)
queueLazyElements() queueLazyElements()
return blueprint return blueprint
else else
return elementClass.new(properties, basalt) local element = elementClass.new()
element:init(properties, basalt)
return element
end end
end end
@@ -82,6 +84,7 @@ end
--- @usage local mainFrame = basalt.createFrame() --- @usage local mainFrame = basalt.createFrame()
function basalt.createFrame() function basalt.createFrame()
local frame = basalt.create("BaseFrame") local frame = basalt.create("BaseFrame")
frame:postInit()
mainFrame = frame mainFrame = frame
return frame return frame
end end

View File

@@ -55,20 +55,19 @@ local BaseFrame = {
if not self._debugFrame then if not self._debugFrame then
local width = self.get("width") local width = self.get("width")
local height = self.get("height") local height = self.get("height")
self._debugFrame = self:addFrame() self._debugFrame = self:addFrame("basaltDebugLog")
:setWidth(width) :setWidth(width)
:setHeight(height) :setHeight(height)
:setBackground(colors.black)
:setZ(999) :setZ(999)
:listenEvent("mouse_scroll", true) :listenEvent("mouse_scroll", true)
self.basalt.LOGGER.debug("Created debug log frame " .. self._debugFrame.get("name"))
self._debugFrame:addButton() self._debugFrame:addButton("basaltDebugLogClose")
:setWidth(9) :setWidth(9)
:setHeight(1) :setHeight(1)
:setX(width - 8) :setX(width - 8)
:setY(height) :setY(height)
:setText("Close") :setText("Close")
:setBackground(colors.red)
:onMouseClick(function() :onMouseClick(function()
self:hideDebugLog() self:hideDebugLog()
end) end)

View File

@@ -8,30 +8,29 @@ local defaultTheme = {
foreground = colors.black, foreground = colors.black,
Frame = { Frame = {
background = colors.gray, background = colors.black,
names = {
Button = { basaltDebugLogClose = {
background = "{self.clicked and colors.black or colors.blue}", background = colors.blue,
foreground = "{self.clicked and colors.blue or colors.white}" foreground = colors.white
} }
},
}, },
Button = { Button = {
background = "{self.clicked and colors.black or colors.cyan}", background = "{self.clicked and colors.black or colors.cyan}",
foreground = "{self.clicked and colors.cyan or colors.black}" foreground = "{self.clicked and colors.cyan or colors.black}",
}, },
Input = { names = {
background = "{self.focused and colors.cyan or colors.lightGray}", basaltDebugLog = {
foreground = colors.black, background = colors.red,
placeholderColor = colors.gray foreground = colors.white
},
test = {
background = "{self.clicked and colors.black or colors.green}",
foreground = "{self.clicked and colors.green or colors.black}"
}
}, },
List = {
background = colors.cyan,
foreground = colors.black,
selectedColor = colors.blue
}
} }
} }
@@ -41,115 +40,129 @@ local themes = {
local currentTheme = "default" local currentTheme = "default"
local function resolveThemeValue(value, theme) local BaseElement = {
if type(value) == "string" and theme.colors[value] then hooks = {
return theme.colors[value] postInit = {
pre = function(self)
self:applyTheme()
end}
}
}
function BaseElement.____getElementPath(self, types)
if types then
table.insert(types, 1, self._values.type)
else
types = {self._values.type}
end
local parent = self.parent
if parent then
return parent.____getElementPath(parent, types)
else
return types
end end
return value
end end
local function getThemeForElement(element) local function lookUpTemplate(theme, path)
local path = {} local current = theme
local current = element
while current do for i = 1, #path do
table.insert(path, 1, current.get("type")) local found = false
current = current.parent local types = path[i]
end
local result = {} for _, elementType in ipairs(types) do
local current = defaultTheme if current[elementType] then
current = current[elementType]
for _, elementType in ipairs(path) do found = true
if current[elementType] then break
for k,v in pairs(current[elementType]) do
result[k] = v
end end
current = current[elementType] end
if not found then
return nil
end end
end end
return current
end
local function getDefaultProperties(theme, elementType)
local result = {}
if theme.default then
for k,v in pairs(theme.default) do
if type(v) ~= "table" then
result[k] = v
end
end
if theme.default[elementType] then
for k,v in pairs(theme.default[elementType]) do
if type(v) ~= "table" then
result[k] = v
end
end
end
end
return result
end
local function applyNamedStyles(result, theme, elementType, elementName, themeTable)
if theme.default and theme.default.names and theme.default.names[elementName] then
for k,v in pairs(theme.default.names[elementName]) do
if type(v) ~= "table" then result[k] = v end
end
end
if theme.default and theme.default[elementType] and theme.default[elementType].names
and theme.default[elementType].names[elementName] then
for k,v in pairs(theme.default[elementType].names[elementName]) do
if type(v) ~= "table" then result[k] = v end
end
end
if themeTable and themeTable.names and themeTable.names[elementName] then
for k,v in pairs(themeTable.names[elementName]) do
if type(v) ~= "table" then result[k] = v end
end
end
end
local function collectThemeProps(theme, path, elementType, elementName)
local result = {}
local themeTable = lookUpTemplate(theme, path)
if themeTable then
for k,v in pairs(themeTable) do
if type(v) ~= "table" then
result[k] = v
end
end
end
if next(result) == nil then
result = getDefaultProperties(theme, elementType)
end
applyNamedStyles(result, theme, elementType, elementName, themeTable)
return result return result
end end
local function applyTheme(element, props) function BaseElement:applyTheme()
local styles = self:getTheme()
local theme = getThemeForElement(element) if(styles ~= nil) then
if props then
for k,v in pairs(props) do
theme[k] = v
end
end
for k,v in pairs(theme) do
if element:getPropertyConfig(k) then
element.set(k, v)
end
end
end
local BaseElement = {
hooks = {
init = function(self)
self.defineProperty(self, "theme", {
default = currentTheme,
type = "string",
setter = function(self, value)
self:applyTheme(value)
return value
end
})
end
}
}
function BaseElement:applyTheme(themeName)
local theme = themes[themeName] or themes.default
local elementType = self.get("type")
if theme.elementStyles[elementType] then
local styles = theme.elementStyles[elementType]
for prop, value in pairs(styles) do for prop, value in pairs(styles) do
if self:getPropertyConfig(prop) then self.set(prop, value)
self.set(prop, resolveThemeValue(value, theme))
end
end end
end end
end end
local BaseFrame = { function BaseElement:getTheme()
hooks = { local path = self:____getElementPath()
init = function(self) local elementType = self.get("type")
applyTheme(self) local elementName = self.get("name")
end
}
}
local Container = { return collectThemeProps(themes[currentTheme], path, elementType, elementName)
hooks = { end
init = function(self)
for k, _ in pairs(self.basalt.getElementManager().getElementList()) do
local capitalizedName = k:sub(1,1):upper() .. k:sub(2)
if capitalizedName ~= "BaseFrame" then
local methodName = "add"..capitalizedName
local original = self[methodName]
if original then
self[methodName] = function(self, name, props)
if type(name) == "table" then
props = name
name = nil
end
local element = original(self, name)
applyTheme(element, props)
return element
end
end
end
end
end
}
}
local themeAPI = { local themeAPI = {
setTheme = function(newTheme) setTheme = function(newTheme)
@@ -171,13 +184,7 @@ local themeAPI = {
} }
local Theme = { local Theme = {
setup = function(basalt)
basalt.setTheme(defaultTheme)
end,
BaseElement = BaseElement, BaseElement = BaseElement,
BaseFrame = BaseFrame,
Container = Container,
API = themeAPI API = themeAPI
} }

View File

@@ -114,7 +114,8 @@ function PropertySystem.blueprint(elementClass, properties, basalt, parent)
end end
template.create = function(self) template.create = function(self)
local element = elementClass.new({}, basalt) local element = elementClass.new()
element:init({}, self.basalt)
for name, value in pairs(self._values) do for name, value in pairs(self._values) do
element._values[name] = value element._values[name] = value
end end
@@ -128,6 +129,7 @@ function PropertySystem.blueprint(elementClass, properties, basalt, parent)
end end
element:updateRender() element:updateRender()
self.loadedCallback(element) self.loadedCallback(element)
element:postInit()
return element return element
end end

View File

@@ -1,27 +1,3 @@
local function serialize(t, indent)
indent = indent or ""
local result = "{\n"
for k, v in pairs(t) do
result = result .. indent .. " "
if type(k) == "string" then
result = result .. "[\"" .. k .. "\"] = "
else
result = result .. "[" .. k .. "] = "
end
if type(v) == "table" then
result = result .. serialize(v, indent .. " ")
elseif type(v) == "string" then
result = result .. "\"" .. v .. "\""
else
result = result .. tostring(v)
end
result = result .. ",\n"
end
return result .. indent .. "}"
end
local function scanDir(dir) local function scanDir(dir)
local files = {} local files = {}
for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do
@@ -47,5 +23,5 @@ local config = {
} }
local f = io.open("config.lua", "w") local f = io.open("config.lua", "w")
f:write("return " .. serialize(config)) f:write("return " .. textutils.serialize(config))
f:close() f:close()

View File

@@ -345,4 +345,4 @@ if args[1]~= nil and args[2]~= nil then
markdown.saveToFile(output, md) markdown.saveToFile(output, md)
end end
return markdown return markdown