diff --git a/basalt-minfied.lua b/basalt-minfied.lua deleted file mode 100644 index d74fbe8..0000000 --- a/basalt-minfied.lua +++ /dev/null @@ -1 +0,0 @@ -local a={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local b={debugger=true,version=1}local c;local d={}local e={}local f=term.current()local g=string.sub;local function h(i,j,k)i=string.sub(i,1,j)local l=j-string.len(i)if k=="right"then i=string.rep(" ",l)..i elseif k=="center"then i=string.rep(" ",math.floor(l/2))..i..string.rep(" ",math.floor(l/2))i=i..(string.len(i)=1 and O<=w then if N+i:len()>0 and N<=v then local P=x[O]local Q;local R=N+#i-1;if N<1 then local S=1-N+1;local T=v-N+1;i=g(i,S,T)elseif R>v then local T=v-N+1;i=g(i,1,T)end;if N>1 then local T=N-1;Q=g(P,1,T)..i else Q=i end;if R=1 and O<=w then if N+V:len()>0 and N<=v then local P=y[O]local Q;local R=N+#V-1;if N<1 then V=g(V,1-N+1,v-N+1)elseif R>v then V=g(V,1,v-N+1)end;if N>1 then Q=g(P,1,N-1)..V else Q=V end;if R=1 and O<=w then if N+V:len()>0 and N<=v then local P=z[O]local Q;local R=N+#V-1;if N<1 then local S=1-N+1;local T=v-N+1;V=g(V,S,T)elseif R>v then local T=v-N+1;V=g(V,1,T)end;if N>1 then local T=N-1;Q=g(P,1,T)..V else Q=V end;if RN and aO<=O and aO+self.h>O and at then if self.parent~=nil then self.parent:setFocusedObject(self)end;av:sendEvent(a7,self,a7,aM,N,O)return true end;return false end,keyHandler=function(self,a7,aP)if self:isFocused()then av:sendEvent(a7,self,a7,aP)return true end;return false end,backgroundKeyHandler=function(self,a7,aP)av:sendEvent("background_"..a7,self,a7,aP)end,valueChangedHandler=function(self)av:sendEvent("value_changed",self)end,eventHandler=function(self,a7,aQ,aR,aS,aT)av:sendEvent("custom_event_handler",self,a7,aQ,aR,aS,aT)end,getFocusHandler=function(self)av:sendEvent("get_focus",self)end,loseFocusHandler=function(self)av:sendEvent("lose_focus",self)end}aw.__index=aw;return aw end;local function aU(am)local aV=al(am)local an="Button"aV:setValue("Button")aV:setZIndex(5)aV.w=8;aV.bgcolor=a.ButtonBG;aV.fgcolor=a.ButtonFG;local aW="center"local aX="center"local aw={getType=function(self)return an end,setHorizontalAlign=function(self,aY)aW=aY end,setVerticalAlign=function(self,aY)aX=aY end,setText=function(self,i)aV:setValue(i)return self end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()local b0=m(self.h,aX)self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aZ,a_,self.w,self.h,self.fgcolor)self.parent:drawTextBox(aZ,a_,self.w,self.h," ")for l=1,self.h do if l==b0 then self.parent:setText(aZ,a_+l-1,h(self:getValue(),self.w,aW))end end end end end}return setmetatable(aw,aV)end;local function b1(am)local aV=al(am)local an="Program"aV:setZIndex(5)local aw;local function b2(N,O,j,n)local b3,b4=1,1;local b5,b6=colors.black,colors.white;local b7=false;local b8=false;local x={}local y={}local z={}local b9={}local D;local E={}for r=0,15 do local ba=2^r;b9[ba]={f.getPaletteColour(ba)}end;local function F()D=(" "):rep(j)for l=0,15 do local G=2^l;local H=s[G]E[G]=H:rep(j)end end;local function I()F()local J=D;local K=E[colors.white]local L=E[colors.black]for l=1,n do x[l]=g(x[l]==nil and J or x[l]..J:sub(1,j-x[l]:len()),1,j)z[l]=g(z[l]==nil and K or z[l]..K:sub(1,j-z[l]:len()),1,j)y[l]=g(y[l]==nil and L or y[l]..L:sub(1,j-y[l]:len()),1,j)end end;I()local function bb()if b3>=1 and b4>=1 and b3<=j and b4<=n then else end end;local function bc(bd,be,bf)local bg=b3;local R=bg+#bd-1;if b4>=1 and b4<=n then if bg<=j and R>=1 then if bg==1 and R==j then x[b4]=bd;z[b4]=be;y[b4]=bf else local bh,bi,bj;if bg<1 then local bk=1-bg+1;local bl=j-bg+1;bh=g(bd,bk,bl)bi=g(be,bk,bl)bj=g(bf,bk,bl)elseif R>j then local bl=j-bg+1;bh=g(bd,1,bl)bi=g(be,1,bl)bj=g(bf,1,bl)else bh=bd;bi=be;bj=bf end;local bm=x[b4]local bn=z[b4]local bo=y[b4]local bp,bq,br;if bg>1 then local bs=bg-1;bp=g(bm,1,bs)..bh;bq=g(bn,1,bs)..bi;br=g(bo,1,bs)..bj else bp=bh;bq=bi;br=bj end;if R=1 and O<=n then x[bQ]=x[O]y[bQ]=y[O]z[bQ]=z[O]else x[bQ]=bN;z[bQ]=bO;y[bQ]=bP end end end;if b8 then bb()end end,isColor=function()return f.isColor()end,isColour=function()return f.isColor()end,write=function(i)i=tostring(i)if b8 then bc(i,s[b6]:rep(i:len()),s[b5]:rep(i:len()))end end,clearLine=function()if b8 then M(1,b4,(" "):rep(j))U(1,b4,s[b5]:rep(j))W(1,b4,s[b6]:rep(j))end;if b8 then bb()end end,clear=function()for l=1,n do M(1,l,(" "):rep(j))U(1,l,s[b5]:rep(j))W(1,l,s[b6]:rep(j))end;if b8 then bb()end end,blit=function(i,bR,bS)if type(i)~="string"then error("bad argument #1 (expected string, got "..type(i)..")",2)end;if type(bR)~="string"then error("bad argument #2 (expected string, got "..type(bR)..")",2)end;if type(bS)~="string"then error("bad argument #3 (expected string, got "..type(bS)..")",2)end;if#bR~=#i or#bS~=#i then error("Arguments must be the same length",2)end;if b8 then bc(i,bR,bS)end end}return bI end;aV.w=30;aV.h=12;local bT=b2(1,1,aV.w,aV.h)local bU;local bV=false;local bW={}aw={getType=function(self)return an end,show=function(self)aV.show(self)bT.setBackgroundColor(self.bgcolor)bT.setTextColor(self.fgcolor)bT.basalt_setVisible(true)return self end,hide=function(self)aV.hide(self)bT.basalt_setVisible(false)return self end,setPosition=function(self,N,O,aC)aV.setPosition(self,N,O,aC)bT.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return bT end,getBasaltProcess=function()return bU end,setSize=function(self,j,n)aV.setSize(self,j,n)bT.basalt_resize(self.w,self.h)return self end,getStatus=function(self)if bU~=nil then return bU:getStatus()end;return"inactive"end,execute=function(self,af,...)bU=ad:new(af,bT,...)bT.setBackgroundColor(colors.black)bT.setTextColor(colors.white)bT.clear()bT.setCursorPos(1,1)bU:resume()bV=false;return self end,stop=function(self)if bU~=nil then if not bU:isDead()then bU:resume("terminate")if bU:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,bX)bV=bX or not bV;if bU~=nil then if not bU:isDead()then if not bV then self:injectEvents(bW)bW={}end end end;return self end,isPaused=function(self)return bV end,injectEvent=function(self,a7,aQ,aR,aS,aT,bY)if bU~=nil then if not bU:isDead()then if bV==false or bY then bU:resume(a7,aQ,aR,aS,aT)else table.insert(bW,{event=a7,args={aQ,aR,aS,aT}})end end end;return self end,getQueuedEvents=function(self)return bW end,updateQueuedEvents=function(self,a5)bW=a5 or bW;return self end,injectEvents=function(self,a5)if bU~=nil then if not bU:isDead()then for aL,ab in pairs(a5)do bU:resume(ab.event,table.unpack(ab.args))end end end;return self end,mouseClickHandler=function(self,a7,aM,N,O)if aV.mouseClickHandler(self,a7,aM,N,O)then if bU==nil then return false end;if not bU:isDead()then if not bV then local bZ,b_=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))bU:resume(a7,aM,N-bZ+1,O-b_+1)end end;return true end end,keyHandler=function(self,a7,aP)aV.keyHandler(self,a7,aP)if self:isFocused()then if bU==nil then return false end;if not bU:isDead()then if not bV then if self.draw then bU:resume(a7,aP)end end end end end,getFocusHandler=function(self)aV.getFocusHandler(self)if bU~=nil then if not bU:isDead()then if not bV then if self.parent~=nil then local c0,c1=bT.getCursorPos()local aZ,a_=self:getAnchorPosition()if self.parent~=nil then if aZ+c0-1>=1 and aZ+c0-1<=aZ+self.w-1 and c1+a_-1>=1 and c1+a_-1<=a_+self.h-1 then self.parent:setCursor(bT.getCursorBlink(),aZ+c0-1,c1+a_-1,bT.getTextColor())end end end end end end end,loseFocusHandler=function(self)aV.loseFocusHandler(self)if bU~=nil then if not bU:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,a7,aQ,aR,aS,aT)if bU==nil then return end;if not bU:isDead()then if not bV then if a7~="mouse_click"and a7~="mouse_up"and a7~="mouse_scroll"and a7~="mouse_drag"and a7~="key_up"and a7~="key"and a7~="char"and a7~="terminate"then bU:resume(a7,aQ,aR,aS,aT)end;if self:isFocused()then local aZ,a_=self:getAnchorPosition()local c0,c1=bT.getCursorPos()if self.parent~=nil then if aZ+c0-1>=1 and aZ+c0-1<=aZ+self.w-1 and c1+a_-1>=1 and c1+a_-1<=a_+self.h-1 then self.parent:setCursor(bT.getCursorBlink(),aZ+c0-1,c1+a_-1,bT.getTextColor())end end;if a7=="terminate"and self:isFocused()then self:stop()end end else if a7~="mouse_click"and a7~="mouse_up"and a7~="mouse_scroll"and a7~="mouse_drag"and a7~="key_up"and a7~="key"and a7~="char"and a7~="terminate"then table.insert(bW,{event=a7,args={aQ,aR,aS,aT}})end end end end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()bT.basalt_reposition(aZ,a_)self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)bT.basalt_update()end end end}return setmetatable(aw,aV)end;local function c2(am)local aV=al(am)local an="Label"aV:setZIndex(3)local c3=true;aV:setValue("")local aw={getType=function(self)return an end,setText=function(self,i)i=tostring(i)aV:setValue(i)if c3 then self.w=i:len()end;return self end,setSize=function(self,j,n)self.w,self.h=j,n;c3=false;return self end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()self.parent:writeText(aZ,a_,self:getValue(),self.bgcolor,self.fgcolor)end end end}return setmetatable(aw,aV)end;local function c4(am)local aV=al(am)local an="Pane"local aw={getType=function(self)return an end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aZ,a_,self.w,self.h,self.bgcolor)end end end}return setmetatable(aw,aV)end;local function c5(am)local aV=al(am)local an="Image"aV:setZIndex(2)local c6;local c7;local c8=false;local function c9()local ca={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local cb,cc,cd={},{},{}for r=0,15 do cc[2^r]=r end;do local ce="0123456789abcdef"for r=1,16 do cb[ce:sub(r,r)]=r-1;cb[r-1]=ce:sub(r,r)cd[ce:sub(r,r)]=2^(r-1)cd[2^(r-1)]=ce:sub(r,r)local cf=ca[r-1]for r=1,#cf do cf[r]=2^cf[r]end end end;local function cg(ch)local ci=ca[cc[ch[#ch][1]]]for cj=1,#ci do local ck=ci[cj]for r=1,#ch-1 do if ch[r][1]==ck then return r end end end;return 1 end;local function cl(cm,cn)if not cn then local co={}cn={}for r=1,6 do local cp=cm[r]local cq=cn[cp]cn[cp],co[r]=cq and cq+1 or 1,cp end;cm=co end;local ch={}for aP,ao in pairs(cn)do ch[#ch+1]={aP,ao}end;if#ch>1 then while#ch>2 do table.sort(ch,function(cr,bF)return cr[2]>bF[2]end)local cs,ct=cg(ch),#ch;local cu,cv=ch[ct][1],ch[cs][1]for r=1,6 do if cm[r]==cu then cm[r]=cv;ch[cs][2]=ch[cs][2]+1 end end;ch[ct]=nil end;local cw=128;for r=1,#cm-1 do if cm[r]~=cm[6]then cw=cw+2^(r-1)end end;return string.char(cw),cd[ch[1][1]==cm[6]and ch[2][1]or ch[1][1]],cd[cm[6]]else return"\128",cd[cm[1]],cd[cm[1]]end end;local cx,v,w,Y={{},{},{}},0,#c6+#c6%3,aV.bgcolor or colors.black;for r=1,#c6 do if#c6[r]>v then v=#c6[r]end end;for O=0,w-1,3 do local cy,cz,cA,cB={},{},{},1;for N=0,v-1,2 do local cm,cn={},{}for cC=1,3 do for cD=1,2 do cm[#cm+1]=c6[O+cC]and c6[O+cC][N+cD]and(c6[O+cC][N+cD]==0 and Y or c6[O+cC][N+cD])or Y;cn[cm[#cm]]=cn[cm[#cm]]and cn[cm[#cm]]+1 or 1 end end;cy[cB],cz[cB],cA[cB]=cl(cm,cn)cB=cB+1 end;cx[1][#cx[1]+1],cx[2][#cx[2]+1],cx[3][#cx[3]+1]=table.concat(cy),table.concat(cz),table.concat(cA)end;cx.width,cx.height=#cx[1][1],#cx[1]c7=cx end;local aw={getType=function(self)return an end,loadImage=function(self,af)c6=paintutils.loadImage(af)c8=false;return self end,loadBlittleImage=function(self,af)c8=true;return self end,shrinkImage=function(self)c9()c8=true;return self end,draw=function(self)if aV.draw(self)then if self.parent~=nil then if c6~=nil then local aZ,a_=self:getAnchorPosition()if c8 then local q,cE,cF=c7[1],c7[2],c7[3]for r=1,c7.height do local cG=q[r]if type(cG)=="string"then self.parent:setText(aZ,a_+r-1,cG)self.parent:setFG(aZ,a_+r-1,cE[r])self.parent:setBG(aZ,a_+r-1,cF[r])elseif type(cG)=="table"then self.parent:setText(aZ,a_+r-1,cG[2])self.parent:setFG(aZ,a_+r-1,cE[r])self.parent:setBG(aZ,a_+r-1,cF[r])end end else for aB=1,math.min(#c6,self.h)do local cH=c6[aB]for aA=1,math.min(#cH,self.w)do if cH[aA]>0 then self.parent:drawBackgroundBox(aZ+aA-1,a_+aB-1,1,1,cH[aA])end end end end end end end end}return setmetatable(aw,aV)end;local function cI(am)local aV=al(am)local an="Checkbox"aV:setZIndex(5)aV:setValue(false)aV.w=1;aV.h=1;aV.bgcolor=a.CheckboxBG;aV.fgcolor=a.CheckboxFG;local aw={symbol="\42",getType=function(self)return an end,mouseClickHandler=function(self,a7,aM,N,O)if aV.mouseClickHandler(self,a7,aM,N,O)then if a7=="mouse_click"and aM==1 then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()local b0=m(self.h,"center")self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)for l=1,self.h do if l==b0 then if self:getValue()==true then self.parent:writeText(aZ,a_+l-1,h(self.symbol,self.w,"center"),self.bgcolor,self.fgcolor)else self.parent:writeText(aZ,a_+l-1,h(" ",self.w,"center"),self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(aw,aV)end;local function cJ(am)local aV=al(am)local an="Progressbar"local cK=0;aV:setZIndex(5)aV:setValue(false)aV.w=25;aV.h=1;aV.bgcolor=a.CheckboxBG;aV.fgcolor=a.CheckboxFG;local cL=colors.black;local cM=""local cN=colors.white;local cO=""local cP=0;local aw={getType=function(self)return an end,setDirection=function(self,cQ)cP=cQ;return self end,setProgressBar=function(self,aE,_,cR)cL=aE or cL;cM=_ or cM;cN=cR or cN;return self end,setBackgroundSymbol=function(self,_)cO=_:sub(1,1)return self end,setProgress=function(self,ao)if ao>=0 and ao<=100 and cK~=ao then cK=ao;self:setValue(cK)if cK==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return cK end,onProgressDone=function(self,cS)self:registerEvent("progress_done",cS)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aZ,a_,self.w,self.h,self.fgcolor)self.parent:drawTextBox(aZ,a_,self.w,self.h,cO)if cP==1 then self.parent:drawBackgroundBox(aZ,a_,self.w,self.h/100*cK,cL)self.parent:drawForegroundBox(aZ,a_,self.w,self.h/100*cK,cN)self.parent:drawTextBox(aZ,a_,self.w,self.h/100*cK,cM)elseif cP==2 then self.parent:drawBackgroundBox(aZ,a_+math.ceil(self.h-self.h/100*cK),self.w,self.h/100*cK,cL)self.parent:drawForegroundBox(aZ,a_+math.ceil(self.h-self.h/100*cK),self.w,self.h/100*cK,cN)self.parent:drawTextBox(aZ,a_+math.ceil(self.h-self.h/100*cK),self.w,self.h/100*cK,cM)elseif cP==3 then self.parent:drawBackgroundBox(aZ+math.ceil(self.w-self.w/100*cK),a_,self.w/100*cK,self.h,cL)self.parent:drawForegroundBox(aZ+math.ceil(self.w-self.w/100*cK),a_,self.w/100*cK,self.h,cN)self.parent:drawTextBox(aZ+math.ceil(self.w-self.w/100*cK),a_,self.w/100*cK,self.h,cM)else self.parent:drawBackgroundBox(aZ,a_,self.w/100*cK,self.h,cL)self.parent:drawForegroundBox(aZ,a_,self.w/100*cK,self.h,cN)self.parent:drawTextBox(aZ,a_,self.w/100*cK,self.h,cM)end end end end}return setmetatable(aw,aV)end;local function cT(am)local aV=al(am)local an="Input"local cU="text"local cV=0;aV:setZIndex(5)aV:setValue("")aV.w=10;aV.h=1;aV.bgcolor=a.InputBG;aV.fgcolor=a.InputFG;local cW=1;local cX=1;local cY=""local cZ;local c_;local d0=cY;local d1=false;local aw={getType=function(self)return an end,setInputType=function(self,d2)if d2=="password"or d2=="number"or d2=="text"then cU=d2 end;return self end,setDefaultText=function(self,i,d3,d4)cY=i;cZ=d4 or cZ;c_=d3 or c_;if self:isFocused()then d0=""else d0=cY end;return self end,getInputType=function(self)return cU end,setValue=function(self,d5)aV.setValue(self,tostring(d5))if not d1 then cW=tostring(d5):len()+1 end;return self end,getValue=function(self)local d5=aV.getValue(self)return cU=="number"and tonumber(d5)or d5 end,setInputLimit=function(self,d6)cV=tonumber(d6)or cV;return self end,getInputLimit=function(self)return cV end,getFocusHandler=function(self)aV.getFocusHandler(self)if self.parent~=nil then local aZ,a_=self:getAnchorPosition()d0=""if self.parent~=nil then self.parent:setCursor(true,aZ+cW-cX,a_,self.fgcolor)end end end,loseFocusHandler=function(self)aV.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)d0=cY end end,keyHandler=function(self,a7,aP)if aV.keyHandler(self,a7,aP)then d1=true;if a7=="key"then if aP==keys.backspace then local i=tostring(aV.getValue())if cW>1 then self:setValue(i:sub(1,cW-2)..i:sub(cW,i:len()))if cW>1 then cW=cW-1 end;if cX>1 then if cWd7 then cW=d7+1 end;if cW<1 then cW=1 end;if cW=self.w+cX then cX=cW-self.w+1 end;if cX<1 then cX=1 end end;if aP==keys.left then cW=cW-1;if cW>=1 then if cW=self.w+cX then cX=cW end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a7=="char"then local i=aV.getValue()if i:len()=self.w+cX then cX=cX+1 end end end;local aZ,a_=self:getAnchorPosition()local d5=tostring(aV.getValue())local d9=(cW<=d5:len()and cW-1 or d5:len())-(cX-1)if d9>self.x+self.w-1 then d9=self.x+self.w-1 end;if self.parent~=nil then self.parent:setCursor(true,aZ+d9,a_,self.fgcolor)end;d1=false end end,mouseClickHandler=function(self,a7,aM,N,O)if aV.mouseClickHandler(self,a7,aM,N,O)then if a7=="mouse_click"and aM==1 then end;return true end;return false end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()local b0=m(self.h,"center")self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)for l=1,self.h do if l==b0 then local d5=tostring(aV.getValue())local d4=self.bgcolor;local d3=self.fgcolor;local i;if d5:len()<=0 then i=d0;d4=cZ or d4;d3=c_ or d3 end;i=d0;if d5~=""then i=d5 end;i=i:sub(cX,self.w+cX-1)local da=self.w-i:len()if da<0 then da=0 end;if cU=="password"and d5~=""then i=string.rep("*",i:len())end;i=i..string.rep(" ",da)self.parent:writeText(aZ,a_+l-1,i,d4,d3)end end end end end}return setmetatable(aw,aV)end;local function db(am)local aV=al(am)local an="Textfield"local dc,cX,cW,dd=1,1,1,1;local de={""}local df={[colors.purple]={"break"}}aV.w=20;aV.h=8;aV.bgcolor=a.textfieldBG;aV.fgcolor=a.textfieldFG;aV:setZIndex(5)local aw={getType=function(self)return an end,getLines=function(self)return de end,getLine=function(self,a6)return de[a6]or""end,editLine=function(self,a6,i)de[a6]=i or de[a6]return self end,addLine=function(self,i,a6)if a6~=nil then table.insert(de,a6,i)else table.insert(de,i)end;return self end,addKeyword=function(self,dg,aE)end,removeLine=function(self,a6)table.remove(de,a6 or#de)if#de<=0 then table.insert(de,"")end;return self end,getTextCursor=function(self)return cW,dd end,getFocusHandler=function(self)aV.getFocusHandler(self)if self.parent~=nil then local aZ,a_=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,aZ+cW-cX,a_+dd-dc,self.fgcolor)end end end,loseFocusHandler=function(self)aV.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,a7,aP)if aV.keyHandler(self,a7,aP)then local aZ,a_=self:getAnchorPosition()if a7=="key"then if aP==keys.backspace then if de[dd]==""then if dd>1 then table.remove(de,dd)cW=de[dd-1]:len()+1;cX=cW-self.w+1;if cX<1 then cX=1 end;dd=dd-1 end elseif cW<=1 then if dd>1 then cW=de[dd-1]:len()+1;cX=cW-self.w+1;if cX<1 then cX=1 end;de[dd-1]=de[dd-1]..de[dd]table.remove(de,dd)dd=dd-1 end else de[dd]=de[dd]:sub(1,cW-2)..de[dd]:sub(cW,de[dd]:len())if cW>1 then cW=cW-1 end;if cX>1 then if cWde[dd]:len()then if de[dd+1]~=nil then de[dd]=de[dd]..de[dd+1]table.remove(de,dd+1)end else de[dd]=de[dd]:sub(1,cW-1)..de[dd]:sub(cW+1,de[dd]:len())end end;if aP==keys.enter then table.insert(de,dd+1,de[dd]:sub(cW,de[dd]:len()))de[dd]=de[dd]:sub(1,cW-1)dd=dd+1;cW=1;cX=1;if dd-dc>=self.h then dc=dc+1 end;self:setValue("")end;if aP==keys.up then if dd>1 then dd=dd-1;if cW>de[dd]:len()+1 then cW=de[dd]:len()+1 end;if cX>1 then if cW1 then if ddde[dd]:len()+1 then cW=de[dd]:len()+1 end;if dd>=dc+self.h then dc=dc+1 end end end;if aP==keys.right then cW=cW+1;if dd<#de then if cW>de[dd]:len()+1 then cW=1;dd=dd+1 end elseif cW>de[dd]:len()then cW=de[dd]:len()+1 end;if cW<1 then cW=1 end;if cW=self.w+cX then cX=cW-self.w+1 end;if cX<1 then cX=1 end end;if aP==keys.left then cW=cW-1;if cW>=1 then if cW=self.w+cX then cX=cW end end;if dd>1 then if cW<1 then dd=dd-1;cW=de[dd]:len()+1;cX=cW-self.w+1 end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a7=="char"then de[dd]=de[dd]:sub(1,cW-1)..aP..de[dd]:sub(cW,de[dd]:len())cW=cW+1;if cW>=self.w+cX then cX=cX+1 end;self:setValue("")end;local d9=(cW<=de[dd]:len()and cW-1 or de[dd]:len())-(cX-1)if d9>self.x+self.w-1 then d9=self.x+self.w-1 end;local dh=dd-dcde[dd]:len()then cW=de[dd]:len()+1 end;if cWde[dd]:len()then cW=de[dd]:len()+1 end;if cW#de-(self.h-1)then dc=#de-(self.h-1)end;if dc<1 then dc=1 end;if self.parent~=nil then if aZ+cW-cX>=aZ and aZ+cW-cX<=aZ+self.w and(a_+dd-dc>=a_ and a_+dd-dc<=a_+self.h)then self.parent:setCursor(true,di+cW-cX,dj+dd-dc)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(aZ,a_,self.w,self.h,self.fgcolor)for l=1,self.h do local i=""if de[l+dc-1]~=nil then i=de[l+dc-1]end;i=i:sub(cX,self.w+cX-1)local da=self.w-i:len()if da<0 then da=0 end;i=i..string.rep(" ",da)self.parent:setText(aZ,a_+l-1,i)end end end end}return setmetatable(aw,aV)end;local function dk(am)local aV=al(am)local an="List"aV.w=16;aV.h=6;aV.bgcolor=a.listBG;aV.fgcolor=a.listFG;aV:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dr=0;local ds=true;local aw={getType=function(self)return an end,addItem=function(self,i,Y,Z,...)table.insert(dl,{text=i,bgCol=Y or self.bgcolor,fgCol=Z or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,setIndexOffset=function(self,dt)dr=dt;return self end,getIndexOffset=function(self)return dr end,removeItem=function(self,a6)table.remove(dl,a6)return self end,getItem=function(self,a6)return dl[a6]end,getItemIndex=function(self)local du=self:getValue()for aa,ab in pairs(dl)do if ab==du then return aa end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a6,i,Y,Z,...)table.remove(dl,a6)table.insert(dl,a6,{text=i,bgCol=Y or self.bgcolor,fgCol=Z or self.fgcolor,args={...}})return self end,selectItem=function(self,a6)self:setValue(dl[a6]or{})return self end,setSelectedItem=function(self,Y,Z,dv)dm=Y or self.bgcolor;dn=Z or self.fgcolor;dp=dv;return self end,setScrollable=function(self,dw)ds=dw;return self end,mouseClickHandler=function(self,a7,aM,N,O)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if aZ<=N and aZ+self.w>N and a_<=O and a_+self.h>O and self:isVisible()then if a7=="mouse_click"or a7=="mouse_drag"then if aM==1 then if#dl>0 then for l=1,self.h do if dl[l+dr]~=nil then if aZ<=N and aZ+self.w>N and a_+l-1==O then self:setValue(dl[l+dr])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dl[l+dr])end end end end end end;if a7=="mouse_scroll"and ds then dr=dr+aM;if dr<0 then dr=0 end;if aM>=1 then if#dl>self.h then if dr>#dl-self.h then dr=#dl-self.h end;if dr>=#dl then dr=#dl-1 end else dr=dr-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)for l=1,self.h do if dl[l+dr]~=nil then if dl[l+dr]==self:getValue()then if dp then self.parent:writeText(aZ,a_+l-1,h(dl[l+dr].text,self.w,dq),dm,dn)else self.parent:writeText(aZ,a_+l-1,h(dl[l+dr].text,self.w,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end else self.parent:writeText(aZ,a_+l-1,h(dl[l+dr].text,self.w,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end end end end end end}return setmetatable(aw,aV)end;local function dx(am)local aV=al(am)local an="Menubar"local aw={}aV.w=30;aV.h=1;aV.bgcolor=colors.gray;aV.fgcolor=colors.lightGray;aV:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dy=0;local da=2;local ds=false;local function dz()local dA=0;local aA=1;for l=1,#dl do if aA+dl[l].text:len()+da*2>aw.w then dA=dA+dl[l].text:len()+da*2 end;aA=aA+dl[l].text:len()+da*2 end;return dA end;aw={getType=function(self)return an end,addItem=function(self,i,Y,Z,...)table.insert(dl,{text=i,bgCol=Y or self.bgcolor,fgCol=Z or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,getItemIndex=function(self)local du=self:getValue()for aa,ab in pairs(dl)do if ab==du then return aa end end end,clear=function(self)dl={}self:setValue({})return self end,setSpace=function(self,dB)da=dB or da;return self end,setButtonOffset=function(self,o)dy=o or 0;if dy<0 then dy=0 end;local dA=dz()if dy>dA then dy=dA end;return self end,setScrollable=function(self,dw)ds=dw;return self end,removeItem=function(self,a6)table.remove(dl,a6)return self end,getItem=function(self,a6)return dl[a6]end,getItemCount=function(self)return#dl end,editItem=function(self,a6,i,Y,Z,...)table.remove(dl,a6)table.insert(dl,a6,{text=i,bgCol=Y or self.bgcolor,fgCol=Z or self.fgcolor,args={...}})return self end,selectItem=function(self,a6)self:setValue(dl[a6]or{})return self end,setSelectedItem=function(self,Y,Z,dv)dm=Y or self.bgcolor;dn=Z or self.fgcolor;dp=dv;return self end,mouseClickHandler=function(self,a7,aM,N,O)local aN,aO=self:getAbsolutePosition(self:getAnchorPosition())if aN<=N and aN+self.w>N and aO<=O and aO+self.h>O and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if a7=="mouse_click"then local aA=1;for l=1+dy,#dl do if dl[l]~=nil then if aA+dl[l].text:len()+da*2<=self.w then if aN+aA-1<=N and aN+aA-1+dl[l].text:len()+da*2>N and aO==O then self:setValue(dl[l])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dl[l])end;aA=aA+dl[l].text:len()+da*2 else break end end end end;if a7=="mouse_scroll"and ds then dy=dy+aM;if dy<0 then dy=0 end;local dA=dz()if dy>dA then dy=dA end end;return true end;return false end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)local aA=0;for aa,ab in pairs(dl)do if aA+ab.text:len()+da*2<=self.w then if ab==self:getValue()then self.parent:writeText(aZ+aA-1+-dy,a_,h((" "):rep(da)..ab.text..(" "):rep(da),ab.text:len()+da*2,dq),dm or ab.bgCol,dn or ab.fgCol)else self.parent:writeText(aZ+aA-1+-dy,a_,h((" "):rep(da)..ab.text..(" "):rep(da),ab.text:len()+da*2,dq),ab.bgCol,ab.fgCol)end;aA=aA+ab.text:len()+da*2 else if aA0 then for l=1,dE do if dl[l+dr]~=nil then if aZ<=N and aZ+dD>N and a_+l==O then self:setValue(dl[l+dr])return true end end end end end end;if a7=="mouse_scroll"then dr=dr+aM;if dr<0 then dr=0 end;if aM==1 then if#dl>dE then if dr>#dl-dE then dr=#dl-dE end else dr=dl-1 end end;return true end;self:setVisualChanged()end;if aV.mouseClickHandler(self,a7,aM,N,O)then dH=2 else dH=1 end end,draw=function(self)if aV.draw(self)then local aZ,a_=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)if#dl>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if dH==1 then self.parent:writeText(aZ,a_,h(self:getValue().text,self.w,dq):sub(1,self.w-1)..dF,self.bgcolor,self.fgcolor)else self.parent:writeText(aZ,a_,h(self:getValue().text,self.w,dq):sub(1,self.w-1)..dG,self.bgcolor,self.fgcolor)end end end;if dH==2 then for l=1,dE do if dl[l+dr]~=nil then if dl[l+dr]==self:getValue()then if dp then self.parent:writeText(aZ,a_+l,h(dl[l+dr].text,dD,dq),dm,dn)else self.parent:writeText(aZ,a_+l,h(dl[l+dr].text,dD,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end else self.parent:writeText(aZ,a_+l,h(dl[l+dr].text,dD,dq),dl[l+dr].bgCol,dl[l+dr].fgCol)end end end end end end end end}return setmetatable(aw,aV)end;local function dI(am)local aV=al(am)local an="Radio"aV.w=8;aV.bgcolor=a.listBG;aV.fgcolor=a.listFG;aV:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dJ=aV.bgcolor;local dK=aV.fgcolor;local dp=true;local _="\7"local dq="left"local aw={getType=function(self)return an end,addItem=function(self,i,N,O,Y,Z,...)table.insert(dl,{x=N or 1,y=O or 1,text=i,bgCol=Y or self.bgcolor,fgCol=Z or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,removeItem=function(self,a6)table.remove(dl,a6)return self end,getItem=function(self,a6)return dl[a6]end,getItemIndex=function(self)local du=self:getValue()for aa,ab in pairs(dl)do if ab==du then return aa end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a6,i,N,O,Y,Z,...)table.remove(dl,a6)table.insert(dl,a6,{x=N or 1,y=O or 1,text=i,bgCol=Y or self.bgcolor,fgCol=Z or self.fgcolor,args={...}})return self end,selectItem=function(self,a6)self:setValue(dl[a6]or{})return self end,setSelectedItem=function(self,Y,Z,dL,dM,dv)dm=Y or dm;dn=Z or dn;dJ=dL or dJ;dK=dM or dK;dp=dv;return self end,mouseClickHandler=function(self,a7,aM,N,O)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if a7=="mouse_click"then if aM==1 then if#dl>0 then for aL,ab in pairs(dl)do if aZ+ab.x-1<=N and aZ+ab.x-1+ab.text:len()+2>=N and a_+ab.y-1==O then self:setValue(ab)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end end;return false end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()for aL,ab in pairs(dl)do if ab==self:getValue()then if dq=="left"then self.parent:writeText(ab.x+aZ-1,ab.y+a_-1,_,dJ,dK)self.parent:writeText(ab.x+2+aZ-1,ab.y+a_-1,ab.text,dm,dn)end else self.parent:drawBackgroundBox(ab.x+aZ-1,ab.y+a_-1,1,1,self.bgcolor)self.parent:writeText(ab.x+2+aZ-1,ab.y+a_-1,ab.text,ab.bgCol,ab.fgCol)end end end end end}return setmetatable(aw,aV)end;local function dN(am)local an="Timer"local dO=0;local dP=0;local dQ=0;local dR;local av=a4()local aw={name=am,getType=function(self)return an end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,dS,dT)dO=dS or 0;dP=dT or 1;return self end,start=function(self)dQ=dP;dR=os.startTimer(dO)return self end,cancel=function(self)if dR~=nil then os.cancelTimer(dR)end;return self end,onCall=function(self,a9)av:registerEvent("timed_event",a9)return self end,eventHandler=function(self,a7,dU)if a7=="timer"and dU==dR then av:sendEvent("timed_event",self)if dQ>=1 then dQ=dQ-1;if dQ>=1 then dR=os.startTimer(dO)end elseif dQ==-1 then dR=os.startTimer(dO)end end end}aw.__index=aw;return aw end;local function dV(am)local aw;local an="Thread"local a9;local dW;local dX=false;aw={name=am,getType=function(self)return an end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,cS)if cS==nil then error("function is nil")end;a9=cS;dW=coroutine.create(a9)dX=true;local aj,ak=coroutine.resume(dW)if not aj then if ak~="Terminated"then error("Threaderror - "..ak)end end;return self end,getStatus=function(self,cS)if dW~=nil then return coroutine.status(dW)end;return nil end,stop=function(self,cS)dX=false;return self end,eventHandler=function(self,a7,aQ,aR,aS)if dX then if coroutine.status(dW)~="dead"then local aj,ak=coroutine.resume(dW,a7,aQ,aR,aS)if not aj then if ak~="Terminated"then error("Threaderror - "..ak)end end else dX=false end end end}aw.__index=aw;return aw end;local function dY(am)local aw={}local an="Animation"local dR;local dZ={}local a6=1;local d_=0;local e0;local function e1()if dZ[a6]~=nil then dZ[a6].f(aw,a6)end;a6=a6+1;if dZ[a6]~=nil then if dZ[a6].t>0 then dR=os.startTimer(dZ[a6].t)else e1()end end end;aw={name=am,getType=function(self)return an end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,a9,e2)e0=a9;table.insert(dZ,{f=a9,t=e2 or d_})return self end,wait=function(self,e2)d_=e2;return self end,rep=function(self,e3)for N=1,e3 do table.insert(dZ,{f=e0,t=d_})end;return self end,clear=function(self)dZ={}e0=nil;d_=0;a6=1;return self end,play=function(self)a6=1;if dZ[a6]~=nil then if dZ[a6].t>0 then dR=os.startTimer(dZ[a6].t)else e1()end end;return self end,cancel=function(self)os.cancelTimer(dR)return self end,eventHandler=function(self,a7,dU)if a7=="timer"and dU==dR then if dZ[a6]~=nil then e1()end end end}aw.__index=aw;return aw end;local function e4(am)local aV=al(am)local an="Slider"aV.w=8;aV.bgcolor=colors.lightGray;aV.fgcolor=colors.gray;aV:setValue(1)local e5="horizontal"local _=" "local e6=colors.black;local e7="\140"local e8=aV.w;local a6=1;local aw={getType=function(self)return an end,setSymbol=function(self,e9)_=e9:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,ea)e7=string.sub(ea,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eb)e6=eb;self:setVisualChanged()return self end,setBarType=function(self,ec)e5=ec:lower()return self end,mouseClickHandler=function(self,a7,aM,N,O)if aV.mouseClickHandler(self,a7,aM,N,O)then local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if e5=="horizontal"then for ed=0,self.w-1 do if aZ+ed==N and a_<=O and a_+self.h>O then a6=ed+1;self:setValue(e8/self.w*a6)self:setVisualChanged()end end end;if e5=="vertical"then for ed=0,self.h-1 do if a_+ed==O and aZ<=N and aZ+self.w>N then a6=ed+1;self:setValue(e8/self.h*a6)self:setVisualChanged()end end end end end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()if e5=="horizontal"then self.parent:writeText(aZ,a_,e7:rep(a6-1),self.bgcolor,self.fgcolor)self.parent:writeText(aZ+a6-1,a_,_,e6,e6)self.parent:writeText(aZ+a6,a_,e7:rep(self.w-a6),self.bgcolor,self.fgcolor)end;if e5=="vertical"then for l=0,self.h-1 do if l+1==a6 then self.parent:writeText(aZ,a_+l,_,e6,e6)else self.parent:writeText(aZ,a_+l,e7,self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(aw,aV)end;local function ee(am)local aV=al(am)local an="Scrollbar"aV.w=1;aV.h=8;aV.bgcolor=colors.lightGray;aV.fgcolor=colors.gray;aV:setValue(1)aV:setZIndex(2)local e5="vertical"local _=" "local e6=colors.black;local e7="\127"local e8=aV.h;local a6=1;local ef=1;local aw={getType=function(self)return an end,setSymbol=function(self,e9)_=e9:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,eg)ef=tonumber(eg)or 1;if e5=="vertical"then self:setValue(a6-1*e8/(self.h-(ef-1))-e8/(self.h-(ef-1)))elseif e5=="horizontal"then self:setValue(a6-1*e8/(self.w-(ef-1))-e8/(self.w-(ef-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,d5)e8=d5;return self end,setBackgroundSymbol=function(self,ea)e7=string.sub(ea,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,eb)e6=eb;self:setVisualChanged()return self end,setBarType=function(self,ec)e5=ec:lower()return self end,mouseClickHandler=function(self,a7,aM,N,O)if aV.mouseClickHandler(self,a7,aM,N,O)then local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if(a7=="mouse_click"or a7=="mouse_drag")and aM==1 then if e5=="horizontal"then for ed=0,self.w do if aZ+ed==N and a_<=O and a_+self.h>O then a6=math.min(ed+1,self.w-(ef-1))self:setValue(e8/self.w*a6)self:setVisualChanged()end end end;if e5=="vertical"then for ed=0,self.h do if a_+ed==O and aZ<=N and aZ+self.w>N then a6=math.min(ed+1,self.h-(ef-1))self:setValue(e8/self.h*a6)self:setVisualChanged()end end end end;if a7=="mouse_scroll"then a6=a6+aM;if a6<1 then a6=1 end;a6=math.min(a6,(e5=="vertical"and self.h or self.w)-(ef-1))self:setValue(e8/(e5=="vertical"and self.h or self.w)*a6)end;return true end end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()if e5=="horizontal"then self.parent:writeText(aZ,a_,e7:rep(a6-1),self.bgcolor,self.fgcolor)self.parent:writeText(aZ+a6-1,a_,_:rep(ef),e6,e6)self.parent:writeText(aZ+a6+ef-1,a_,e7:rep(self.w-(a6+ef-1)),self.bgcolor,self.fgcolor)end;if e5=="vertical"then for l=0,self.h-1 do if a6==l+1 then for eh=0,math.min(ef-1,self.h)do self.parent:writeText(aZ,a_+l+eh,_,e6,e6)end else if l+1a6-1+ef then self.parent:writeText(aZ,a_+l,e7,self.bgcolor,self.fgcolor)end end end end end end end}return setmetatable(aw,aV)end;local function ei(am)local aV=al(am)local an="Switch"aV.w=3;aV.h=1;aV.bgcolor=colors.lightGray;aV.fgcolor=colors.gray;aV:setValue(false)aV:setZIndex(5)local aw={getType=function(self)return an end,mouseClickHandler=function(self,a7,aM,N,O)if aV.mouseClickHandler(self,a7,aM,N,O)then local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if(a7=="mouse_click"or a7=="mouse_drag")and aM==1 then end;return true end end,draw=function(self)if aV.draw(self)then if self.parent~=nil then local aZ,a_=self:getAnchorPosition()end end end}return setmetatable(aw,aV)end;local function ej(am,ek)local aV=al(am)local an="Frame"local el={}local em={}local aw={}local en;aV:setZIndex(10)local b7=false;local b3=1;local b4=1;local eo=colors.white;local ep,dr=0,0;if ek~=nil then aV.parent=ek;aV.w,aV.h=ek.w,ek.h;aV.bgcolor=a.FrameBG;aV.fgcolor=a.FrameFG else local eq,er=f.getSize()aV.w,aV.h=eq,er;aV.bgcolor=a.basaltBG;aV.fgcolor=a.basaltFG end;local function es(am)for aa,ab in pairs(el)do for cr,bF in pairs(ab)do if bF.name==am then return ab end end end end;local function et(eu)local ap=eu:getZIndex()if es(eu.name)~=nil then return nil end;if el[ap]==nil then for N=1,#em+1 do if em[N]~=nil then if ap==em[N]then break end;if ap>em[N]then table.insert(em,N,ap)break end else table.insert(em,ap)end end;if#em<=0 then table.insert(em,ap)end;el[ap]={}end;eu.parent=aw;table.insert(el[ap],eu)return eu end;local function ev(eu)for cr,bF in pairs(el)do for aa,ab in pairs(bF)do if ab==eu then table.remove(el[cr],aa)return true end end end;return false end;aw={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return an end,setFocusedObject=function(self,eu)for aL,a6 in pairs(em)do for aL,ab in pairs(el[a6])do if ab==eu then if en~=nil then en:loseFocusHandler()end;en=eu;en:getFocusHandler()end end end;return self end,setOffset=function(self,aI,aJ)ep=aI~=nil and math.floor(aI<0 and math.abs(aI)or-aI)or ep;dr=aJ~=nil and math.floor(aJ<0 and math.abs(aJ)or-aJ)or dr;return self end,getFrameOffset=function(self)return ep,dr end,removeFocusedObject=function(self)if en~=nil then en:loseFocusHandler()end;en=nil;return self end,getFocusedObject=function(self)return en end,show=function(self)aV:show()if self.parent==nil then c=self end;return self end,setCursor=function(self,ew,ex,ey,aE)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())b7=ew or false;if ex~=nil then b3=aZ+ex-1 end;if ey~=nil then b4=a_+ey-1 end;eo=aE or eo;self:setVisualChanged()return self end,setMoveable=function(self,ez)self.isMoveable=ez or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,eA)self.barActive=eA or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,i,Y,Z)self.barText=i or""self.barBackground=Y or self.barBackground;self.barTextcolor=Z or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,dq)self.barTextAlign=dq or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local eB=aV.getVisualChanged(self)for aL,a6 in pairs(em)do if el[a6]~=nil then for aL,ab in pairs(el[a6])do if ab.getVisualChanged~=nil and ab:getVisualChanged()then eB=true end end end end;return eB end,loseFocusHandler=function(self)aV.loseFocusHandler(self)end,getFocusHandler=function(self)aV.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,a7,aP)if en~=nil then if en.keyHandler~=nil then if en:keyHandler(a7,aP)then return true end end end;return false end,backgroundKeyHandler=function(self,a7,aP)aV.backgroundKeyHandler(self,a7,aP)for aL,a6 in pairs(em)do if el[a6]~=nil then for aL,ab in pairs(el[a6])do if ab.backgroundKeyHandler~=nil then ab:backgroundKeyHandler(a7,aP)end end end end end,eventHandler=function(self,a7,aQ,aR,aS,aT)aV.eventHandler(self,a7,aQ,aR,aS,aT)for aL,a6 in pairs(em)do if el[a6]~=nil then for aL,ab in pairs(el[a6])do if ab.eventHandler~=nil then ab:eventHandler(a7,aQ,aR,aS,aT)end end end end;if a7=="terminate"then f.clear()f.setCursorPos(1,1)b.stop()end end,mouseClickHandler=function(self,a7,aM,N,O)local aI,aJ=self:getOffset()aI=aI<0 and math.abs(aI)or-aI;aJ=aJ<0 and math.abs(aJ)or-aJ;if self.drag then if a7=="mouse_drag"then local eC=1;local eD=1;if self.parent~=nil then eC,eD=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(N+self.xToRem-(eC-1)+aI,O-(eD-1)+aJ)end;if a7=="mouse_up"then self.drag=false end;return true end;if aV.mouseClickHandler(self,a7,aM,N,O)then local aF,aG=self:getAbsolutePosition(self:getAnchorPosition())for aL,a6 in pairs(em)do if el[a6]~=nil then for aL,ab in p(el[a6])do if ab.mouseClickHandler~=nil then if ab:mouseClickHandler(a7,aM,N+aI,O+aJ)then return true end end end end end;if self.isMoveable then if N>=aF and N<=aF+self.w-1 and O==aG and a7=="mouse_click"then self.drag=true;self.xToRem=aF-N end end;if en~=nil then en:loseFocusHandler()en=nil end;return true end;return false end,setText=function(self,N,O,i)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.h then if self.parent~=nil then self.parent:setText(math.max(N+aZ-1,aZ)-(self.parent.x-1),a_+O-1-(self.parent.y-1),g(i,math.max(1-N+1,1),self.w-N+1))else X.setText(math.max(N+aZ-1,aZ),a_+O-1,g(i,math.max(1-N+1,1),self.w-N+1))end end end,setBG=function(self,N,O,Y)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.h then if self.parent~=nil then self.parent:setBG(math.max(N+aZ-1,aZ)-(self.parent.x-1),a_+O-1-(self.parent.y-1),g(Y,math.max(1-N+1,1),self.w-N+1))else X.setBG(math.max(N+aZ-1,aZ),a_+O-1,g(Y,math.max(1-N+1,1),self.w-N+1))end end end,setFG=function(self,N,O,Z)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.h then if self.parent~=nil then self.parent:setFG(math.max(N+aZ-1,aZ)-(self.parent.x-1),a_+O-1-(self.parent.y-1),g(Z,math.max(1-N+1,1),self.w-N+1))else X.setFG(math.max(N+aZ-1,aZ),a_+O-1,g(Z,math.max(1-N+1,1),self.w-N+1))end end end,writeText=function(self,N,O,i,Y,Z)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.h then if self.parent~=nil then self.parent:writeText(math.max(N+aZ-1,aZ)-(self.parent.x-1),a_+O-1-(self.parent.y-1),g(i,math.max(1-N+1,1),self.w-N+1),Y,Z)else X.writeText(math.max(N+aZ-1,aZ),a_+O-1,g(i,math.max(1-N+1,1),self.w-N+1),Y,Z)end end end,drawBackgroundBox=function(self,N,O,j,n,Y)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.h and self.h or n+O-1)or(n+O>self.h and self.h-O+1 or n)j=N<1 and(j+N>self.w and self.w or j+N-1)or(j+N>self.w and self.w-N+1 or j)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(N+aZ-1,aZ)-(self.parent.x-1),math.max(O+a_-1,a_)-(self.parent.y-1),j,n,Y)else X.drawBackgroundBox(math.max(N+aZ-1,aZ),math.max(O+a_-1,a_),j,n,Y)end end,drawTextBox=function(self,N,O,j,n,_)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.h and self.h or n+O-1)or(n+O>self.h and self.h-O+1 or n)j=N<1 and(j+N>self.w and self.w or j+N-1)or(j+N>self.w and self.w-N+1 or j)if self.parent~=nil then self.parent:drawTextBox(math.max(N+aZ-1,aZ)-(self.parent.x-1),math.max(O+a_-1,a_)-(self.parent.y-1),j,n,_:sub(1,1))else X.drawTextBox(math.max(N+aZ-1,aZ),math.max(O+a_-1,a_),j,n,_:sub(1,1))end end,drawForegroundBox=function(self,N,O,j,n,Z)local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.h and self.h or n+O-1)or(n+O>self.h and self.h-O+1 or n)j=N<1 and(j+N>self.w and self.w or j+N-1)or(j+N>self.w and self.w-N+1 or j)if self.parent~=nil then self.parent:drawForegroundBox(math.max(N+aZ-1,aZ)-(self.parent.x-1),math.max(O+a_-1,a_)-(self.parent.y-1),j,n,Z)else X.drawForegroundBox(math.max(N+aZ-1,aZ),math.max(O+a_-1,a_),j,n,Z)end end,draw=function(self)if self:getVisualChanged()then if aV.draw(self)then local aZ,a_=self:getAbsolutePosition(self:getAnchorPosition())local di,dj=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(di,dj,self.w,self.h,self.bgcolor)self.parent:drawForegroundBox(di,dj,self.w,self.h,self.fgcolor)self.parent:drawTextBox(di,dj,self.w,self.h," ")else X.drawBackgroundBox(aZ,a_,self.w,self.h,self.bgcolor)X.drawForegroundBox(aZ,a_,self.w,self.h,self.fgcolor)X.drawTextBox(aZ,a_,self.w,self.h," ")end;f.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(di,dj,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)else X.writeText(aZ,a_,h(self.barText,self.w,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for aL,a6 in p(em)do if el[a6]~=nil then for aL,ab in pairs(el[a6])do if ab.draw~=nil then ab:draw()end end end end;if b7 then f.setTextColor(eo)f.setCursorPos(b3,b4)if self.parent~=nil then f.setCursorBlink(self:isFocused())else f.setCursorBlink(b7)end end;self:setVisualChanged(false)end end end,addObject=function(self,eu)return et(eu)end,removeObject=function(self,eu)return ev(eu)end,getObject=function(self,eu)return es(eu)end,addButton=function(self,am)local eu=aU(am)eu.name=am;return et(eu)end,addLabel=function(self,am)local eu=c2(am)eu.name=am;eu.bgcolor=self.bgcolor;eu.fgcolor=self.fgcolor;return et(eu)end,addCheckbox=function(self,am)local eu=cI(am)eu.name=am;return et(eu)end,addInput=function(self,am)local eu=cT(am)eu.name=am;return et(eu)end,addProgram=function(self,am)local eu=b1(am)eu.name=am;return et(eu)end,addTextfield=function(self,am)local eu=db(am)eu.name=am;return et(eu)end,addList=function(self,am)local eu=dk(am)eu.name=am;return et(eu)end,addDropdown=function(self,am)local eu=dC(am)eu.name=am;return et(eu)end,addRadio=function(self,am)local eu=dI(am)eu.name=am;return et(eu)end,addTimer=function(self,am)local eu=dN(am)eu.name=am;return et(eu)end,addAnimation=function(self,am)local eu=dY(am)eu.name=am;return et(eu)end,addSlider=function(self,am)local eu=e4(am)eu.name=am;return et(eu)end,addScrollbar=function(self,am)local eu=ee(am)eu.name=am;return et(eu)end,addMenubar=function(self,am)local eu=dx(am)eu.name=am;return et(eu)end,addThread=function(self,am)local eu=dV(am)eu.name=am;return et(eu)end,addPane=function(self,am)local eu=c4(am)eu.name=am;return et(eu)end,addImage=function(self,am)local eu=c5(am)eu.name=am;return et(eu)end,addProgressbar=function(self,am)local eu=cJ(am)eu.name=am;return et(eu)end,addFrame=function(self,am)local eu=ej(am,self)eu.name=am;return et(eu)end}setmetatable(aw,aV)if ek==nil then table.insert(d,aw)end;return aw end;local eE=false;local function eF(a7,aQ,aR,aS,aT)if a7=="mouse_click"then c:mouseClickHandler(a7,aQ,aR,aS,aT)end;if a7=="mouse_drag"then c:mouseClickHandler(a7,aQ,aR,aS,aT)end;if a7=="mouse_up"then c:mouseClickHandler(a7,aQ,aR,aS,aT)end;if a7=="mouse_scroll"then c:mouseClickHandler(a7,aQ,aR,aS,aT)end;if a7=="key"or a7=="char"then c:keyHandler(a7,aQ)c:backgroundKeyHandler(a7,aQ)end;for aL,ab in pairs(d)do ab:eventHandler(a7,aQ,aR,aS,aT)end;if eE then c:draw()X.update()end end;function b.autoUpdate(dX)f.clear()eE=dX or true;c:draw()X.update()while eE do local a7,aQ,aR,aS,aT=os.pullEventRaw()eF(a7,aQ,aR,aS,aT)end end;function b.update(a7,aQ,aR,aS,aT)if a7~="nil"then eF(a7,aQ,aR,aS,aT)else c:draw()X.update()end end;function b.stop()eE=false end;function b.getFrame(am)for aa,ab in pairs(d)do if ab.name==am then return ab end end end;function b.getActiveFrame()return c end;function b.setActiveFrame(ax)if ax:getType()=="Frame"then c=ax;return true end;return false end;function b.createFrame(am)local ax=ej(am)return ax end;function b.removeFrame(am)for aa,ab in pairs(d)do if ab.name==am then d[aa]=nil;return true end end;return false end;if b.debugger then b.debugFrame=b.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)b.debugList=b.debugFrame:addList("debugList"):setSize(b.debugFrame.w-2,b.debugFrame.h-3):setPosition(2,3):setScrollable(true):show()b.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()b.oldFrame:show()end):setBackground(colors.red):show()b.debugLabel=b.debugFrame:addLabel("debugLabel"):onClick(function()b.oldFrame=c;b.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if b.debugger then function b.debug(...)local ah={...}if c.name~="basaltDebuggingFrame"then if c~=b.debugLabel.frame then b.debugLabel:setParent(c)end end;local eG=""for aa,ab in pairs(ah)do eG=eG..tostring(ab)..(#ah~=aa and", "or"")end;b.debugLabel:setText("[Debug] "..eG)b.debugList:addItem(eG)if b.debugList:getItemCount()>50 then b.debugList:removeItem(1)end;b.debugList:setValue(b.debugList:getItem(b.debugList:getItemCount()))b.debugLabel:show()end end;return b \ No newline at end of file diff --git a/basalt-minified.lua b/basalt-minified.lua new file mode 100644 index 0000000..a9e8f7e --- /dev/null +++ b/basalt-minified.lua @@ -0,0 +1 @@ +local a={basaltBG=colors.lightGray,basaltFG=colors.black,FrameBG=colors.gray,FrameFG=colors.black,ButtonBG=colors.gray,ButtonFG=colors.black,CheckboxBG=colors.gray,CheckboxFG=colors.black,InputBG=colors.gray,InputFG=colors.black,textfieldBG=colors.gray,textfieldFG=colors.black,listBG=colors.gray,listFG=colors.black,dropdownBG=colors.gray,dropdownFG=colors.black,radioBG=colors.gray,radioFG=colors.black,selectionBG=colors.black,selectionFG=colors.lightGray}local b={debugger=true,version=1}local c;local d={}local e={}local f=term.current()local g=string.sub;local function h(i,j,k)i=string.sub(i,1,j)local l=j-string.len(i)if k=="right"then i=string.rep(" ",l)..i elseif k=="center"then i=string.rep(" ",math.floor(l/2))..i..string.rep(" ",math.floor(l/2))i=i..(string.len(i)=1 and O<=u then if N+i:len()>0 and N<=j then local P=v[O]local Q;local R=N+#i-1;if N<1 then local S=1-N+1;local T=j-N+1;i=g(i,S,T)elseif R>j then local T=j-N+1;i=g(i,1,T)end;if N>1 then local T=N-1;Q=g(P,1,T)..i else Q=i end;if R=1 and O<=u then if N+V:len()>0 and N<=j then local P=w[O]local Q;local R=N+#V-1;if N<1 then V=g(V,1-N+1,j-N+1)elseif R>j then V=g(V,1,j-N+1)end;if N>1 then Q=g(P,1,N-1)..V else Q=V end;if R=1 and O<=u then if N+V:len()>0 and N<=j then local P=x[O]local Q;local R=N+#V-1;if N<1 then local S=1-N+1;local T=j-N+1;V=g(V,S,T)elseif R>j then local T=j-N+1;V=g(V,1,T)end;if N>1 then local T=N-1;Q=g(P,1,T)..V else Q=V end;if RN and aN<=O and aN+self.height>O and at then if self.parent~=nil then self.parent:setFocusedObject(self)end;av:sendEvent(a8,self,a8,aL,N,O)return true end;return false end,keyHandler=function(self,a8,aO)if self:isFocused()then av:sendEvent(a8,self,a8,aO)return true end;return false end,backgroundKeyHandler=function(self,a8,aO)av:sendEvent("background_"..a8,self,a8,aO)end,valueChangedHandler=function(self)av:sendEvent("value_changed",self)end,eventHandler=function(self,a8,aP,aQ,aR,aS)av:sendEvent("custom_event_handler",self,a8,aP,aQ,aR,aS)end,getFocusHandler=function(self)av:sendEvent("get_focus",self)end,loseFocusHandler=function(self)av:sendEvent("lose_focus",self)end}aw.__index=aw;return aw end;local function aT(an)local aU=am(an)local ao="Button"aU:setValue("Button")aU:setZIndex(5)aU.weight=8;aU.bgcolor=a.ButtonBG;aU.fgcolor=a.ButtonFG;local aV="center"local aW="center"local aw={getType=function(self)return ao end,setHorizontalAlign=function(self,aX)aV=aX end,setVerticalAlign=function(self,aX)aW=aX end,setText=function(self,i)aU:setValue(i)return self end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()local a_=m(self.height,aW)self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)self.parent:drawTextBox(aY,aZ,self.weight,self.height," ")for E=1,self.height do if E==a_ then self.parent:setText(aY,aZ+E-1,h(self:getValue(),self.weight,aV))end end end end end}return setmetatable(aw,aU)end;local function b0(an)local aU=am(an)local ao="Program"aU:setZIndex(5)local aw;local function b1(N,O,Y,n)local b2,b3=1,1;local b4,b5=colors.black,colors.white;local b6=false;local b7=false;local v={}local w={}local x={}local b8={}local B;local C={}for q=0,15 do local b9=2^q;b8[b9]={f.getPaletteColour(b9)}end;local function D()B=(" "):rep(Y)for E=0,15 do local F=2^E;local G=r[F]C[F]=G:rep(Y)end end;local function H()D()local I=B;local J=C[colors.white]local K=C[colors.black]for E=1,n do v[E]=g(v[E]==nil and I or v[E]..I:sub(1,Y-v[E]:len()),1,Y)x[E]=g(x[E]==nil and J or x[E]..J:sub(1,Y-x[E]:len()),1,Y)w[E]=g(w[E]==nil and K or w[E]..K:sub(1,Y-w[E]:len()),1,Y)end end;H()local function ba()if b2>=1 and b3>=1 and b2<=Y and b3<=n then else end end;local function bb(bc,bd,be)local bf=b2;local R=bf+#bc-1;if b3>=1 and b3<=n then if bf<=Y and R>=1 then if bf==1 and R==Y then v[b3]=bc;x[b3]=bd;w[b3]=be else local bg,bh,bi;if bf<1 then local bj=1-bf+1;local bk=Y-bf+1;bg=g(bc,bj,bk)bh=g(bd,bj,bk)bi=g(be,bj,bk)elseif R>Y then local bk=Y-bf+1;bg=g(bc,1,bk)bh=g(bd,1,bk)bi=g(be,1,bk)else bg=bc;bh=bd;bi=be end;local bl=v[b3]local bm=x[b3]local bn=w[b3]local bo,bp,bq;if bf>1 then local br=bf-1;bo=g(bl,1,br)..bg;bp=g(bm,1,br)..bh;bq=g(bn,1,br)..bi else bo=bg;bp=bh;bq=bi end;if R=1 and O<=n then v[bP]=v[O]w[bP]=w[O]x[bP]=x[O]else v[bP]=bM;x[bP]=bN;w[bP]=bO end end end;if b7 then ba()end end,isColor=function()return f.isColor()end,isColour=function()return f.isColor()end,write=function(i)i=tostring(i)if b7 then bb(i,r[b5]:rep(i:len()),r[b4]:rep(i:len()))end end,clearLine=function()if b7 then M(1,b3,(" "):rep(Y))U(1,b3,r[b4]:rep(Y))W(1,b3,r[b5]:rep(Y))end;if b7 then ba()end end,clear=function()for E=1,n do M(1,E,(" "):rep(Y))U(1,E,r[b4]:rep(Y))W(1,E,r[b5]:rep(Y))end;if b7 then ba()end end,blit=function(i,bQ,bR)if type(i)~="string"then error("bad argument #1 (expected string, got "..type(i)..")",2)end;if type(bQ)~="string"then error("bad argument #2 (expected string, got "..type(bQ)..")",2)end;if type(bR)~="string"then error("bad argument #3 (expected string, got "..type(bR)..")",2)end;if#bQ~=#i or#bR~=#i then error("Arguments must be the same length",2)end;if b7 then bb(i,bQ,bR)end end}return bH end;aU.weight=30;aU.height=12;local bS=b1(1,1,aU.weight,aU.height)local bT;local bU=false;local bV={}aw={getType=function(self)return ao end,show=function(self)aU.show(self)bS.setBackgroundColor(self.bgcolor)bS.setTextColor(self.fgcolor)bS.basalt_setVisible(true)return self end,hide=function(self)aU.hide(self)bS.basalt_setVisible(false)return self end,setPosition=function(self,N,O,aC)aU.setPosition(self,N,O,aC)bS.basalt_reposition(self:getAnchorPosition())return self end,getBasaltWindow=function()return bS end,getBasaltProcess=function()return bT end,setSize=function(self,Y,n)aU.setSize(self,Y,n)bS.basalt_resize(self.weight,self.height)return self end,getStatus=function(self)if bT~=nil then return bT:getStatus()end;return"inactive"end,execute=function(self,ag,...)bT=ae:new(ag,bS,...)bS.setBackgroundColor(colors.black)bS.setTextColor(colors.white)bS.clear()bS.setCursorPos(1,1)bT:resume()bU=false;return self end,stop=function(self)if bT~=nil then if not bT:isDead()then bT:resume("terminate")if bT:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end;return self end,pause=function(self,bW)bU=bW or not bU;if bT~=nil then if not bT:isDead()then if not bU then self:injectEvents(bV)bV={}end end end;return self end,isPaused=function(self)return bU end,injectEvent=function(self,a8,aP,aQ,aR,aS,bX)if bT~=nil then if not bT:isDead()then if bU==false or bX then bT:resume(a8,aP,aQ,aR,aS)else table.insert(bV,{event=a8,args={aP,aQ,aR,aS}})end end end;return self end,getQueuedEvents=function(self)return bV end,updateQueuedEvents=function(self,a6)bV=a6 or bV;return self end,injectEvents=function(self,a6)if bT~=nil then if not bT:isDead()then for ab,bY in pairs(a6)do bT:resume(bY.event,table.unpack(bY.args))end end end;return self end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then if bT==nil then return false end;if not bT:isDead()then if not bU then local bZ,b_=self:getAbsolutePosition(self:getAnchorPosition(nil,nil,true))bT:resume(a8,aL,N-bZ+1,O-b_+1)end end;return true end end,keyHandler=function(self,a8,aO)aU.keyHandler(self,a8,aO)if self:isFocused()then if bT==nil then return false end;if not bT:isDead()then if not bU then if self.draw then bT:resume(a8,aO)end end end end end,getFocusHandler=function(self)aU.getFocusHandler(self)if bT~=nil then if not bT:isDead()then if not bU then if self.parent~=nil then local c0,c1=bS.getCursorPos()local aY,aZ=self:getAnchorPosition()if self.parent~=nil then if aY+c0-1>=1 and aY+c0-1<=aY+self.weight-1 and c1+aZ-1>=1 and c1+aZ-1<=aZ+self.height-1 then self.parent:setCursor(bS.getCursorBlink(),aY+c0-1,c1+aZ-1,bS.getTextColor())end end end end end end end,loseFocusHandler=function(self)aU.loseFocusHandler(self)if bT~=nil then if not bT:isDead()then if self.parent~=nil then self.parent:setCursor(false)end end end end,eventHandler=function(self,a8,aP,aQ,aR,aS)if bT==nil then return end;if not bT:isDead()then if not bU then if a8~="mouse_click"and a8~="mouse_up"and a8~="mouse_scroll"and a8~="mouse_drag"and a8~="key_up"and a8~="key"and a8~="char"and a8~="terminate"then bT:resume(a8,aP,aQ,aR,aS)end;if self:isFocused()then local aY,aZ=self:getAnchorPosition()local c0,c1=bS.getCursorPos()if self.parent~=nil then if aY+c0-1>=1 and aY+c0-1<=aY+self.weight-1 and c1+aZ-1>=1 and c1+aZ-1<=aZ+self.height-1 then self.parent:setCursor(bS.getCursorBlink(),aY+c0-1,c1+aZ-1,bS.getTextColor())end end;if a8=="terminate"and self:isFocused()then self:stop()end end else if a8~="mouse_click"and a8~="mouse_up"and a8~="mouse_scroll"and a8~="mouse_drag"and a8~="key_up"and a8~="key"and a8~="char"and a8~="terminate"then table.insert(bV,{event=a8,args={aP,aQ,aR,aS}})end end end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()bS.basalt_reposition(aY,aZ)self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)bS.basalt_update()end end end}return setmetatable(aw,aU)end;local function c2(an)local aU=am(an)local ao="Label"aU:setZIndex(3)local c3=true;aU:setValue("")local aw={getType=function(self)return ao end,setText=function(self,i)i=tostring(i)aU:setValue(i)if c3 then self.weight=i:len()end;return self end,setSize=function(self,Y,n)self.weight,self.height=Y,n;c3=false;return self end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:writeText(aY,aZ,self:getValue(),self.bgcolor,self.fgcolor)end end end}return setmetatable(aw,aU)end;local function c4(an)local aU=am(an)local ao="Pane"local aw={getType=function(self)return ao end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.bgcolor)end end end}return setmetatable(aw,aU)end;local function c5(an)local aU=am(an)local ao="Image"aU:setZIndex(2)local c6;local c7;local c8=false;local function c9()local ca={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local cb,cc,cd={},{},{}for q=0,15 do cc[2^q]=q end;do local ce="0123456789abcdef"for q=1,16 do cb[ce:sub(q,q)]=q-1;cb[q-1]=ce:sub(q,q)cd[ce:sub(q,q)]=2^(q-1)cd[2^(q-1)]=ce:sub(q,q)local cf=ca[q-1]for q=1,#cf do cf[q]=2^cf[q]end end end;local function cg(ch)local ci=ca[cc[ch[#ch][1]]]for cj=1,#ci do local ck=ci[cj]for q=1,#ch-1 do if ch[q][1]==ck then return q end end end;return 1 end;local function cl(cm,cn)if not cn then local co={}cn={}for q=1,6 do local cp=cm[q]local cq=cn[cp]cn[cp],co[q]=cq and cq+1 or 1,cp end;cm=co end;local ch={}for aO,ac in pairs(cn)do ch[#ch+1]={aO,ac}end;if#ch>1 then while#ch>2 do table.sort(ch,function(cr,bE)return cr[2]>bE[2]end)local cs,ct=cg(ch),#ch;local cu,cv=ch[ct][1],ch[cs][1]for q=1,6 do if cm[q]==cu then cm[q]=cv;ch[cs][2]=ch[cs][2]+1 end end;ch[ct]=nil end;local cw=128;for q=1,#cm-1 do if cm[q]~=cm[6]then cw=cw+2^(q-1)end end;return string.char(cw),cd[ch[1][1]==cm[6]and ch[2][1]or ch[1][1]],cd[cm[6]]else return"\128",cd[cm[1]],cd[cm[1]]end end;local cx,j,u,Z={{},{},{}},0,#c6+#c6%3,aU.bgcolor or colors.black;for q=1,#c6 do if#c6[q]>j then j=#c6[q]end end;for O=0,u-1,3 do local cy,cz,cA,cB={},{},{},1;for N=0,j-1,2 do local cm,cn={},{}for cC=1,3 do for cD=1,2 do cm[#cm+1]=c6[O+cC]and c6[O+cC][N+cD]and(c6[O+cC][N+cD]==0 and Z or c6[O+cC][N+cD])or Z;cn[cm[#cm]]=cn[cm[#cm]]and cn[cm[#cm]]+1 or 1 end end;cy[cB],cz[cB],cA[cB]=cl(cm,cn)cB=cB+1 end;cx[1][#cx[1]+1],cx[2][#cx[2]+1],cx[3][#cx[3]+1]=table.concat(cy),table.concat(cz),table.concat(cA)end;cx.width,cx.height=#cx[1][1],#cx[1]c7=cx end;local aw={getType=function(self)return ao end,loadImage=function(self,ag)c6=paintutils.loadImage(ag)c8=false;return self end,loadBlittleImage=function(self,ag)c8=true;return self end,shrinkImage=function(self)c9()c8=true;return self end,draw=function(self)if aU.draw(self)then if self.parent~=nil then if c6~=nil then local aY,aZ=self:getAnchorPosition()if c8 then local p,cE,cF=c7[1],c7[2],c7[3]for q=1,c7.height do local cG=p[q]if type(cG)=="string"then self.parent:setText(aY,aZ+q-1,cG)self.parent:setFG(aY,aZ+q-1,cE[q])self.parent:setBG(aY,aZ+q-1,cF[q])elseif type(cG)=="table"then self.parent:setText(aY,aZ+q-1,cG[2])self.parent:setFG(aY,aZ+q-1,cE[q])self.parent:setBG(aY,aZ+q-1,cF[q])end end else for aB=1,math.min(#c6,self.height)do local cH=c6[aB]for aA=1,math.min(#cH,self.weight)do if cH[aA]>0 then self.parent:drawBackgroundBox(aY+aA-1,aZ+aB-1,1,1,cH[aA])end end end end end end end end}return setmetatable(aw,aU)end;local function cI(an)local aU=am(an)local ao="Checkbox"aU:setZIndex(5)aU:setValue(false)aU.weight=1;aU.height=1;aU.bgcolor=a.CheckboxBG;aU.fgcolor=a.CheckboxFG;local aw={symbol="\42",getType=function(self)return ao end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then if a8=="mouse_click"and aL==1 then if self:getValue()~=true and self:getValue()~=false then self:setValue(false)else self:setValue(not self:getValue())end end;return true end;return false end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()local a_=m(self.height,"center")self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)for E=1,self.height do if E==a_ then if self:getValue()==true then self.parent:writeText(aY,aZ+E-1,h(self.symbol,self.weight,"center"),self.bgcolor,self.fgcolor)else self.parent:writeText(aY,aZ+E-1,h(" ",self.weight,"center"),self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(aw,aU)end;local function cJ(an)local aU=am(an)local ao="Progressbar"local cK=0;aU:setZIndex(5)aU:setValue(false)aU.weight=25;aU.height=1;aU.bgcolor=a.CheckboxBG;aU.fgcolor=a.CheckboxFG;local cL=colors.black;local cM=""local cN=colors.white;local cO=""local cP=0;local aw={getType=function(self)return ao end,setDirection=function(self,cQ)cP=cQ;return self end,setProgressBar=function(self,aE,a0,cR)cL=aE or cL;cM=a0 or cM;cN=cR or cN;return self end,setBackgroundSymbol=function(self,a0)cO=a0:sub(1,1)return self end,setProgress=function(self,ac)if ac>=0 and ac<=100 and cK~=ac then cK=ac;self:setValue(cK)if cK==100 then self:progressDoneHandler()end end;return self end,getProgress=function(self)return cK end,onProgressDone=function(self,cS)self:registerEvent("progress_done",cS)return self end,progressDoneHandler=function(self)self:sendEvent("progress_done")end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)self.parent:drawTextBox(aY,aZ,self.weight,self.height,cO)if cP==1 then self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height/100*cK,cL)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height/100*cK,cN)self.parent:drawTextBox(aY,aZ,self.weight,self.height/100*cK,cM)elseif cP==2 then self.parent:drawBackgroundBox(aY,aZ+math.ceil(self.height-self.height/100*cK),self.weight,self.height/100*cK,cL)self.parent:drawForegroundBox(aY,aZ+math.ceil(self.height-self.height/100*cK),self.weight,self.height/100*cK,cN)self.parent:drawTextBox(aY,aZ+math.ceil(self.height-self.height/100*cK),self.weight,self.height/100*cK,cM)elseif cP==3 then self.parent:drawBackgroundBox(aY+math.ceil(self.weight-self.weight/100*cK),aZ,self.weight/100*cK,self.height,cL)self.parent:drawForegroundBox(aY+math.ceil(self.weight-self.weight/100*cK),aZ,self.weight/100*cK,self.height,cN)self.parent:drawTextBox(aY+math.ceil(self.weight-self.weight/100*cK),aZ,self.weight/100*cK,self.height,cM)else self.parent:drawBackgroundBox(aY,aZ,self.weight/100*cK,self.height,cL)self.parent:drawForegroundBox(aY,aZ,self.weight/100*cK,self.height,cN)self.parent:drawTextBox(aY,aZ,self.weight/100*cK,self.height,cM)end end end end}return setmetatable(aw,aU)end;local function cT(an)local aU=am(an)local ao="Input"local cU="text"local cV=0;aU:setZIndex(5)aU:setValue("")aU.weight=10;aU.height=1;aU.bgcolor=a.InputBG;aU.fgcolor=a.InputFG;local cW=1;local cX=1;local cY=""local cZ;local c_;local d0=cY;local d1=false;local aw={getType=function(self)return ao end,setInputType=function(self,d2)if d2=="password"or d2=="number"or d2=="text"then cU=d2 end;return self end,setDefaultText=function(self,i,d3,d4)cY=i;cZ=d4 or cZ;c_=d3 or c_;if self:isFocused()then d0=""else d0=cY end;return self end,getInputType=function(self)return cU end,setValue=function(self,d5)aU.setValue(self,tostring(d5))if not d1 then cW=tostring(d5):len()+1 end;return self end,getValue=function(self)local d5=aU.getValue(self)return cU=="number"and tonumber(d5)or d5 end,setInputLimit=function(self,d6)cV=tonumber(d6)or cV;return self end,getInputLimit=function(self)return cV end,getFocusHandler=function(self)aU.getFocusHandler(self)if self.parent~=nil then local aY,aZ=self:getAnchorPosition()d0=""if self.parent~=nil then self.parent:setCursor(true,aY+cW-cX,aZ,self.fgcolor)end end end,loseFocusHandler=function(self)aU.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)d0=cY end end,keyHandler=function(self,a8,aO)if aU.keyHandler(self,a8,aO)then d1=true;if a8=="key"then if aO==keys.backspace then local i=tostring(aU.getValue())if cW>1 then self:setValue(i:sub(1,cW-2)..i:sub(cW,i:len()))if cW>1 then cW=cW-1 end;if cX>1 then if cWd7 then cW=d7+1 end;if cW<1 then cW=1 end;if cW=self.weight+cX then cX=cW-self.weight+1 end;if cX<1 then cX=1 end end;if aO==keys.left then cW=cW-1;if cW>=1 then if cW=self.weight+cX then cX=cW end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a8=="char"then local i=aU.getValue()if i:len()=self.weight+cX then cX=cX+1 end end end;local aY,aZ=self:getAnchorPosition()local d5=tostring(aU.getValue())local d9=(cW<=d5:len()and cW-1 or d5:len())-(cX-1)if d9>self.x+self.weight-1 then d9=self.x+self.weight-1 end;if self.parent~=nil then self.parent:setCursor(true,aY+d9,aZ,self.fgcolor)end;d1=false end end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then if a8=="mouse_click"and aL==1 then end;return true end;return false end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()local a_=m(self.height,"center")self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)for E=1,self.height do if E==a_ then local d5=tostring(aU.getValue())local d4=self.bgcolor;local d3=self.fgcolor;local i;if d5:len()<=0 then i=d0;d4=cZ or d4;d3=c_ or d3 end;i=d0;if d5~=""then i=d5 end;i=i:sub(cX,self.weight+cX-1)local da=self.weight-i:len()if da<0 then da=0 end;if cU=="password"and d5~=""then i=string.rep("*",i:len())end;i=i..string.rep(" ",da)self.parent:writeText(aY,aZ+E-1,i,d4,d3)end end end end end}return setmetatable(aw,aU)end;local function db(an)local aU=am(an)local ao="Textfield"local dc,cX,cW,dd=1,1,1,1;local de={""}local df={[colors.purple]={"break"}}aU.weight=20;aU.height=8;aU.bgcolor=a.textfieldBG;aU.fgcolor=a.textfieldFG;aU:setZIndex(5)local aw={getType=function(self)return ao end,getLines=function(self)return de end,getLine=function(self,a7)return de[a7]or""end,editLine=function(self,a7,i)de[a7]=i or de[a7]return self end,addLine=function(self,i,a7)if a7~=nil then table.insert(de,a7,i)else table.insert(de,i)end;return self end,addKeyword=function(self,dg,aE)end,removeLine=function(self,a7)table.remove(de,a7 or#de)if#de<=0 then table.insert(de,"")end;return self end,getTextCursor=function(self)return cW,dd end,getFocusHandler=function(self)aU.getFocusHandler(self)if self.parent~=nil then local aY,aZ=self:getAnchorPosition()if self.parent~=nil then self.parent:setCursor(true,aY+cW-cX,aZ+dd-dc,self.fgcolor)end end end,loseFocusHandler=function(self)aU.loseFocusHandler(self)if self.parent~=nil then self.parent:setCursor(false)end end,keyHandler=function(self,a8,aO)if aU.keyHandler(self,a8,aO)then local aY,aZ=self:getAnchorPosition()if a8=="key"then if aO==keys.backspace then if de[dd]==""then if dd>1 then table.remove(de,dd)cW=de[dd-1]:len()+1;cX=cW-self.weight+1;if cX<1 then cX=1 end;dd=dd-1 end elseif cW<=1 then if dd>1 then cW=de[dd-1]:len()+1;cX=cW-self.weight+1;if cX<1 then cX=1 end;de[dd-1]=de[dd-1]..de[dd]table.remove(de,dd)dd=dd-1 end else de[dd]=de[dd]:sub(1,cW-2)..de[dd]:sub(cW,de[dd]:len())if cW>1 then cW=cW-1 end;if cX>1 then if cWde[dd]:len()then if de[dd+1]~=nil then de[dd]=de[dd]..de[dd+1]table.remove(de,dd+1)end else de[dd]=de[dd]:sub(1,cW-1)..de[dd]:sub(cW+1,de[dd]:len())end end;if aO==keys.enter then table.insert(de,dd+1,de[dd]:sub(cW,de[dd]:len()))de[dd]=de[dd]:sub(1,cW-1)dd=dd+1;cW=1;cX=1;if dd-dc>=self.height then dc=dc+1 end;self:setValue("")end;if aO==keys.up then if dd>1 then dd=dd-1;if cW>de[dd]:len()+1 then cW=de[dd]:len()+1 end;if cX>1 then if cW1 then if ddde[dd]:len()+1 then cW=de[dd]:len()+1 end;if dd>=dc+self.height then dc=dc+1 end end end;if aO==keys.right then cW=cW+1;if dd<#de then if cW>de[dd]:len()+1 then cW=1;dd=dd+1 end elseif cW>de[dd]:len()then cW=de[dd]:len()+1 end;if cW<1 then cW=1 end;if cW=self.weight+cX then cX=cW-self.weight+1 end;if cX<1 then cX=1 end end;if aO==keys.left then cW=cW-1;if cW>=1 then if cW=self.weight+cX then cX=cW end end;if dd>1 then if cW<1 then dd=dd-1;cW=de[dd]:len()+1;cX=cW-self.weight+1 end end;if cW<1 then cW=1 end;if cX<1 then cX=1 end end end;if a8=="char"then de[dd]=de[dd]:sub(1,cW-1)..aO..de[dd]:sub(cW,de[dd]:len())cW=cW+1;if cW>=self.weight+cX then cX=cX+1 end;self:setValue("")end;local d9=(cW<=de[dd]:len()and cW-1 or de[dd]:len())-(cX-1)if d9>self.x+self.weight-1 then d9=self.x+self.weight-1 end;local dh=dd-dcde[dd]:len()then cW=de[dd]:len()+1 end;if cWde[dd]:len()then cW=de[dd]:len()+1 end;if cW#de-(self.height-1)then dc=#de-(self.height-1)end;if dc<1 then dc=1 end;if self.parent~=nil then if aY+cW-cX>=aY and aY+cW-cX<=aY+self.weight and(aZ+dd-dc>=aZ and aZ+dd-dc<=aZ+self.height)then self.parent:setCursor(true,di+cW-cX,dj+dd-dc)else self.parent:setCursor(false)end end end;self:setVisualChanged()return true end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)for E=1,self.height do local i=""if de[E+dc-1]~=nil then i=de[E+dc-1]end;i=i:sub(cX,self.weight+cX-1)local da=self.weight-i:len()if da<0 then da=0 end;i=i..string.rep(" ",da)self.parent:setText(aY,aZ+E-1,i)end end end end}return setmetatable(aw,aU)end;local function dk(an)local aU=am(an)local ao="List"aU.weight=16;aU.height=6;aU.bgcolor=a.listBG;aU.fgcolor=a.listFG;aU:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dr=0;local ds=true;local aw={getType=function(self)return ao end,addItem=function(self,i,Z,_,...)table.insert(dl,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,setIndexOffset=function(self,dt)dr=dt;return self end,getIndexOffset=function(self)return dr end,removeItem=function(self,a7)table.remove(dl,a7)return self end,getItem=function(self,a7)return dl[a7]end,getItemIndex=function(self)local du=self:getValue()for dv,bY in pairs(dl)do if bY==du then return dv end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a7,i,Z,_,...)table.remove(dl,a7)table.insert(dl,a7,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})return self end,selectItem=function(self,a7)self:setValue(dl[a7]or{})return self end,setSelectedItem=function(self,Z,_,dw)dm=Z or self.bgcolor;dn=_ or self.fgcolor;dp=dw;return self end,setScrollable=function(self,dx)ds=dx;return self end,mouseClickHandler=function(self,a8,aL,N,O)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if aY<=N and aY+self.weight>N and aZ<=O and aZ+self.height>O and self:isVisible()then if a8=="mouse_click"or a8=="mouse_drag"then if aL==1 then if#dl>0 then for E=1,self.height do if dl[E+dr]~=nil then if aY<=N and aY+self.weight>N and aZ+E-1==O then self:setValue(dl[E+dr])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dl[E+dr])end end end end end end;if a8=="mouse_scroll"and ds then dr=dr+aL;if dr<0 then dr=0 end;if aL>=1 then if#dl>self.height then if dr>#dl-self.height then dr=#dl-self.h end;if dr>=#dl then dr=#dl-1 end else dr=dr-1 end end end;self:setVisualChanged()return true end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)for E=1,self.height do if dl[E+dr]~=nil then if dl[E+dr]==self:getValue()then if dp then self.parent:writeText(aY,aZ+E-1,h(dl[E+dr].text,self.weight,dq),dm,dn)else self.parent:writeText(aY,aZ+E-1,h(dl[E+dr].text,self.weight,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end else self.parent:writeText(aY,aZ+E-1,h(dl[E+dr].text,self.weight,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end end end end end end}return setmetatable(aw,aU)end;local function dy(an)local aU=am(an)local ao="Menubar"local aw={}aU.weight=30;aU.height=1;aU.bgcolor=colors.gray;aU.fgcolor=colors.lightGray;aU:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dp=true;local dq="left"local dz=0;local da=2;local ds=false;local function dA()local dB=0;local aA=1;for E=1,#dl do if aA+dl[E].text:len()+da*2>aw.w then dB=dB+dl[E].text:len()+da*2 end;aA=aA+dl[E].text:len()+da*2 end;return dB end;aw={getType=function(self)return ao end,addItem=function(self,i,Z,_,...)table.insert(dl,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,getItemIndex=function(self)local du=self:getValue()for dv,bY in pairs(dl)do if bY==du then return dv end end end,clear=function(self)dl={}self:setValue({})return self end,setSpace=function(self,dC)da=dC or da;return self end,setButtonOffset=function(self,l)dz=l or 0;if dz<0 then dz=0 end;local dB=dA()if dz>dB then dz=dB end;return self end,setScrollable=function(self,dx)ds=dx;return self end,removeItem=function(self,a7)table.remove(dl,a7)return self end,getItem=function(self,a7)return dl[a7]end,getItemCount=function(self)return#dl end,editItem=function(self,a7,i,Z,_,...)table.remove(dl,a7)table.insert(dl,a7,{text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})return self end,selectItem=function(self,a7)self:setValue(dl[a7]or{})return self end,setSelectedItem=function(self,Z,_,dw)dm=Z or self.bgcolor;dn=_ or self.fgcolor;dp=dw;return self end,mouseClickHandler=function(self,a8,aL,N,O)local aM,aN=self:getAbsolutePosition(self:getAnchorPosition())if aM<=N and aM+self.weight>N and aN<=O and aN+self.height>O and self:isVisible()then if self.parent~=nil then self.parent:setFocusedObject(self)end;if a8=="mouse_click"then local aA=1;for E=1+dz,#dl do if dl[E]~=nil then if aA+dl[E].text:len()+da*2<=self.weight then if aM+aA-1<=N and aM+aA-1+dl[E].text:len()+da*2>N and aN==O then self:setValue(dl[E])self:getEventSystem():sendEvent("mouse_click",self,"mouse_click",0,N,O,dl[E])end;aA=aA+dl[E].text:len()+da*2 else break end end end end;if a8=="mouse_scroll"and ds then dz=dz+aL;if dz<0 then dz=0 end;local dB=dA()if dz>dB then dz=dB end end;return true end;return false end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)local aA=0;for ab,bY in pairs(dl)do if aA+bY.text:len()+da*2<=self.weight then if bY==self:getValue()then self.parent:writeText(aY+aA-1+-dz,aZ,h((" "):rep(da)..bY.text..(" "):rep(da),bY.text:len()+da*2,dq),dm or bY.bgCol,dn or bY.fgCol)else self.parent:writeText(aY+aA-1+-dz,aZ,h((" "):rep(da)..bY.text..(" "):rep(da),bY.text:len()+da*2,dq),bY.bgCol,bY.fgCol)end;aA=aA+bY.text:len()+da*2 else if aA0 then for E=1,dF do if dl[E+dr]~=nil then if aY<=N and aY+dE>N and aZ+E==O then self:setValue(dl[E+dr])return true end end end end end end;if a8=="mouse_scroll"then dr=dr+aL;if dr<0 then dr=0 end;if aL==1 then if#dl>dF then if dr>#dl-dF then dr=#dl-dF end else dr=dl-1 end end;return true end;self:setVisualChanged()end;if aU.mouseClickHandler(self,a8,aL,N,O)then dI=2 else dI=1 end end,draw=function(self)if aU.draw(self)then local aY,aZ=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)if#dl>=1 then if self:getValue()~=nil then if self:getValue().text~=nil then if dI==1 then self.parent:writeText(aY,aZ,h(self:getValue().text,self.weight,dq):sub(1,self.weight-1)..dG,self.bgcolor,self.fgcolor)else self.parent:writeText(aY,aZ,h(self:getValue().text,self.weight,dq):sub(1,self.weight-1)..dH,self.bgcolor,self.fgcolor)end end end;if dI==2 then for E=1,dF do if dl[E+dr]~=nil then if dl[E+dr]==self:getValue()then if dp then self.parent:writeText(aY,aZ+E,h(dl[E+dr].text,dE,dq),dm,dn)else self.parent:writeText(aY,aZ+E,h(dl[E+dr].text,dE,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end else self.parent:writeText(aY,aZ+E,h(dl[E+dr].text,dE,dq),dl[E+dr].bgCol,dl[E+dr].fgCol)end end end end end end end end}return setmetatable(aw,aU)end;local function dJ(an)local aU=am(an)local ao="Radio"aU.weight=8;aU.bgcolor=a.listBG;aU.fgcolor=a.listFG;aU:setZIndex(5)local dl={}local dm=a.selectionBG;local dn=a.selectionFG;local dK=aU.bgcolor;local dL=aU.fgcolor;local dp=true;local a0="\7"local dq="left"local aw={getType=function(self)return ao end,addItem=function(self,i,N,O,Z,_,...)table.insert(dl,{x=N or 1,y=O or 1,text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})if#dl==1 then self:setValue(dl[1])end;return self end,removeItem=function(self,a7)table.remove(dl,a7)return self end,getItem=function(self,a7)return dl[a7]end,getItemIndex=function(self)local du=self:getValue()for dv,bY in pairs(dl)do if bY==du then return dv end end end,clear=function(self)dl={}self:setValue({})return self end,getItemCount=function(self)return#dl end,editItem=function(self,a7,i,N,O,Z,_,...)table.remove(dl,a7)table.insert(dl,a7,{x=N or 1,y=O or 1,text=i,bgCol=Z or self.bgcolor,fgCol=_ or self.fgcolor,args={...}})return self end,selectItem=function(self,a7)self:setValue(dl[a7]or{})return self end,setSelectedItem=function(self,Z,_,dM,dN,dw)dm=Z or dm;dn=_ or dn;dK=dM or dK;dL=dN or dL;dp=dw;return self end,mouseClickHandler=function(self,a8,aL,N,O)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if a8=="mouse_click"then if aL==1 then if#dl>0 then for ab,bY in pairs(dl)do if aY+bY.x-1<=N and aY+bY.x-1+bY.text:len()+2>=N and aZ+bY.y-1==O then self:setValue(bY)if self.parent~=nil then self.parent:setFocusedObject(self)end;self:setVisualChanged()return true end end end end end;return false end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()for ab,bY in pairs(dl)do if bY==self:getValue()then if dq=="left"then self.parent:writeText(bY.x+aY-1,bY.y+aZ-1,a0,dK,dL)self.parent:writeText(bY.x+2+aY-1,bY.y+aZ-1,bY.text,dm,dn)end else self.parent:drawBackgroundBox(bY.x+aY-1,bY.y+aZ-1,1,1,self.bgcolor)self.parent:writeText(bY.x+2+aY-1,bY.y+aZ-1,bY.text,bY.bgCol,bY.fgCol)end end end end end}return setmetatable(aw,aU)end;local function dO(an)local ao="Timer"local dP=0;local dQ=0;local dR=0;local dS;local av=a5()local aw={name=an,getType=function(self)return ao end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,setTime=function(self,dT,dU)dP=dT or 0;dQ=dU or 1;return self end,start=function(self)dR=dQ;dS=os.startTimer(dP)return self end,cancel=function(self)if dS~=nil then os.cancelTimer(dS)end;return self end,onCall=function(self,aa)av:registerEvent("timed_event",aa)return self end,eventHandler=function(self,a8,dV)if a8=="timer"and dV==dS then av:sendEvent("timed_event",self)if dR>=1 then dR=dR-1;if dR>=1 then dS=os.startTimer(dP)end elseif dR==-1 then dS=os.startTimer(dP)end end end}aw.__index=aw;return aw end;local function dW(an)local aw;local ao="Thread"local aa;local dX;local dY=false;aw={name=an,getType=function(self)return ao end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,start=function(self,cS)if cS==nil then error("function is nil")end;aa=cS;dX=coroutine.create(aa)dY=true;local ak,al=coroutine.resume(dX)if not ak then if al~="Terminated"then error("Threaderror - "..al)end end;return self end,getStatus=function(self,cS)if dX~=nil then return coroutine.status(dX)end;return nil end,stop=function(self,cS)dY=false;return self end,eventHandler=function(self,a8,aP,aQ,aR)if dY then if coroutine.status(dX)~="dead"then local ak,al=coroutine.resume(dX,a8,aP,aQ,aR)if not ak then if al~="Terminated"then error("Threaderror - "..al)end end else dY=false end end end}aw.__index=aw;return aw end;local function dZ(an)local aw={}local ao="Animation"local dS;local d_={}local a7=1;local e0=0;local e1;local function e2()if d_[a7]~=nil then d_[a7].f(aw,a7)end;a7=a7+1;if d_[a7]~=nil then if d_[a7].t>0 then dS=os.startTimer(d_[a7].t)else e2()end end end;aw={name=an,getType=function(self)return ao end,getZIndex=function(self)return 1 end,getName=function(self)return self.name end,add=function(self,aa,e3)e1=aa;table.insert(d_,{f=aa,t=e3 or e0})return self end,wait=function(self,e3)e0=e3;return self end,rep=function(self,e4)for N=1,e4 do table.insert(d_,{f=e1,t=e0})end;return self end,clear=function(self)d_={}e1=nil;e0=0;a7=1;return self end,play=function(self)a7=1;if d_[a7]~=nil then if d_[a7].t>0 then dS=os.startTimer(d_[a7].t)else e2()end end;return self end,cancel=function(self)os.cancelTimer(dS)return self end,eventHandler=function(self,a8,dV)if a8=="timer"and dV==dS then if d_[a7]~=nil then e2()end end end}aw.__index=aw;return aw end;local function e5(an)local aU=am(an)local ao="Slider"aU.weight=8;aU.bgcolor=colors.lightGray;aU.fgcolor=colors.gray;aU:setValue(1)local e6="horizontal"local a0=" "local e7=colors.black;local e8="\140"local e9=aU.w;local a7=1;local aw={getType=function(self)return ao end,setSymbol=function(self,ea)a0=ea:sub(1,1)self:setVisualChanged()return self end,setBackgroundSymbol=function(self,eb)e8=string.sub(eb,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,ec)e7=ec;self:setVisualChanged()return self end,setBarType=function(self,ed)e6=ed:lower()return self end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if e6=="horizontal"then for ee=0,self.weight-1 do if aY+ee==N and aZ<=O and aZ+self.height>O then a7=ee+1;self:setValue(e9/self.weight*a7)self:setVisualChanged()end end end;if e6=="vertical"then for ee=0,self.height-1 do if aZ+ee==O and aY<=N and aY+self.weight>N then a7=ee+1;self:setValue(e9/self.height*a7)self:setVisualChanged()end end end end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()if e6=="horizontal"then self.parent:writeText(aY,aZ,e8:rep(a7-1),self.bgcolor,self.fgcolor)self.parent:writeText(aY+a7-1,aZ,a0,e7,e7)self.parent:writeText(aY+a7,aZ,e8:rep(self.weight-a7),self.bgcolor,self.fgcolor)end;if e6=="vertical"then for E=0,self.height-1 do if E+1==a7 then self.parent:writeText(aY,aZ+E,a0,e7,e7)else self.parent:writeText(aY,aZ+E,e8,self.bgcolor,self.fgcolor)end end end end end end}return setmetatable(aw,aU)end;local function ef(an)local aU=am(an)local ao="Scrollbar"aU.weight=1;aU.height=8;aU.bgcolor=colors.lightGray;aU.fgcolor=colors.gray;aU:setValue(1)aU:setZIndex(2)local e6="vertical"local a0=" "local e7=colors.black;local e8="\127"local e9=aU.h;local a7=1;local eg=1;local aw={getType=function(self)return ao end,setSymbol=function(self,ea)a0=ea:sub(1,1)self:setVisualChanged()return self end,setSymbolSize=function(self,eh)eg=tonumber(eh)or 1;if e6=="vertical"then self:setValue(a7-1*e9/(self.height-(eg-1))-e9/(self.height-(eg-1)))elseif e6=="horizontal"then self:setValue(a7-1*e9/(self.weight-(eg-1))-e9/(self.weight-(eg-1)))end;self:setVisualChanged()return self end,setMaxValue=function(self,d5)e9=d5;return self end,setBackgroundSymbol=function(self,eb)e8=string.sub(eb,1,1)self:setVisualChanged()return self end,setSymbolColor=function(self,ec)e7=ec;self:setVisualChanged()return self end,setBarType=function(self,ed)e6=ed:lower()return self end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if(a8=="mouse_click"or a8=="mouse_drag")and aL==1 then if e6=="horizontal"then for ee=0,self.weight do if aY+ee==N and aZ<=O and aZ+self.height>O then a7=math.min(ee+1,self.weight-(eg-1))self:setValue(e9/self.weight*a7)self:setVisualChanged()end end end;if e6=="vertical"then for ee=0,self.height do if aZ+ee==O and aY<=N and aY+self.weight>N then a7=math.min(ee+1,self.height-(eg-1))self:setValue(e9/self.height*a7)self:setVisualChanged()end end end end;if a8=="mouse_scroll"then a7=a7+aL;if a7<1 then a7=1 end;a7=math.min(a7,(e6=="vertical"and self.height or self.weight)-(eg-1))self:setValue(e9/(e6=="vertical"and self.height or self.weight)*a7)end;return true end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()if e6=="horizontal"then self.parent:writeText(aY,aZ,e8:rep(a7-1),self.bgcolor,self.fgcolor)self.parent:writeText(aY+a7-1,aZ,a0:rep(eg),e7,e7)self.parent:writeText(aY+a7+eg-1,aZ,e8:rep(self.weight-(a7+eg-1)),self.bgcolor,self.fgcolor)end;if e6=="vertical"then for E=0,self.height-1 do if a7==E+1 then for ei=0,math.min(eg-1,self.height)do self.parent:writeText(aY,aZ+E+ei,a0,e7,e7)end else if E+1a7-1+eg then self.parent:writeText(aY,aZ+E,e8,self.bgcolor,self.fgcolor)end end end end end end end}return setmetatable(aw,aU)end;local function ej(an)local aU=am(an)local ao="Switch"aU.weight=3;aU.height=1;aU.bgcolor=colors.lightGray;aU.fgcolor=colors.gray;aU:setValue(false)aU:setZIndex(5)local aw={getType=function(self)return ao end,mouseClickHandler=function(self,a8,aL,N,O)if aU.mouseClickHandler(self,a8,aL,N,O)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if(a8=="mouse_click"or a8=="mouse_drag")and aL==1 then end;return true end end,draw=function(self)if aU.draw(self)then if self.parent~=nil then local aY,aZ=self:getAnchorPosition()end end end}return setmetatable(aw,aU)end;local function ek(an,el)local aU=am(an)local ao="Frame"local em={}local en={}local aw={}local eo;aU:setZIndex(10)local b6=false;local b2=1;local b3=1;local ep=colors.white;local eq,dr=0,0;if el~=nil then aU.parent=el;aU.weight,aU.height=el.w,el.h;aU.bgcolor=a.FrameBG;aU.fgcolor=a.FrameFG else local er,es=f.getSize()aU.weight,aU.height=er,es;aU.bgcolor=a.basaltBG;aU.fgcolor=a.basaltFG end;local function et(an)for dv,bY in pairs(em)do for cr,bE in pairs(bY)do if bE.name==an then return bY end end end end;local function eu(ev)local ap=ev:getZIndex()if et(ev.name)~=nil then return nil end;if em[ap]==nil then for N=1,#en+1 do if en[N]~=nil then if ap==en[N]then break end;if ap>en[N]then table.insert(en,N,ap)break end else table.insert(en,ap)end end;if#en<=0 then table.insert(en,ap)end;em[ap]={}end;ev.parent=aw;table.insert(em[ap],ev)return ev end;local function ew(ev)for cr,bE in pairs(em)do for dv,bY in pairs(bE)do if bY==ev then table.remove(em[cr],dv)return true end end end;return false end;aw={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",isMoveable=false,getType=function(self)return ao end,setFocusedObject=function(self,ev)for ab,a7 in pairs(en)do for ab,bY in pairs(em[a7])do if bY==ev then if eo~=nil then eo:loseFocusHandler()end;eo=ev;eo:getFocusHandler()end end end;return self end,setOffset=function(self,aI,aJ)eq=aI~=nil and math.floor(aI<0 and math.abs(aI)or-aI)or eq;dr=aJ~=nil and math.floor(aJ<0 and math.abs(aJ)or-aJ)or dr;return self end,getFrameOffset=function(self)return eq,dr end,removeFocusedObject=function(self)if eo~=nil then eo:loseFocusHandler()end;eo=nil;return self end,getFocusedObject=function(self)return eo end,show=function(self)aU:show()if self.parent==nil then c=self end;return self end,setCursor=function(self,ex,ey,ez,aE)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())b6=ex or false;if ey~=nil then b2=aY+ey-1 end;if ez~=nil then b3=aZ+ez-1 end;ep=aE or ep;self:setVisualChanged()return self end,setMoveable=function(self,eA)self.isMoveable=eA or not self.isMoveable;self:setVisualChanged()return self end,showBar=function(self,eB)self.barActive=eB or not self.barActive;self:setVisualChanged()return self end,setBar=function(self,i,Z,_)self.barText=i or""self.barBackground=Z or self.barBackground;self.barTextcolor=_ or self.barTextcolor;self:setVisualChanged()return self end,setBarTextAlign=function(self,dq)self.barTextAlign=dq or"left"self:setVisualChanged()return self end,getVisualChanged=function(self)local eC=aU.getVisualChanged(self)for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.getVisualChanged~=nil and bY:getVisualChanged()then eC=true end end end end;return eC end,loseFocusHandler=function(self)aU.loseFocusHandler(self)end,getFocusHandler=function(self)aU.getFocusHandler(self)if self.parent~=nil then self.parent:removeObject(self)self.parent:addObject(self)end end,keyHandler=function(self,a8,aO)if eo~=nil then if eo.keyHandler~=nil then if eo:keyHandler(a8,aO)then return true end end end;return false end,backgroundKeyHandler=function(self,a8,aO)aU.backgroundKeyHandler(self,a8,aO)for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.backgroundKeyHandler~=nil then bY:backgroundKeyHandler(a8,aO)end end end end end,eventHandler=function(self,a8,aP,aQ,aR,aS)aU.eventHandler(self,a8,aP,aQ,aR,aS)for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.eventHandler~=nil then bY:eventHandler(a8,aP,aQ,aR,aS)end end end end;if a8=="terminate"then f.clear()f.setCursorPos(1,1)b.stop()end end,mouseClickHandler=function(self,a8,aL,N,O)local aI,aJ=self:getOffset()aI=aI<0 and math.abs(aI)or-aI;aJ=aJ<0 and math.abs(aJ)or-aJ;if self.drag then if a8=="mouse_drag"then local eD=1;local eE=1;if self.parent~=nil then eD,eE=self.parent:getAbsolutePosition(self.parent:getAnchorPosition())end;self:setPosition(N+self.xToRem-(eD-1)+aI,O-(eE-1)+aJ)end;if a8=="mouse_up"then self.drag=false end;return true end;if aU.mouseClickHandler(self,a8,aL,N,O)then local aF,aG=self:getAbsolutePosition(self:getAnchorPosition())for ab,a7 in pairs(en)do if em[a7]~=nil then for ab,bY in o(em[a7])do if bY.mouseClickHandler~=nil then if bY:mouseClickHandler(a8,aL,N+aI,O+aJ)then return true end end end end end;if self.isMoveable then if N>=aF and N<=aF+self.weight-1 and O==aG and a8=="mouse_click"then self.drag=true;self.xToRem=aF-N end end;if eo~=nil then eo:loseFocusHandler()eo=nil end;return true end;return false end,setText=function(self,N,O,i)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:setText(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(i,math.max(1-N+1,1),self.weight-N+1))else X.setText(math.max(N+aY-1,aY),aZ+O-1,g(i,math.max(1-N+1,1),self.weight-N+1))end end end,setBG=function(self,N,O,Z)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:setBG(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(Z,math.max(1-N+1,1),self.weight-N+1))else X.setBG(math.max(N+aY-1,aY),aZ+O-1,g(Z,math.max(1-N+1,1),self.weight-N+1))end end end,setFG=function(self,N,O,_)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:setFG(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(_,math.max(1-N+1,1),self.weight-N+1))else X.setFG(math.max(N+aY-1,aY),aZ+O-1,g(_,math.max(1-N+1,1),self.weight-N+1))end end end,writeText=function(self,N,O,i,Z,_)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())if O>=1 and O<=self.height then if self.parent~=nil then self.parent:writeText(math.max(N+aY-1,aY)-(self.parent.x-1),aZ+O-1-(self.parent.y-1),g(i,math.max(1-N+1,1),self.weight-N+1),Z,_)else X.writeText(math.max(N+aY-1,aY),aZ+O-1,g(i,math.max(1-N+1,1),self.weight-N+1),Z,_)end end end,drawBackgroundBox=function(self,N,O,Y,n,Z)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.height and self.height or n+O-1)or(n+O>self.height and self.height-O+1 or n)Y=N<1 and(Y+N>self.weight and self.weight or Y+N-1)or(Y+N>self.weight and self.weight-N+1 or Y)if self.parent~=nil then self.parent:drawBackgroundBox(math.max(N+aY-1,aY)-(self.parent.x-1),math.max(O+aZ-1,aZ)-(self.parent.y-1),Y,n,Z)else X.drawBackgroundBox(math.max(N+aY-1,aY),math.max(O+aZ-1,aZ),Y,n,Z)end end,drawTextBox=function(self,N,O,Y,n,a0)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.height and self.height or n+O-1)or(n+O>self.height and self.height-O+1 or n)Y=N<1 and(Y+N>self.weight and self.weight or Y+N-1)or(Y+N>self.weight and self.weight-N+1 or Y)if self.parent~=nil then self.parent:drawTextBox(math.max(N+aY-1,aY)-(self.parent.x-1),math.max(O+aZ-1,aZ)-(self.parent.y-1),Y,n,a0:sub(1,1))else X.drawTextBox(math.max(N+aY-1,aY),math.max(O+aZ-1,aZ),Y,n,a0:sub(1,1))end end,drawForegroundBox=function(self,N,O,Y,n,_)local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())n=O<1 and(n+O>self.height and self.height or n+O-1)or(n+O>self.height and self.height-O+1 or n)Y=N<1 and(Y+N>self.weight and self.weight or Y+N-1)or(Y+N>self.weight and self.weight-N+1 or Y)if self.parent~=nil then self.parent:drawForegroundBox(math.max(N+aY-1,aY)-(self.parent.x-1),math.max(O+aZ-1,aZ)-(self.parent.y-1),Y,n,_)else X.drawForegroundBox(math.max(N+aY-1,aY),math.max(O+aZ-1,aZ),Y,n,_)end end,draw=function(self)if self:getVisualChanged()then if aU.draw(self)then local aY,aZ=self:getAbsolutePosition(self:getAnchorPosition())local di,dj=self:getAnchorPosition()if self.parent~=nil then self.parent:drawBackgroundBox(di,dj,self.weight,self.height,self.bgcolor)self.parent:drawForegroundBox(di,dj,self.weight,self.height,self.fgcolor)self.parent:drawTextBox(di,dj,self.weight,self.height," ")else X.drawBackgroundBox(aY,aZ,self.weight,self.height,self.bgcolor)X.drawForegroundBox(aY,aZ,self.weight,self.height,self.fgcolor)X.drawTextBox(aY,aZ,self.weight,self.height," ")end;f.setCursorBlink(false)if self.barActive then if self.parent~=nil then self.parent:writeText(di,dj,h(self.barText,self.weight,self.barTextAlign),self.barBackground,self.barTextcolor)else X.writeText(aY,aZ,h(self.barText,self.weight,self.barTextAlign),self.barBackground,self.barTextcolor)end end;for ab,a7 in o(en)do if em[a7]~=nil then for ab,bY in pairs(em[a7])do if bY.draw~=nil then bY:draw()end end end end;if b6 then f.setTextColor(ep)f.setCursorPos(b2,b3)if self.parent~=nil then f.setCursorBlink(self:isFocused())else f.setCursorBlink(b6)end end;self:setVisualChanged(false)end end end,addObject=function(self,ev)return eu(ev)end,removeObject=function(self,ev)return ew(ev)end,getObject=function(self,ev)return et(ev)end,addButton=function(self,an)local ev=aT(an)ev.name=an;return eu(ev)end,addLabel=function(self,an)local ev=c2(an)ev.name=an;ev.bgcolor=self.bgcolor;ev.fgcolor=self.fgcolor;return eu(ev)end,addCheckbox=function(self,an)local ev=cI(an)ev.name=an;return eu(ev)end,addInput=function(self,an)local ev=cT(an)ev.name=an;return eu(ev)end,addProgram=function(self,an)local ev=b0(an)ev.name=an;return eu(ev)end,addTextfield=function(self,an)local ev=db(an)ev.name=an;return eu(ev)end,addList=function(self,an)local ev=dk(an)ev.name=an;return eu(ev)end,addDropdown=function(self,an)local ev=dD(an)ev.name=an;return eu(ev)end,addRadio=function(self,an)local ev=dJ(an)ev.name=an;return eu(ev)end,addTimer=function(self,an)local ev=dO(an)ev.name=an;return eu(ev)end,addAnimation=function(self,an)local ev=dZ(an)ev.name=an;return eu(ev)end,addSlider=function(self,an)local ev=e5(an)ev.name=an;return eu(ev)end,addScrollbar=function(self,an)local ev=ef(an)ev.name=an;return eu(ev)end,addMenubar=function(self,an)local ev=dy(an)ev.name=an;return eu(ev)end,addThread=function(self,an)local ev=dW(an)ev.name=an;return eu(ev)end,addPane=function(self,an)local ev=c4(an)ev.name=an;return eu(ev)end,addImage=function(self,an)local ev=c5(an)ev.name=an;return eu(ev)end,addProgressbar=function(self,an)local ev=cJ(an)ev.name=an;return eu(ev)end,addFrame=function(self,an)local ev=ek(an,self)ev.name=an;return eu(ev)end}setmetatable(aw,aU)if el==nil then table.insert(d,aw)end;return aw end;local eF=false;local function eG(a8,aP,aQ,aR,aS)if a8=="mouse_click"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="mouse_drag"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="mouse_up"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="mouse_scroll"then c:mouseClickHandler(a8,aP,aQ,aR,aS)end;if a8=="key"or a8=="char"then c:keyHandler(a8,aP)c:backgroundKeyHandler(a8,aP)end;for ab,bY in pairs(d)do bY:eventHandler(a8,aP,aQ,aR,aS)end;if eF then c:draw()X.update()end end;function b.autoUpdate(dY)f.clear()eF=dY or true;c:draw()X.update()while eF do local a8,aP,aQ,aR,aS=os.pullEventRaw()eG(a8,aP,aQ,aR,aS)end end;function b.update(a8,aP,aQ,aR,aS)if a8~="nil"then eG(a8,aP,aQ,aR,aS)else c:draw()X.update()end end;function b.stop()eF=false end;function b.getFrame(an)for dv,bY in pairs(d)do if bY.name==an then return bY end end end;function b.getActiveFrame()return c end;function b.setActiveFrame(ax)if ax:getType()=="Frame"then c=ax;return true end;return false end;function b.createFrame(an)local ax=ek(an)return ax end;function b.removeFrame(an)for dv,bY in pairs(d)do if bY.name==an then d[dv]=nil;return true end end;return false end;if b.debugger then b.debugFrame=b.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)b.debugList=b.debugFrame:addList("debugList"):setSize(b.debugFrame.w-2,b.debugFrame.h-3):setPosition(2,3):setScrollable(true):show()b.debugFrame:addButton("back"):setAnchor("right"):setSize(1,1):setText("\22"):onClick(function()b.oldFrame:show()end):setBackground(colors.red):show()b.debugLabel=b.debugFrame:addLabel("debugLabel"):onClick(function()b.oldFrame=c;b.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()end;if b.debugger then function b.debug(...)local ai={...}if c.name~="basaltDebuggingFrame"then if c~=b.debugLabel.frame then b.debugLabel:setParent(c)end end;local eH=""for dv,bY in pairs(ai)do eH=eH..tostring(bY)..(#ai~=dv and", "or"")end;b.debugLabel:setText("[Debug] "..eH)b.debugList:addItem(eH)if b.debugList:getItemCount()>50 then b.debugList:removeItem(1)end;b.debugList:setValue(b.debugList:getItem(b.debugList:getItemCount()))b.debugLabel:show()end end;return b \ No newline at end of file diff --git a/source/basalt.lua b/source/basalt.lua index 03a71a3..97c444d 100644 --- a/source/basalt.lua +++ b/source/basalt.lua @@ -31,16 +31,16 @@ local parentTerminal = term.current() local sub = string.sub -local function getTextHorizontalAlign(text, w, textAlign) - text = string.sub(text, 1, w) - local n = w - string.len(text) +local function getTextHorizontalAlign(text, width, textAlign) + text = string.sub(text, 1, width) + local offset = width - string.len(text) if (textAlign == "right") then - text = string.rep(" ", n) .. text + text = string.rep(" ", offset) .. text elseif (textAlign == "center") then - text = string.rep(" ", math.floor(n / 2)) .. text .. string.rep(" ", math.floor(n / 2)) - text = text .. (string.len(text) < w and " " or "") + text = string.rep(" ", math.floor(offset / 2)) .. text .. string.rep(" ", math.floor(offset / 2)) + text = text .. (string.len(text) < width and " " or "") else - text = text .. string.rep(" ", n) + text = text .. string.rep(" ", offset) end return text end @@ -116,10 +116,10 @@ local function basaltDrawHelper() local emptyText = emptySpaceLine local emptyFG = emptyColorLines[colors.white] local emptyBG = emptyColorLines[colors.black] - for n = 1, height do - cacheT[n] = sub(cacheT[n] == nil and emptyText or cacheT[n] .. emptyText:sub(1, width - cacheT[n]:len()), 1, width) - cacheFG[n] = sub(cacheFG[n] == nil and emptyFG or cacheFG[n] .. emptyFG:sub(1, width - cacheFG[n]:len()), 1, width) - cacheBG[n] = sub(cacheBG[n] == nil and emptyBG or cacheBG[n] .. emptyBG:sub(1, width - cacheBG[n]:len()), 1, width) + for currentY = 1, height do + cacheT[currentY] = sub(cacheT[currentY] == nil and emptyText or cacheT[currentY] .. emptyText:sub(1, width - cacheT[currentY]:len()), 1, width) + cacheFG[currentY] = sub(cacheFG[currentY] == nil and emptyFG or cacheFG[currentY] .. emptyFG:sub(1, width - cacheFG[currentY]:len()), 1, width) + cacheBG[currentY] = sub(cacheBG[currentY] == nil and emptyBG or cacheBG[currentY] .. emptyBG:sub(1, width - cacheBG[currentY]:len()), 1, width) end end recreateWindowArray() @@ -291,8 +291,8 @@ local function BasaltEvents() sendEvent = function(self, _event, ...) if (events[_event] ~= nil) then - for k, v in pairs(events[_event]) do - v(...) + for _, value in pairs(events[_event]) do + value(...) end end end; @@ -354,7 +354,7 @@ end local function Object(name) -- Base object - local typ = "Object" -- not changeable + local objectType = "Object" -- not changeable --[[ local horizontalAnchor = "left" local verticalAnchor = "top" @@ -418,7 +418,7 @@ local function Object(name) end; getType = function(self) - return typ + return objectType end; getName = function(self) @@ -500,7 +500,7 @@ local function Object(name) end; setSize = function(self, w, h) - self.w, self.h = w, h + self.weight, self.height = w, h visualsChanged = true return self end; @@ -566,10 +566,10 @@ local function Object(name) y = self.y end if (hanchor == "right") then - x = self.parent.w - x - self.w + 2 + x = self.parent.w - x - self.weight + 2 end if (vanchor == "bottom") then - y = self.parent.h - y - self.h + 2 + y = self.parent.h - y - self.height + 2 end local xO, yO = self:getOffset() if (ignOffset or ignOff) then @@ -591,12 +591,12 @@ local function Object(name) end; setAnchor = function(self, ...) - for _, v in pairs(table.pack(...)) do - if (v == "right") or (v == "left") then - hanchor = v + for _, value in pairs(table.pack(...)) do + if (value == "right") or (value == "left") then + hanchor = value end - if (v == "top") or (v == "bottom") then - vanchor = v + if (value == "top") or (value == "bottom") then + vanchor = value end end visualsChanged = true @@ -680,7 +680,7 @@ local function Object(name) mouseClickHandler = function(self, event, button, x, y) local objX, objY = self:getAbsolutePosition(self:getAnchorPosition()) - if (objX <= x) and (objX + self.w > x) and (objY <= y) and (objY + self.h > y) and (isVisible) then + if (objX <= x) and (objX + self.weight > x) and (objY <= y) and (objY + self.height > y) and (isVisible) then if (self.parent ~= nil) then self.parent:setFocusedObject(self) end @@ -728,11 +728,11 @@ end local function Button(name) -- Button local base = Object(name) - local typ = "Button" + local objectType = "Button" base:setValue("Button") base:setZIndex(5) - base.w = 8 + base.weight = 8 base.bgcolor = theme.ButtonBG base.fgcolor = theme.ButtonFG @@ -741,7 +741,7 @@ local function Button(name) local object = { getType = function(self) - return typ + return objectType end; setHorizontalAlign = function(self, pos) textHorizontalAlign = pos @@ -760,14 +760,14 @@ local function Button(name) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - local verticalAlign = getTextVerticalAlign(self.h, textVerticalAlign) + local verticalAlign = getTextVerticalAlign(self.height, textVerticalAlign) - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - self.parent:drawForegroundBox(obx, oby, self.w, self.h, self.fgcolor) - self.parent:drawTextBox(obx, oby, self.w, self.h, " ") - for n = 1, self.h do + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + self.parent:drawForegroundBox(obx, oby, self.weight, self.height, self.fgcolor) + self.parent:drawTextBox(obx, oby, self.weight, self.height, " ") + for n = 1, self.height do if (n == verticalAlign) then - self.parent:setText(obx, oby + (n - 1), getTextHorizontalAlign(self:getValue(), self.w, textHorizontalAlign)) + self.parent:setText(obx, oby + (n - 1), getTextHorizontalAlign(self:getValue(), self.weight, textHorizontalAlign)) end end end @@ -780,7 +780,7 @@ end local function Program(name) local base = Object(name) - local typ = "Program" + local objectType = "Program" base:setZIndex(5) local object @@ -1186,16 +1186,16 @@ local function Program(name) return basaltwindow end - base.w = 30 - base.h = 12 - local pWindow = basaltWindow(1, 1, base.w, base.h) + base.weight = 30 + base.height = 12 + local pWindow = basaltWindow(1, 1, base.weight, base.height) local curProcess local paused = false local queuedEvent = {} object = { getType = function(self) - return typ + return objectType end; show = function(self) @@ -1228,7 +1228,7 @@ local function Program(name) setSize = function(self, w, h) base.setSize(self, w, h) - pWindow.basalt_resize(self.w, self.h) + pWindow.basalt_resize(self.weight, self.height) return self end; @@ -1354,7 +1354,7 @@ local function Program(name) local xCur, yCur = pWindow.getCursorPos() local obx, oby = self:getAnchorPosition() if (self.parent ~= nil) then - if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + self.w - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + self.h - 1) then + if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + self.weight - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + self.height - 1) then self.parent:setCursor(pWindow.getCursorBlink(), obx + xCur - 1, yCur + oby - 1, pWindow.getTextColor()) end end @@ -1388,7 +1388,7 @@ local function Program(name) local obx, oby = self:getAnchorPosition() local xCur, yCur = pWindow.getCursorPos() if (self.parent ~= nil) then - if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + self.w - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + self.h - 1) then + if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + self.weight - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + self.height - 1) then self.parent:setCursor(pWindow.getCursorBlink(), obx + xCur - 1, yCur + oby - 1, pWindow.getTextColor()) end end @@ -1410,7 +1410,7 @@ local function Program(name) if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() pWindow.basalt_reposition(obx, oby) - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) pWindow.basalt_update() end end @@ -1424,7 +1424,7 @@ end local function Label(name) -- Label local base = Object(name) - local typ = "Label" + local objectType = "Label" base:setZIndex(3) @@ -1433,19 +1433,19 @@ local function Label(name) local object = { getType = function(self) - return typ + return objectType end; setText = function(self, text) text = tostring(text) base:setValue(text) if (autoWidth) then - self.w = text:len() + self.weight = text:len() end return self end; setSize = function(self, w, h) - self.w, self.h = w, h + self.weight, self.height = w, h autoWidth = false return self end; @@ -1467,19 +1467,19 @@ end local function Pane(name) -- Pane local base = Object(name) - local typ = "Pane" + local objectType = "Pane" local object = { getType = function(self) - return typ + return objectType end; draw = function(self) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - self.parent:drawForegroundBox(obx, oby, self.w, self.h, self.bgcolor) + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + self.parent:drawForegroundBox(obx, oby, self.weight, self.height, self.bgcolor) end end end; @@ -1492,7 +1492,7 @@ end local function Image(name) -- Pane local base = Object(name) - local typ = "Image" + local objectType = "Image" base:setZIndex(2) local image local shrinkedImage @@ -1622,7 +1622,7 @@ local function Image(name) local object = { getType = function(self) - return typ + return objectType end; loadImage = function(self, path) @@ -1664,9 +1664,9 @@ local function Image(name) end end else - for yPos = 1, math.min(#image, self.h) do + for yPos = 1, math.min(#image, self.height) do local line = image[yPos] - for xPos = 1, math.min(#line, self.w) do + for xPos = 1, math.min(#line, self.weight) do if line[xPos] > 0 then self.parent:drawBackgroundBox(obx + xPos - 1, oby + yPos - 1, 1, 1, line[xPos]) end @@ -1685,12 +1685,12 @@ end local function Checkbox(name) -- Checkbox local base = Object(name) - local typ = "Checkbox" + local objectType = "Checkbox" base:setZIndex(5) base:setValue(false) - base.w = 1 - base.h = 1 + base.weight = 1 + base.height = 1 base.bgcolor = theme.CheckboxBG base.fgcolor = theme.CheckboxFG @@ -1698,7 +1698,7 @@ local function Checkbox(name) symbol = "\42", getType = function(self) - return typ + return objectType end; mouseClickHandler = function(self, event, button, x, y) @@ -1719,15 +1719,15 @@ local function Checkbox(name) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - local verticalAlign = getTextVerticalAlign(self.h, "center") + local verticalAlign = getTextVerticalAlign(self.height, "center") - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - for n = 1, self.h do + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + for n = 1, self.height do if (n == verticalAlign) then if (self:getValue() == true) then - self.parent:writeText(obx, oby + (n - 1), getTextHorizontalAlign(self.symbol, self.w, "center"), self.bgcolor, self.fgcolor) + self.parent:writeText(obx, oby + (n - 1), getTextHorizontalAlign(self.symbol, self.weight, "center"), self.bgcolor, self.fgcolor) else - self.parent:writeText(obx, oby + (n - 1), getTextHorizontalAlign(" ", self.w, "center"), self.bgcolor, self.fgcolor) + self.parent:writeText(obx, oby + (n - 1), getTextHorizontalAlign(" ", self.weight, "center"), self.bgcolor, self.fgcolor) end end end @@ -1743,14 +1743,14 @@ end local function Progressbar(name) -- Checkbox local base = Object(name) - local typ = "Progressbar" + local objectType = "Progressbar" local progress = 0 base:setZIndex(5) base:setValue(false) - base.w = 25 - base.h = 1 + base.weight = 25 + base.height = 1 base.bgcolor = theme.CheckboxBG base.fgcolor = theme.CheckboxFG @@ -1763,7 +1763,7 @@ local function Progressbar(name) local object = { getType = function(self) - return typ + return objectType end; setDirection = function(self, dir) @@ -1811,25 +1811,25 @@ local function Progressbar(name) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - self.parent:drawForegroundBox(obx, oby, self.w, self.h, self.fgcolor) - self.parent:drawTextBox(obx, oby, self.w, self.h, bgBarSymbol) + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + self.parent:drawForegroundBox(obx, oby, self.weight, self.height, self.fgcolor) + self.parent:drawTextBox(obx, oby, self.weight, self.height, bgBarSymbol) if (direction == 1) then - self.parent:drawBackgroundBox(obx, oby, self.w, self.h / 100 * progress, activeBarColor) - self.parent:drawForegroundBox(obx, oby, self.w, self.h / 100 * progress, activeBarSymbolCol) - self.parent:drawTextBox(obx, oby, self.w, self.h / 100 * progress, activeBarSymbol) + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height / 100 * progress, activeBarColor) + self.parent:drawForegroundBox(obx, oby, self.weight, self.height / 100 * progress, activeBarSymbolCol) + self.parent:drawTextBox(obx, oby, self.weight, self.height / 100 * progress, activeBarSymbol) elseif (direction == 2) then - self.parent:drawBackgroundBox(obx, oby + math.ceil(self.h - self.h / 100 * progress), self.w, self.h / 100 * progress, activeBarColor) - self.parent:drawForegroundBox(obx, oby + math.ceil(self.h - self.h / 100 * progress), self.w, self.h / 100 * progress, activeBarSymbolCol) - self.parent:drawTextBox(obx, oby + math.ceil(self.h - self.h / 100 * progress), self.w, self.h / 100 * progress, activeBarSymbol) + self.parent:drawBackgroundBox(obx, oby + math.ceil(self.height - self.height / 100 * progress), self.weight, self.height / 100 * progress, activeBarColor) + self.parent:drawForegroundBox(obx, oby + math.ceil(self.height - self.height / 100 * progress), self.weight, self.height / 100 * progress, activeBarSymbolCol) + self.parent:drawTextBox(obx, oby + math.ceil(self.height - self.height / 100 * progress), self.weight, self.height / 100 * progress, activeBarSymbol) elseif (direction == 3) then - self.parent:drawBackgroundBox(obx + math.ceil(self.w - self.w / 100 * progress), oby, self.w / 100 * progress, self.h, activeBarColor) - self.parent:drawForegroundBox(obx + math.ceil(self.w - self.w / 100 * progress), oby, self.w / 100 * progress, self.h, activeBarSymbolCol) - self.parent:drawTextBox(obx + math.ceil(self.w - self.w / 100 * progress), oby, self.w / 100 * progress, self.h, activeBarSymbol) + self.parent:drawBackgroundBox(obx + math.ceil(self.weight - self.weight / 100 * progress), oby, self.weight / 100 * progress, self.height, activeBarColor) + self.parent:drawForegroundBox(obx + math.ceil(self.weight - self.weight / 100 * progress), oby, self.weight / 100 * progress, self.height, activeBarSymbolCol) + self.parent:drawTextBox(obx + math.ceil(self.weight - self.weight / 100 * progress), oby, self.weight / 100 * progress, self.height, activeBarSymbol) else - self.parent:drawBackgroundBox(obx, oby, self.w / 100 * progress, self.h, activeBarColor) - self.parent:drawForegroundBox(obx, oby, self.w / 100 * progress, self.h, activeBarSymbolCol) - self.parent:drawTextBox(obx, oby, self.w / 100 * progress, self.h, activeBarSymbol) + self.parent:drawBackgroundBox(obx, oby, self.weight / 100 * progress, self.height, activeBarColor) + self.parent:drawForegroundBox(obx, oby, self.weight / 100 * progress, self.height, activeBarSymbolCol) + self.parent:drawTextBox(obx, oby, self.weight / 100 * progress, self.height, activeBarSymbol) end end end @@ -1843,14 +1843,14 @@ end local function Input(name) -- Input local base = Object(name) - local typ = "Input" + local objectType = "Input" local inputType = "text" local inputLimit = 0 base:setZIndex(5) base:setValue("") - base.w = 10 - base.h = 1 + base.weight = 10 + base.height = 1 base.bgcolor = theme.InputBG base.fgcolor = theme.InputFG @@ -1866,7 +1866,7 @@ local function Input(name) local object = { getType = function(self) - return typ + return objectType end; setInputType = function(self, iType) @@ -1969,8 +1969,8 @@ local function Input(name) if (textX < 1) then textX = 1 end - if (textX < wIndex) or (textX >= self.w + wIndex) then - wIndex = textX - self.w + 1 + if (textX < wIndex) or (textX >= self.weight + wIndex) then + wIndex = textX - self.weight + 1 end if (wIndex < 1) then wIndex = 1 @@ -1981,7 +1981,7 @@ local function Input(name) -- left arrow textX = textX - 1 if (textX >= 1) then - if (textX < wIndex) or (textX >= self.w + wIndex) then + if (textX < wIndex) or (textX >= self.weight + wIndex) then wIndex = textX end end @@ -2010,7 +2010,7 @@ local function Input(name) self:setValue(text:sub(1, textX - 1) .. key .. text:sub(textX, text:len())) textX = textX + 1 end - if (textX >= self.w + wIndex) then + if (textX >= self.weight + wIndex) then wIndex = wIndex + 1 end end @@ -2019,8 +2019,8 @@ local function Input(name) local val = tostring(base.getValue()) local cursorX = (textX <= val:len() and textX - 1 or val:len()) - (wIndex - 1) - if (cursorX > self.x + self.w - 1) then - cursorX = self.x + self.w - 1 + if (cursorX > self.x + self.weight - 1) then + cursorX = self.x + self.weight - 1 end if (self.parent ~= nil) then self.parent:setCursor(true, obx + cursorX, oby, self.fgcolor) @@ -2043,10 +2043,10 @@ local function Input(name) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - local verticalAlign = getTextVerticalAlign(self.h, "center") + local verticalAlign = getTextVerticalAlign(self.height, "center") - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - for n = 1, self.h do + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + for n = 1, self.height do if (n == verticalAlign) then local val = tostring(base.getValue()) local bCol = self.bgcolor @@ -2062,8 +2062,8 @@ local function Input(name) if (val ~= "") then text = val end - text = text:sub(wIndex, self.w + wIndex - 1) - local space = self.w - text:len() + text = text:sub(wIndex, self.weight + wIndex - 1) + local space = self.weight - text:len() if (space < 0) then space = 0 end @@ -2084,21 +2084,21 @@ end local function Textfield(name) local base = Object(name) - local typ = "Textfield" + local objectType = "Textfield" local hIndex, wIndex, textX, textY = 1, 1, 1, 1 local lines = { "" } local keyWords = { [colors.purple] = { "break" } } - base.w = 20 - base.h = 8 + base.weight = 20 + base.height = 8 base.bgcolor = theme.textfieldBG base.fgcolor = theme.textfieldFG base:setZIndex(5) local object = { getType = function(self) - return typ + return objectType end; getLines = function(self) @@ -2166,7 +2166,7 @@ local function Textfield(name) if (textY > 1) then table.remove(lines, textY) textX = lines[textY - 1]:len() + 1 - wIndex = textX - self.w + 1 + wIndex = textX - self.weight + 1 if (wIndex < 1) then wIndex = 1 end @@ -2175,7 +2175,7 @@ local function Textfield(name) elseif (textX <= 1) then if (textY > 1) then textX = lines[textY - 1]:len() + 1 - wIndex = textX - self.w + 1 + wIndex = textX - self.weight + 1 if (wIndex < 1) then wIndex = 1 end @@ -2219,7 +2219,7 @@ local function Textfield(name) textY = textY + 1 textX = 1 wIndex = 1 - if (textY - hIndex >= self.h) then + if (textY - hIndex >= self.height) then hIndex = hIndex + 1 end self:setValue("") @@ -2234,7 +2234,7 @@ local function Textfield(name) end if (wIndex > 1) then if (textX < wIndex) then - wIndex = textX - self.w + 1 + wIndex = textX - self.weight + 1 if (wIndex < 1) then wIndex = 1 end @@ -2255,7 +2255,7 @@ local function Textfield(name) textX = lines[textY]:len() + 1 end - if (textY >= hIndex + self.h) then + if (textY >= hIndex + self.height) then hIndex = hIndex + 1 end end @@ -2274,8 +2274,8 @@ local function Textfield(name) if (textX < 1) then textX = 1 end - if (textX < wIndex) or (textX >= self.w + wIndex) then - wIndex = textX - self.w + 1 + if (textX < wIndex) or (textX >= self.weight + wIndex) then + wIndex = textX - self.weight + 1 end if (wIndex < 1) then wIndex = 1 @@ -2286,7 +2286,7 @@ local function Textfield(name) -- arrow left textX = textX - 1 if (textX >= 1) then - if (textX < wIndex) or (textX >= self.w + wIndex) then + if (textX < wIndex) or (textX >= self.weight + wIndex) then wIndex = textX end end @@ -2294,7 +2294,7 @@ local function Textfield(name) if (textX < 1) then textY = textY - 1 textX = lines[textY]:len() + 1 - wIndex = textX - self.w + 1 + wIndex = textX - self.weight + 1 end end if (textX < 1) then @@ -2309,17 +2309,17 @@ local function Textfield(name) if (event == "char") then lines[textY] = lines[textY]:sub(1, textX - 1) .. key .. lines[textY]:sub(textX, lines[textY]:len()) textX = textX + 1 - if (textX >= self.w + wIndex) then + if (textX >= self.weight + wIndex) then wIndex = wIndex + 1 end self:setValue("") end local cursorX = (textX <= lines[textY]:len() and textX - 1 or lines[textY]:len()) - (wIndex - 1) - if (cursorX > self.x + self.w - 1) then - cursorX = self.x + self.w - 1 + if (cursorX > self.x + self.weight - 1) then + cursorX = self.x + self.weight - 1 end - local cursorY = (textY - hIndex < self.h and textY - hIndex or textY - hIndex - 1) + local cursorY = (textY - hIndex < self.height and textY - hIndex or textY - hIndex - 1) if (cursorX < 1) then cursorX = 0 end @@ -2371,8 +2371,8 @@ local function Textfield(name) if (event == "mouse_scroll") then hIndex = hIndex + button - if (hIndex > #lines - (self.h - 1)) then - hIndex = #lines - (self.h - 1) + if (hIndex > #lines - (self.height - 1)) then + hIndex = #lines - (self.height - 1) end if (hIndex < 1) then @@ -2380,7 +2380,7 @@ local function Textfield(name) end if (self.parent ~= nil) then - if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.w) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.h) then + if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.weight) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) else self.parent:setCursor(false) @@ -2396,15 +2396,15 @@ local function Textfield(name) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - self.parent:drawForegroundBox(obx, oby, self.w, self.h, self.fgcolor) - for n = 1, self.h do + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + self.parent:drawForegroundBox(obx, oby, self.weight, self.height, self.fgcolor) + for n = 1, self.height do local text = "" if (lines[n + hIndex - 1] ~= nil) then text = lines[n + hIndex - 1] end - text = text:sub(wIndex, self.w + wIndex - 1) - local space = self.w - text:len() + text = text:sub(wIndex, self.weight + wIndex - 1) + local space = self.weight - text:len() if (space < 0) then space = 0 end @@ -2421,9 +2421,9 @@ end local function List(name) local base = Object(name) - local typ = "List" - base.w = 16 - base.h = 6 + local objectType = "List" + base.weight = 16 + base.height = 6 base.bgcolor = theme.listBG base.fgcolor = theme.listFG base:setZIndex(5) @@ -2438,7 +2438,7 @@ local function List(name) local object = { getType = function(self) - return typ + return objectType end; addItem = function(self, text, bgCol, fgCol, ...) @@ -2511,14 +2511,14 @@ local function List(name) mouseClickHandler = function(self, event, button, x, y) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - if (obx <= x) and (obx + self.w > x) and (oby <= y) and (oby + self.h > y) and (self:isVisible()) then + if (obx <= x) and (obx + self.weight > x) and (oby <= y) and (oby + self.height > y) and (self:isVisible()) then if (event == "mouse_click") or (event == "mouse_drag") then -- remove mouse_drag if i want to make objects moveable uwuwuwuw if (button == 1) then if (#list > 0) then - for n = 1, self.h do + for n = 1, self.height do if (list[n + yOffset] ~= nil) then - if (obx <= x) and (obx + self.w > x) and (oby + n - 1 == y) then + if (obx <= x) and (obx + self.weight > x) and (oby + n - 1 == y) then self:setValue(list[n + yOffset]) self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n + yOffset]) end @@ -2534,8 +2534,8 @@ local function List(name) yOffset = 0 end if (button >= 1) then - if (#list > self.h) then - if (yOffset > #list - self.h) then + if (#list > self.height) then + if (yOffset > #list - self.height) then yOffset = #list - self.h end if (yOffset >= #list) then @@ -2555,17 +2555,17 @@ local function List(name) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - for n = 1, self.h do + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + for n = 1, self.height do if (list[n + yOffset] ~= nil) then if (list[n + yOffset] == self:getValue()) then if (selectionColorActive) then - self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.w, align), itemSelectedBG, itemSelectedFG) + self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.weight, align), itemSelectedBG, itemSelectedFG) else - self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.w, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) + self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.weight, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) end else - self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.w, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) + self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.weight, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) end end end @@ -2579,11 +2579,11 @@ end local function Menubar(name) local base = Object(name) - local typ = "Menubar" + local objectType = "Menubar" local object = {} - base.w = 30 - base.h = 1 + base.weight = 30 + base.height = 1 base.bgcolor = colors.gray base.fgcolor = colors.lightGray base:setZIndex(5) @@ -2612,7 +2612,7 @@ local function Menubar(name) object = { getType = function(self) - return typ + return objectType end; addItem = function(self, text, bgCol, fgCol, ...) @@ -2694,7 +2694,7 @@ local function Menubar(name) mouseClickHandler = function(self, event, button, x, y) local objX, objY = self:getAbsolutePosition(self:getAnchorPosition()) - if (objX <= x) and (objX + self.w > x) and (objY <= y) and (objY + self.h > y) and (self:isVisible()) then + if (objX <= x) and (objX + self.weight > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then if (self.parent ~= nil) then self.parent:setFocusedObject(self) end @@ -2702,7 +2702,7 @@ local function Menubar(name) local xPos = 1 for n = 1 + itemOffset, #list do if (list[n] ~= nil) then - if (xPos + list[n].text:len() + space * 2 <= self.w) then + if (xPos + list[n].text:len() + space * 2 <= self.weight) then if (objX + (xPos - 1) <= x) and (objX + (xPos - 1) + list[n].text:len() + space * 2 > x) and (objY == y) then self:setValue(list[n]) self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n]) @@ -2736,10 +2736,10 @@ local function Menubar(name) if (base.draw(self)) then if (self.parent ~= nil) then local obx, oby = self:getAnchorPosition() - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) local xPos = 0 - for k, v in pairs(list) do - if (xPos + v.text:len() + space * 2 <= self.w) then + for _, v in pairs(list) do + if (xPos + v.text:len() + space * 2 <= self.weight) then if (v == self:getValue()) then self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. v.text .. (" "):rep(space), v.text:len() + space * 2, align), itemSelectedBG or v.bgCol, itemSelectedFG or v.fgCol) else @@ -2747,11 +2747,11 @@ local function Menubar(name) end xPos = xPos + v.text:len() + space * 2 else - if (xPos < self.w + itemOffset) then + if (xPos < self.weight + itemOffset) then if (v == self:getValue()) then - self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. v.text .. (" "):rep(space), v.text:len() + space * 2, align):sub(1, self.w + itemOffset - xPos), itemSelectedBG or v.bgCol, itemSelectedFG or v.fgCol) + self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. v.text .. (" "):rep(space), v.text:len() + space * 2, align):sub(1, self.weight + itemOffset - xPos), itemSelectedBG or v.bgCol, itemSelectedFG or v.fgCol) else - self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. v.text .. (" "):rep(space), v.text:len() + space * 2, align):sub(1, self.w + itemOffset - xPos), v.bgCol, v.fgCol) + self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. v.text .. (" "):rep(space), v.text:len() + space * 2, align):sub(1, self.weight + itemOffset - xPos), v.bgCol, v.fgCol) end xPos = xPos + v.text:len() + space * 2 end @@ -2767,9 +2767,9 @@ end local function Dropdown(name) local base = Object(name) - local typ = "Dropdown" - base.w = 12 - base.h = 1 + local objectType = "Dropdown" + base.weight = 12 + base.height = 1 base.bgcolor = theme.dropdownBG base.fgcolor = theme.dropdownFG base:setZIndex(6) @@ -2789,7 +2789,7 @@ local function Dropdown(name) local object = { getType = function(self) - return typ + return objectType end; setIndexOffset = function(self, yOff) @@ -2905,14 +2905,14 @@ local function Dropdown(name) if (base.draw(self)) then local obx, oby = self:getAnchorPosition() if (self.parent ~= nil) then - self.parent:drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) + self.parent:drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) if (#list >= 1) then if (self:getValue() ~= nil) then if (self:getValue().text ~= nil) then if (state == 1) then - self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.w, align):sub(1, self.w - 1) .. closedSymbol, self.bgcolor, self.fgcolor) + self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.weight, align):sub(1, self.weight - 1) .. closedSymbol, self.bgcolor, self.fgcolor) else - self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.w, align):sub(1, self.w - 1) .. openedSymbol, self.bgcolor, self.fgcolor) + self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.weight, align):sub(1, self.weight - 1) .. openedSymbol, self.bgcolor, self.fgcolor) end end end @@ -2942,8 +2942,8 @@ end local function Radio(name) local base = Object(name) - local typ = "Radio" - base.w = 8 + local objectType = "Radio" + base.weight = 8 base.bgcolor = theme.listBG base.fgcolor = theme.listFG base:setZIndex(5) @@ -2959,7 +2959,7 @@ local function Radio(name) local object = { getType = function(self) - return typ + return objectType end; addItem = function(self, text, x, y, bgCol, fgCol, ...) @@ -3065,7 +3065,7 @@ local function Radio(name) end local function Timer(name) - local typ = "Timer" + local objectType = "Timer" local timer = 0 local savedRepeats = 0 @@ -3076,7 +3076,7 @@ local function Timer(name) local object = { name = name, getType = function(self) - return typ + return objectType end; getZIndex = function(self) @@ -3132,7 +3132,7 @@ end local function Thread(name) local object - local typ = "Thread" + local objectType = "Thread" local func local cRoutine @@ -3141,7 +3141,7 @@ local function Thread(name) object = { name = name, getType = function(self) - return typ + return objectType end; getZIndex = function(self) return 1 @@ -3202,7 +3202,7 @@ end local function Animation(name) local object = {} - local typ = "Animation" + local objectType = "Animation" local timerObj @@ -3229,7 +3229,7 @@ local function Animation(name) object = { name = name, getType = function(self) - return typ + return objectType end; getZIndex = function(self) @@ -3298,9 +3298,9 @@ end local function Slider(name) local base = Object(name) - local typ = "Slider" + local objectType = "Slider" - base.w = 8 + base.weight = 8 base.bgcolor = colors.lightGray base.fgcolor = colors.gray base:setValue(1) @@ -3314,7 +3314,7 @@ local function Slider(name) local object = { getType = function(self) - return typ + return objectType end; setSymbol = function(self, _symbol) @@ -3344,29 +3344,29 @@ local function Slider(name) if (base.mouseClickHandler(self, event, button, x, y)) then local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) if (barType == "horizontal") then - for _index = 0, self.w - 1 do - if (obx + _index == x) and (oby <= y) and (oby + self.h > y) then + for _index = 0, self.weight - 1 do + if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then index = _index + 1 - self:setValue(maxValue / self.w * (index)) + self:setValue(maxValue / self.weight * (index)) self:setVisualChanged() end end end if (barType == "vertical") then - for _index = 0, self.h - 1 do - if (oby + _index == y) and (obx <= x) and (obx + self.w > x) then + for _index = 0, self.height - 1 do + if (oby + _index == y) and (obx <= x) and (obx + self.weight > x) then index = _index + 1 - self:setValue(maxValue / self.h * (index)) + self:setValue(maxValue / self.height * (index)) self:setVisualChanged() end end end --[[if(event=="mouse_scroll")then - self:setValue(self:getValue() + (maxValue/(barType=="vertical" and self.h or self.w))*typ) + self:setValue(self:getValue() + (maxValue/(barType=="vertical" and self.height or self.weight))*typ) self:setVisualChanged() end if(self:getValue()>maxValue)then self:setValue(maxValue) end - if(self:getValue() y) then - index = math.min(_index + 1, self.w - (symbolSize - 1)) - self:setValue(maxValue / self.w * (index)) + for _index = 0, self.weight do + if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then + index = math.min(_index + 1, self.weight - (symbolSize - 1)) + self:setValue(maxValue / self.weight * (index)) self:setVisualChanged() end end end if (barType == "vertical") then - for _index = 0, self.h do - if (oby + _index == y) and (obx <= x) and (obx + self.w > x) then - index = math.min(_index + 1, self.h - (symbolSize - 1)) - self:setValue(maxValue / self.h * (index)) + for _index = 0, self.height do + if (oby + _index == y) and (obx <= x) and (obx + self.weight > x) then + index = math.min(_index + 1, self.height - (symbolSize - 1)) + self:setValue(maxValue / self.height * (index)) self:setVisualChanged() end end @@ -3490,8 +3490,8 @@ local function Scrollbar(name) if (index < 1) then index = 1 end - index = math.min(index, (barType == "vertical" and self.h or self.w) - (symbolSize - 1)) - self:setValue(maxValue / (barType == "vertical" and self.h or self.w) * index) + index = math.min(index, (barType == "vertical" and self.height or self.weight) - (symbolSize - 1)) + self:setValue(maxValue / (barType == "vertical" and self.height or self.weight) * index) end return true end @@ -3504,14 +3504,14 @@ local function Scrollbar(name) if (barType == "horizontal") then self.parent:writeText(obx, oby, bgSymbol:rep(index - 1), self.bgcolor, self.fgcolor) self.parent:writeText(obx + index - 1, oby, symbol:rep(symbolSize), symbolColor, symbolColor) - self.parent:writeText(obx + index + symbolSize - 1, oby, bgSymbol:rep(self.w - (index + symbolSize - 1)), self.bgcolor, self.fgcolor) + self.parent:writeText(obx + index + symbolSize - 1, oby, bgSymbol:rep(self.weight - (index + symbolSize - 1)), self.bgcolor, self.fgcolor) end if (barType == "vertical") then - for n = 0, self.h - 1 do + for n = 0, self.height - 1 do if (index == n + 1) then - for curIndexOffset = 0, math.min(symbolSize - 1, self.h) do + for curIndexOffset = 0, math.min(symbolSize - 1, self.height) do self.parent:writeText(obx, oby + n + curIndexOffset, symbol, symbolColor, symbolColor) end else @@ -3531,10 +3531,10 @@ end local function Switch(name) local base = Object(name) - local typ = "Switch" + local objectType = "Switch" - base.w = 3 - base.h = 1 + base.weight = 3 + base.height = 1 base.bgcolor = colors.lightGray base.fgcolor = colors.gray base:setValue(false) @@ -3542,7 +3542,7 @@ local function Switch(name) local object = { getType = function(self) - return typ + return objectType end; @@ -3573,7 +3573,7 @@ end local function Frame(name, parent) -- Frame local base = Object(name) - local typ = "Frame" + local objectType = "Frame" local objects = {} local objZIndex = {} local object = {} @@ -3589,12 +3589,12 @@ local function Frame(name, parent) if (parent ~= nil) then base.parent = parent - base.w, base.h = parent.w, parent.h + base.weight, base.height = parent.w, parent.h base.bgcolor = theme.FrameBG base.fgcolor = theme.FrameFG else local termW, termH = parentTerminal.getSize() - base.w, base.h = termW, termH + base.weight, base.height = termW, termH base.bgcolor = theme.basaltBG base.fgcolor = theme.basaltFG end @@ -3659,7 +3659,7 @@ local function Frame(name, parent) isMoveable = false, getType = function(self) - return typ + return objectType end; setFocusedObject = function(self, obj) @@ -3850,7 +3850,7 @@ local function Frame(name, parent) end if (self.isMoveable) then - if (x >= fx) and (x <= fx + self.w - 1) and (y == fy) and (event == "mouse_click") then + if (x >= fx) and (x <= fx + self.weight - 1) and (y == fy) and (event == "mouse_click") then self.drag = true self.xToRem = fx - x end @@ -3866,52 +3866,52 @@ local function Frame(name, parent) setText = function(self, x, y, text) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - if (y >= 1) and (y <= self.h) then + if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.w - x + 1)) + self.parent:setText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.weight - x + 1)) else - drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.w - x + 1)) + drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.weight - x + 1)) end end end; setBG = function(self, x, y, bgCol) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - if (y >= 1) and (y <= self.h) then + if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setBG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(bgCol, math.max(1 - x + 1, 1), self.w - x + 1)) + self.parent:setBG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(bgCol, math.max(1 - x + 1, 1), self.weight - x + 1)) else - drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.w - x + 1)) + drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.weight - x + 1)) end end end; setFG = function(self, x, y, fgCol) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - if (y >= 1) and (y <= self.h) then + if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:setFG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(fgCol, math.max(1 - x + 1, 1), self.w - x + 1)) + self.parent:setFG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(fgCol, math.max(1 - x + 1, 1), self.weight - x + 1)) else - drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.w - x + 1)) + drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.weight - x + 1)) end end end; writeText = function(self, x, y, text, bgCol, fgCol) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - if (y >= 1) and (y <= self.h) then + if (y >= 1) and (y <= self.height) then if (self.parent ~= nil) then - self.parent:writeText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.w - x + 1), bgCol, fgCol) + self.parent:writeText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.weight - x + 1), bgCol, fgCol) else - drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.w - x + 1), bgCol, fgCol) + drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.weight - x + 1), bgCol, fgCol) end end end; drawBackgroundBox = function(self, x, y, w, h, bgCol) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - h = (y < 1 and (h + y > self.h and self.h or h + y - 1) or (h + y > self.h and self.h - y + 1 or h)) - w = (x < 1 and (w + x > self.w and self.w or w + x - 1) or (w + x > self.w and self.w - x + 1 or w)) + h = (y < 1 and (h + y > self.height and self.height or h + y - 1) or (h + y > self.height and self.height - y + 1 or h)) + w = (x < 1 and (w + x > self.weight and self.weight or w + x - 1) or (w + x > self.weight and self.weight - x + 1 or w)) if (self.parent ~= nil) then self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), w, h, bgCol) else @@ -3921,8 +3921,8 @@ local function Frame(name, parent) drawTextBox = function(self, x, y, w, h, symbol) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - h = (y < 1 and (h + y > self.h and self.h or h + y - 1) or (h + y > self.h and self.h - y + 1 or h)) - w = (x < 1 and (w + x > self.w and self.w or w + x - 1) or (w + x > self.w and self.w - x + 1 or w)) + h = (y < 1 and (h + y > self.height and self.height or h + y - 1) or (h + y > self.height and self.height - y + 1 or h)) + w = (x < 1 and (w + x > self.weight and self.weight or w + x - 1) or (w + x > self.weight and self.weight - x + 1 or w)) if (self.parent ~= nil) then self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), w, h, symbol:sub(1, 1)) else @@ -3932,8 +3932,8 @@ local function Frame(name, parent) drawForegroundBox = function(self, x, y, w, h, fgCol) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) - h = (y < 1 and (h + y > self.h and self.h or h + y - 1) or (h + y > self.h and self.h - y + 1 or h)) - w = (x < 1 and (w + x > self.w and self.w or w + x - 1) or (w + x > self.w and self.w - x + 1 or w)) + h = (y < 1 and (h + y > self.height and self.height or h + y - 1) or (h + y > self.height and self.height - y + 1 or h)) + w = (x < 1 and (w + x > self.weight and self.weight or w + x - 1) or (w + x > self.weight and self.weight - x + 1 or w)) if (self.parent ~= nil) then self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), w, h, fgCol) else @@ -3947,20 +3947,20 @@ local function Frame(name, parent) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local anchx, anchy = self:getAnchorPosition() if (self.parent ~= nil) then - self.parent:drawBackgroundBox(anchx, anchy, self.w, self.h, self.bgcolor) - self.parent:drawForegroundBox(anchx, anchy, self.w, self.h, self.fgcolor) - self.parent:drawTextBox(anchx, anchy, self.w, self.h, " ") + self.parent:drawBackgroundBox(anchx, anchy, self.weight, self.height, self.bgcolor) + self.parent:drawForegroundBox(anchx, anchy, self.weight, self.height, self.fgcolor) + self.parent:drawTextBox(anchx, anchy, self.weight, self.height, " ") else - drawHelper.drawBackgroundBox(obx, oby, self.w, self.h, self.bgcolor) - drawHelper.drawForegroundBox(obx, oby, self.w, self.h, self.fgcolor) - drawHelper.drawTextBox(obx, oby, self.w, self.h, " ") + drawHelper.drawBackgroundBox(obx, oby, self.weight, self.height, self.bgcolor) + drawHelper.drawForegroundBox(obx, oby, self.weight, self.height, self.fgcolor) + drawHelper.drawTextBox(obx, oby, self.weight, self.height, " ") end parentTerminal.setCursorBlink(false) if (self.barActive) then if (self.parent ~= nil) then - self.parent:writeText(anchx, anchy, getTextHorizontalAlign(self.barText, self.w, self.barTextAlign), self.barBackground, self.barTextcolor) + self.parent:writeText(anchx, anchy, getTextHorizontalAlign(self.barText, self.weight, self.barTextAlign), self.barBackground, self.barTextcolor) else - drawHelper.writeText(obx, oby, getTextHorizontalAlign(self.barText, self.w, self.barTextAlign), self.barBackground, self.barTextcolor) + drawHelper.writeText(obx, oby, getTextHorizontalAlign(self.barText, self.weight, self.barTextAlign), self.barBackground, self.barTextcolor) end end