diff --git a/config.lua b/config.lua index 2808d01..1f4bd3e 100644 --- a/config.lua +++ b/config.lua @@ -1,351 +1,351 @@ return { ["metadata"] = { ["version"] = "2.0", - ["generated"] = "Sat Feb 22 10:26:48 2025", + ["generated"] = "Sun Feb 23 10:12:02 2025", }, ["categories"] = { - ["core"] = { - ["files"] = { - ["log"] = { - ["description"] = "", - ["size"] = 3140, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "log.lua", - }, - ["elementManager"] = { - ["description"] = "", - ["size"] = 6290, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "elementManager.lua", - }, - ["errorManager"] = { - ["description"] = "", - ["size"] = 3789, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "errorManager.lua", - }, - ["init"] = { - ["description"] = "", - ["size"] = 519, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "init.lua", - }, - ["main"] = { - ["description"] = "", - ["size"] = 7781, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "main.lua", - }, - ["render"] = { - ["description"] = "", - ["size"] = 10919, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "render.lua", - }, - ["propertySystem"] = { - ["description"] = "", - ["size"] = 15220, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "propertySystem.lua", - }, - }, - ["description"] = "Core Files", - }, ["elements"] = { + ["description"] = "UI Elements", ["files"] = { - ["Container"] = { - ["description"] = "The container class. It is a visual element that can contain other elements. It is the base class for all containers", - ["size"] = 21693, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/Container.lua", - }, ["Label"] = { - ["description"] = "", - ["size"] = 2848, ["default"] = true, + ["size"] = 2848, ["requires"] = { [1] = "VisualElement", }, ["path"] = "elements/Label.lua", - }, - ["Button"] = { - ["description"] = "Standard button element with click handling and state management", - ["size"] = 1837, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/Button.lua", - }, - ["Checkbox"] = { ["description"] = "", - ["size"] = 2874, + }, + ["Container"] = { ["default"] = true, + ["size"] = 21768, ["requires"] = { [1] = "VisualElement", }, - ["path"] = "elements/Checkbox.lua", - }, - ["Table"] = { - ["description"] = "", - ["size"] = 8475, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/Table.lua", - }, - ["BaseElement"] = { - ["description"] = "The base class for all UI elements in Basalt", - ["size"] = 8969, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "elements/BaseElement.lua", - }, - ["Slider"] = { - ["description"] = "", - ["size"] = 4465, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/Slider.lua", - }, - ["ProgressBar"] = { - ["description"] = "", - ["size"] = 2348, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/ProgressBar.lua", - }, - ["Scrollbar"] = { - ["description"] = "", - ["size"] = 7793, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/Scrollbar.lua", - }, - ["Program"] = { - ["description"] = "", - ["size"] = 5589, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/Program.lua", - }, - ["Input"] = { - ["description"] = "A text input field with various features", - ["size"] = 7180, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/Input.lua", - }, - ["BaseFrame"] = { - ["description"] = "This is the base frame class. It is the root element of all elements and the only element without a parent.", - ["size"] = 5188, - ["default"] = true, - ["requires"] = { - [1] = "Container", - }, - ["path"] = "elements/BaseFrame.lua", - }, - ["Frame"] = { - ["description"] = "", - ["size"] = 1053, - ["default"] = true, - ["requires"] = { - [1] = "Container", - }, - ["path"] = "elements/Frame.lua", - }, - ["Dropdown"] = { - ["description"] = "A dropdown menu that shows a list of selectable items", - ["size"] = 5981, - ["default"] = false, - ["requires"] = { - [1] = "List", - }, - ["path"] = "elements/Dropdown.lua", - }, - ["VisualElement"] = { - ["description"] = "The Visual Element class which is the base class for all visual UI elements", - ["size"] = 14388, - ["default"] = true, - ["requires"] = { - [1] = "BaseElement", - }, - ["path"] = "elements/VisualElement.lua", - }, - ["List"] = { - ["description"] = "A scrollable list of selectable items", - ["size"] = 8326, - ["default"] = true, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/List.lua", - }, - ["TextBox"] = { - ["description"] = "A multi-line text editor component with cursor support and text manipulation features", - ["size"] = 8976, - ["default"] = false, - ["requires"] = { - [1] = "VisualElement", - }, - ["path"] = "elements/TextBox.lua", - }, - ["Flexbox"] = { - ["description"] = "", - ["size"] = 10132, - ["default"] = true, - ["requires"] = { - [1] = "Container", - }, - ["path"] = "elements/Flexbox.lua", + ["path"] = "elements/Container.lua", + ["description"] = "The container class. It is a visual element that can contain other elements. It is the base class for all containers", }, ["Menu"] = { - ["description"] = "A horizontal menu bar with selectable", - ["size"] = 4823, ["default"] = true, + ["size"] = 4714, ["requires"] = { [1] = "List", }, ["path"] = "elements/Menu.lua", + ["description"] = "A horizontal menu bar with selectable", + }, + ["BaseElement"] = { + ["default"] = true, + ["size"] = 8969, + ["requires"] = { + }, + ["path"] = "elements/BaseElement.lua", + ["description"] = "The base class for all UI elements in Basalt", + }, + ["Scrollbar"] = { + ["default"] = true, + ["size"] = 7793, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/Scrollbar.lua", + ["description"] = "", + }, + ["TextBox"] = { + ["default"] = false, + ["size"] = 8976, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/TextBox.lua", + ["description"] = "A multi-line text editor component with cursor support and text manipulation features", + }, + ["ProgressBar"] = { + ["default"] = true, + ["size"] = 2348, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/ProgressBar.lua", + ["description"] = "", + }, + ["BaseFrame"] = { + ["default"] = true, + ["size"] = 5188, + ["requires"] = { + [1] = "Container", + }, + ["path"] = "elements/BaseFrame.lua", + ["description"] = "This is the base frame class. It is the root element of all elements and the only element without a parent.", + }, + ["Table"] = { + ["default"] = true, + ["size"] = 8475, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/Table.lua", + ["description"] = "", + }, + ["Frame"] = { + ["default"] = true, + ["size"] = 1053, + ["requires"] = { + [1] = "Container", + }, + ["path"] = "elements/Frame.lua", + ["description"] = "", + }, + ["Flexbox"] = { + ["default"] = true, + ["size"] = 10132, + ["requires"] = { + [1] = "Container", + }, + ["path"] = "elements/Flexbox.lua", + ["description"] = "", + }, + ["List"] = { + ["default"] = true, + ["size"] = 8413, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/List.lua", + ["description"] = "A scrollable list of selectable items", }, ["Tree"] = { - ["description"] = "", - ["size"] = 7284, ["default"] = true, + ["size"] = 7284, ["requires"] = { [1] = "VisualElement", }, ["path"] = "elements/Tree.lua", + ["description"] = "", + }, + ["VisualElement"] = { + ["default"] = true, + ["size"] = 14456, + ["requires"] = { + [1] = "BaseElement", + }, + ["path"] = "elements/VisualElement.lua", + ["description"] = "The Visual Element class which is the base class for all visual UI elements", + }, + ["Button"] = { + ["default"] = true, + ["size"] = 1837, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/Button.lua", + ["description"] = "Standard button element with click handling and state management", + }, + ["Dropdown"] = { + ["default"] = false, + ["size"] = 5976, + ["requires"] = { + [1] = "List", + }, + ["path"] = "elements/Dropdown.lua", + ["description"] = "A dropdown menu that shows a list of selectable items", + }, + ["Checkbox"] = { + ["default"] = true, + ["size"] = 2874, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/Checkbox.lua", + ["description"] = "", + }, + ["Slider"] = { + ["default"] = true, + ["size"] = 4465, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/Slider.lua", + ["description"] = "", + }, + ["Program"] = { + ["default"] = true, + ["size"] = 5589, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/Program.lua", + ["description"] = "", + }, + ["Input"] = { + ["default"] = true, + ["size"] = 7180, + ["requires"] = { + [1] = "VisualElement", + }, + ["path"] = "elements/Input.lua", + ["description"] = "A text input field with various features", + }, + }, + }, + ["core"] = { + ["description"] = "Core Files", + ["files"] = { + ["elementManager"] = { + ["default"] = true, + ["size"] = 6290, + ["requires"] = { + }, + ["path"] = "elementManager.lua", + ["description"] = "", + }, + ["errorManager"] = { + ["default"] = true, + ["size"] = 3789, + ["requires"] = { + }, + ["path"] = "errorManager.lua", + ["description"] = "", + }, + ["main"] = { + ["default"] = true, + ["size"] = 7849, + ["requires"] = { + }, + ["path"] = "main.lua", + ["description"] = "", + }, + ["render"] = { + ["default"] = true, + ["size"] = 10919, + ["requires"] = { + }, + ["path"] = "render.lua", + ["description"] = "", + }, + ["log"] = { + ["default"] = true, + ["size"] = 3140, + ["requires"] = { + }, + ["path"] = "log.lua", + ["description"] = "", + }, + ["propertySystem"] = { + ["default"] = true, + ["size"] = 15220, + ["requires"] = { + }, + ["path"] = "propertySystem.lua", + ["description"] = "", + }, + ["init"] = { + ["default"] = true, + ["size"] = 519, + ["requires"] = { + }, + ["path"] = "init.lua", + ["description"] = "", }, }, - ["description"] = "UI Elements", }, ["libraries"] = { + ["description"] = "Libraries", ["files"] = { ["colorHex"] = { - ["description"] = "", - ["size"] = 132, ["default"] = true, + ["size"] = 132, ["requires"] = { }, ["path"] = "libraries/colorHex.lua", + ["description"] = "", }, ["utils"] = { - ["description"] = "", - ["size"] = 2661, ["default"] = true, + ["size"] = 2661, ["requires"] = { }, ["path"] = "libraries/utils.lua", + ["description"] = "", }, ["expect"] = { - ["description"] = "", - ["size"] = 880, ["default"] = true, + ["size"] = 880, ["requires"] = { }, ["path"] = "libraries/expect.lua", + ["description"] = "", }, }, - ["description"] = "Libraries", }, ["plugins"] = { + ["description"] = "Plugins", ["files"] = { ["state"] = { - ["description"] = "", - ["size"] = 5867, ["default"] = true, + ["size"] = 5867, ["requires"] = { }, ["path"] = "plugins/state.lua", - }, - ["debug"] = { ["description"] = "", - ["size"] = 6175, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "plugins/debug.lua", - }, - ["reactive"] = { - ["description"] = "", - ["size"] = 6989, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "plugins/reactive.lua", - }, - ["pluginTemplate"] = { - ["description"] = "", - ["size"] = 695, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "plugins/pluginTemplate.lua", - }, - ["theme"] = { - ["description"] = "", - ["size"] = 5879, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "plugins/theme.lua", - }, - ["xml"] = { - ["description"] = "", - ["size"] = 6371, - ["default"] = true, - ["requires"] = { - }, - ["path"] = "plugins/xml.lua", }, ["benchmark"] = { - ["description"] = "", - ["size"] = 12515, ["default"] = true, + ["size"] = 12515, ["requires"] = { }, ["path"] = "plugins/benchmark.lua", + ["description"] = "", }, ["animation"] = { - ["description"] = "", - ["size"] = 14116, ["default"] = true, + ["size"] = 14116, ["requires"] = { }, ["path"] = "plugins/animation.lua", + ["description"] = "", + }, + ["xml"] = { + ["default"] = true, + ["size"] = 6371, + ["requires"] = { + }, + ["path"] = "plugins/xml.lua", + ["description"] = "", + }, + ["reactive"] = { + ["default"] = true, + ["size"] = 6989, + ["requires"] = { + }, + ["path"] = "plugins/reactive.lua", + ["description"] = "", + }, + ["pluginTemplate"] = { + ["default"] = true, + ["size"] = 695, + ["requires"] = { + }, + ["path"] = "plugins/pluginTemplate.lua", + ["description"] = "", + }, + ["theme"] = { + ["default"] = true, + ["size"] = 5879, + ["requires"] = { + }, + ["path"] = "plugins/theme.lua", + ["description"] = "", + }, + ["debug"] = { + ["default"] = true, + ["size"] = 6175, + ["requires"] = { + }, + ["path"] = "plugins/debug.lua", + ["description"] = "", }, }, - ["description"] = "Plugins", }, }, } \ No newline at end of file diff --git a/release/basalt.lua b/release/basalt.lua index 845dbbd..cff7efd 100644 --- a/release/basalt.lua +++ b/release/basalt.lua @@ -225,19 +225,19 @@ function bd.removeSchedule(_ba) for aba,bba in ipairs(bd._schedule)do if(bba.coroutine==_ba)then table.remove(bd._schedule,aba)return true end end;return false end local function caa(_ba,...)if(_ba=="terminate")then bd.stop()end -if baa(_ba,...)then return end -if(cd)then if(cd:dispatchEvent(_ba,...))then return end end -for aba,bba in ipairs(bd._schedule)do if(_ba==bba.filter)then +if baa(_ba,...)then return end;if(cd)then cd:dispatchEvent(_ba,...)end +for aba,bba in +ipairs(bd._schedule)do +if(_ba==bba.filter)or(bba.filter==nil)then local cba,dba=coroutine.resume(bba.coroutine,_ba,...) -if(not cba)then dc.header="Basalt Schedule Error"dc.error(dba)end end -if( -coroutine.status(bba.coroutine)=="dead")then bd.removeSchedule(bba.coroutine)end end;if bd._events[_ba]then +if(not cba)then dc.header="Basalt Schedule Error"dc.error(dba)end;bba.filter=dba end;if(coroutine.status(bba.coroutine)=="dead")then +bd.removeSchedule(bba.coroutine)end end;if bd._events[_ba]then for aba,bba in ipairs(bd._events[_ba])do bba(...)end end end;local function daa()if(cd)then cd:render()end end;function bd.update(...)caa(...) -daa()end;function bd.stop()term.clear() -term.setCursorPos(1,1)dd=false end -function bd.run(_ba)dd=_ba -if(_ba==nil)then dd=true end;local function aba()daa() -while dd do caa(os.pullEventRaw())daa()end end +daa()end;function bd.stop()dd=false;term.clear() +term.setCursorPos(1,1)end +function bd.run(_ba)dd=_ba;if(_ba==nil)then dd=true end;local function aba() +daa() +while dd do caa(os.pullEventRaw())if(dd)then daa()end end end while dd do local bba,cba=pcall(aba)if not(bba)then dc.header="Basalt Runtime Error"dc.error(cba)end end end;function bd.getAPI(_ba)return cc.getAPI(_ba)end;return bd end project["init.lua"] = function(...) local da={...}local _b=fs.getDir(da[2])local ab=package.path @@ -1092,10 +1092,11 @@ bb["addDelayed"..bc]=function(cc,dc)_b(1,cc,"table") local _d=cc.basalt.create(_c,dc,true,cc)return _d end end end function bb.new()local _c=setmetatable({},bb):__init()return _c end function bb:init(_c,ac)da.init(self,_c,ac)self.set("type","Container")end -function bb:isChildVisible(_c)local ac,bc=self.get("width"),self.get("height") -local cc,dc=self.get("offsetX"),self.get("offsetY")local _d,ad=_c.get("x"),_c.get("y") -local bd,cd=_c.get("width"),_c.get("height")local dd;local __a -if(_c.get("ignoreOffset"))then dd=_d;__a=ad else dd=_d-cc;__a=ad-dc end;return +function bb:isChildVisible(_c)if(_c.get("visible")==false)then return false end +local ac,bc=self.get("width"),self.get("height")local cc,dc=self.get("offsetX"),self.get("offsetY") +local _d,ad=_c.get("x"),_c.get("y")local bd,cd=_c.get("width"),_c.get("height")local dd;local __a;if +(_c.get("ignoreOffset"))then dd=_d;__a=ad else dd=_d-cc;__a=ad-dc end +return (dd+bd>0)and(dd<=ac)and(__a+cd>0)and(__a<=bc)end function bb:addChild(_c) if _c==self then error("Cannot add container to itself")end;table.insert(self._values.children,_c) @@ -1221,9 +1222,9 @@ if not self.get("childrenEventsSorted")then for _c in pairs(self._values.childrenEvents)do self:sortChildrenEvents(_c)end end for _c,ac in ipairs(self.get("visibleChildren"))do if ac==self then -self.basalt.LOGGER.error("CIRCULAR REFERENCE DETECTED!")return end;ac:render()end end;function bb:destroy() -for _c,ac in ipairs(self._values.children)do ac:destroy()end;da.destroy(self)end;return -bb end +self.basalt.LOGGER.error("CIRCULAR REFERENCE DETECTED!")return end;ac:render()end end +function bb:destroy() +for _c,ac in ipairs(self._values.children)do ac:destroy()end;da.destroy(self)return self end;return bb end project["elements/Slider.lua"] = function(...) local c=require("elements/VisualElement") local d=setmetatable({},c)d.__index=d d.defineProperty(d,"step",{default=1,type="number",canTriggerRender=true}) @@ -1413,7 +1414,7 @@ if db then cb.parent:setFocusedChild(cb)else cb.parent:setFocusedChild(nil)end end;return db end}) _b.defineProperty(_b,"visible",{default=true,type="boolean",canTriggerRender=true,setter=function(cb,db) if(cb.parent~=nil)then -cb.parent.set("childrenSorted",false)cb.parent.set("childrenEventsSorted",false)end;return db end}) +cb.parent.set("childrenSorted",false)cb.parent.set("childrenEventsSorted",false)end;if(db==false)then cb.set("clicked",false)end;return db end}) _b.defineProperty(_b,"ignoreOffset",{default=false,type="boolean"})_b.combineProperties(_b,"position","x","y") _b.combineProperties(_b,"size","width","height") _b.combineProperties(_b,"color","foreground","background")_b.defineEvent(_b,"focus") @@ -1562,7 +1563,7 @@ local aa=self.get("items")table.remove(aa,_a)self:updateRender()return self end function d:clear()self.set("items",{})self:updateRender()return self end function d:getSelectedItems()local _a={}for aa,ba in ipairs(self.get("items"))do if -type(ba)=="table"and ba.selected then table.insert(_a,{index=aa,item=ba})end end;return _a end +type(ba)=="table"and ba.selected then local ca=ba;ca.index=aa;table.insert(_a,ca)end end;return _a end function d:mouse_click(_a,aa,ba) if _a==1 and self:isInBounds(aa,ba)and self.get("selectable")then local ca,da=self:getRelativePosition(aa,ba) @@ -1590,13 +1591,13 @@ type(_b)=="string"then _b={text=_b}_a[da]=_b end if _b.separator then local ab=(_b.text or"-"):sub(1,1)local bb=string.rep(ab,ca) local cb=_b.foreground or self.get("foreground")local db=_b.background or self.get("background") -self:textBg(1,i,string.rep(" ",ca),db)self:textFg(1,i,bb,cb)else local ab=_b.text;local bb=_b.selected -local cb=bb and(_b.selectedBackground or -self.get("selectedBackground"))or(_b.background or -self.get("background")) +self:textBg(1,i,string.rep(" ",ca),db)self:textFg(1,i,bb:sub(1,ca),cb)else local ab=_b.text +local bb=_b.selected +local cb= +bb and(_b.selectedBackground or self.get("selectedBackground"))or(_b.background or self.get("background")) local db= bb and(_b.selectedForeground or self.get("selectedForeground"))or(_b.foreground or self.get("foreground"))self:textBg(1,i,string.rep(" ",ca),cb) -self:textFg(1,i,ab,db)end end end end;return d end +self:textFg(1,i,ab:sub(1,ca),db)end end end end;return d end project["elements/Tree.lua"] = function(...) local _a=require("elements/VisualElement")local aa=string.sub local ba=setmetatable({},_a)ba.__index=ba ba.defineProperty(ba,"nodes",{default={},type="table",canTriggerRender=true}) @@ -1764,13 +1765,13 @@ if not self.get("multiSelection")then for bc,cc in ipairs(_c)do if type(cc)=="ta cc.selected=false end end end;ac.selected=not ac.selected if ac.callback then ac.callback(self)end;self:fireEvent("select",db,ac) self.set("isOpen",false)self.set("height",1)self:updateRender()return true end end;return false end -function ca:render()_a.render(self)local da=self.get("selectedText") -if -#da==0 then local _b=self:getSelectedItems()if#_b>0 then local ab=_b[1].item +function ca:render()_a.render(self)local da=self.get("selectedText")if +#da==0 then local _b=self:getSelectedItems()if#_b>0 then local ab=_b[1] da=ab.text or""end end -self:blit(1,1,da.. - -string.rep(" ",self.get("width")-#da-1).. (self.get("isOpen")and"\31"or"\17"),string.rep(ba[self.get("foreground")],self.get("width")),string.rep(ba[self.get("background")],self.get("width"))) +self:blit(1,1, +da.. +string.rep(" ",self.get("width")-#da-1).. ( +self.get("isOpen")and"\31"or"\17"),string.rep(ba[self.get("foreground")],self.get("width")),string.rep(ba[self.get("background")],self.get("width"))) if self.get("isOpen")then local _b=self.get("items") local ab=self.get("height")-1;local bb=self.get("offset")local cb=self.get("width") for i=1,ab do local db=i+bb