diff --git a/Basalt/Frame.lua b/Basalt/Frame.lua index 9813a42..800d2c0 100644 --- a/Basalt/Frame.lua +++ b/Basalt/Frame.lua @@ -1,6 +1,5 @@ local Object = require("Object") local _OBJECTS = require("loadObjects") -local log = require("basaltLogs") local BasaltDraw = require("basaltDraw") local utils = require("utils") local layout = require("layout") @@ -43,6 +42,7 @@ return function(name, parent, pTerm, basalt) local focusedObject local autoSize = true local autoScroll = true + local initialized = false local activeEvents = {} @@ -461,7 +461,6 @@ return function(name, parent, pTerm, basalt) local obx, oby = self:getAnchorPosition() self.parent:setCursor(_blink or false, (_xCursor or 0)+obx-1, (_yCursor or 0)+oby-1, color or cursorColor) else - log(_blink) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition(self:getX(), self:getY(), true)) cursorBlink = _blink or false if (_xCursor ~= nil) then @@ -744,9 +743,7 @@ return function(name, parent, pTerm, basalt) self:mouseHandler(1, p2, p3, true) end end - if (event == "terminate") then - termObject.setCursorPos(1, 1) - termObject.clear() + if (event == "terminate")and(self.parent==nil)then basalt.stop() end end, @@ -873,7 +870,7 @@ return function(name, parent, pTerm, basalt) return false end, - keyHandler = function(self, key) + keyHandler = function(self, key, isHolding) if (self:isFocused())or(self.parent==nil)then local val = self:getEventSystem():sendEvent("key", self, "key", key) if(val==false)then return false end @@ -882,7 +879,7 @@ return function(name, parent, pTerm, basalt) if (events["key"][index] ~= nil) then for _, value in rpairs(events["key"][index]) do if (value.keyHandler ~= nil) then - if (value:keyHandler(key)) then + if (value:keyHandler(key, isHolding)) then return true end end @@ -1087,14 +1084,17 @@ return function(name, parent, pTerm, basalt) end, init = function(self) - if (parent ~= nil) then - base.width, base.height = parent:getSize() - self:setBackground(parent:getTheme("FrameBG")) - self:setForeground(parent:getTheme("FrameText")) - else - base.width, base.height = termObject.getSize() - self:setBackground(basalt.getTheme("BasaltBG")) - self:setForeground(basalt.getTheme("BasaltText")) + if not(initialized)then + if (parent ~= nil) then + base.width, base.height = parent:getSize() + self:setBackground(parent:getTheme("FrameBG")) + self:setForeground(parent:getTheme("FrameText")) + else + base.width, base.height = termObject.getSize() + self:setBackground(basalt.getTheme("BasaltBG")) + self:setForeground(basalt.getTheme("BasaltText")) + end + initialized = true end end, } diff --git a/Basalt/Object.lua b/Basalt/Object.lua index 04ebdf1..042346a 100644 --- a/Basalt/Object.lua +++ b/Basalt/Object.lua @@ -314,7 +314,9 @@ return function(name) end; setTransparent = function(self, color) - transparentColor = color or false + self.transparentColor = color or false + self.bgSymbol = false + self.bgSymbolColor = false self:updateDraw() return self end; @@ -780,10 +782,10 @@ return function(name) return false end, - keyHandler = function(self, key) + keyHandler = function(self, key, isHolding) if(isEnabled)and(isVisible)then if (self:isFocused()) then - local val = eventSystem:sendEvent("key", self, "key", key) + local val = eventSystem:sendEvent("key", self, "key", key, isHolding) if(val==false)then return false end return true end @@ -818,7 +820,8 @@ return function(name) end; eventHandler = function(self, event, p1, p2, p3, p4) - eventSystem:sendEvent("other_event", self, event, p1, p2, p3, p4) + local val = eventSystem:sendEvent("other_event", self, event, p1, p2, p3, p4) + if(val~=nil)then return val end return true end; diff --git a/Basalt/basaltDraw.lua b/Basalt/basaltDraw.lua index 9301019..62ce41e 100644 --- a/Basalt/basaltDraw.lua +++ b/Basalt/basaltDraw.lua @@ -163,11 +163,15 @@ return function(drawTerm) end end; writeText = function(x, y, text, bgCol, fgCol) - bgCol = bgCol or terminal.getBackgroundColor() - fgCol = fgCol or terminal.getTextColor() - setText(x, y, text) - setBG(x, y, rep(tHex[bgCol], text:len())) - setFG(x, y, rep(tHex[fgCol], text:len())) + if(text~=nil)then + setText(x, y, text) + if(bgCol~=nil)and(bgCol~=false)then + setBG(x, y, rep(tHex[bgCol], text:len())) + end + if(fgCol~=nil)and(fgCol~=false)then + setFG(x, y, rep(tHex[fgCol], text:len())) + end + end end; update = function() diff --git a/Basalt/libraries/process.lua b/Basalt/libraries/process.lua index d2cf279..eadf1ae 100644 --- a/Basalt/libraries/process.lua +++ b/Basalt/libraries/process.lua @@ -3,12 +3,12 @@ local process = {} local processId = 0 function process:new(path, window, ...) - local args = table.pack(...) + local args = {...} local newP = setmetatable({ path = path }, { __index = self }) newP.window = window newP.processId = processId newP.coroutine = coroutine.create(function() - os.run({ basaltProcess = true }, path, table.unpack(args)) + shell.execute(path, table.unpack(args)) end) processes[processId] = newP processId = processId + 1 diff --git a/Basalt/main.lua b/Basalt/main.lua index c229e1b..3fbc654 100644 --- a/Basalt/main.lua +++ b/Basalt/main.lua @@ -2,9 +2,11 @@ local basaltEvent = require("basaltEvent")() local Frame = require("Frame") local theme = require("theme") local utils = require("utils") +local log = require("basaltLogs") local uuid = utils.uuid local createText = utils.createText + local baseTerm = term.current() local version = 5 local debugger = true @@ -14,12 +16,16 @@ local projectDirectory = fs.getDir(table.pack(...)[2] or "") local activeKey, frames, monFrames, variables, schedules = {}, {}, {}, {}, {} local mainFrame, activeFrame, focusedObject, updaterActive +local basalt = {} + if not term.isColor or not term.isColor() then error('Basalt requires an advanced (golden) computer to run.', 0) end local function stop() - updaterActive = false + updaterActive = false + baseTerm.clear() + baseTerm.setCursorPos(1, 1) end local setVariable = function(name, var) @@ -93,34 +99,19 @@ local basaltError = function(errMsg) baseTerm.setBackgroundColor(colors.black) baseTerm.setTextColor(colors.red) local w,h = baseTerm.getSize() - - local splitString = function(str, sep) - if sep == nil then - sep = "%s" - end - local t={} - for v in string.gmatch(str, "([^"..sep.."]+)") do - table.insert(t, v) - end - return t - end - local words = splitString(errMsg, " ") - local line = "Basalt error: " - local yPos = 1 - for n=1,#words do - baseTerm.setCursorPos(1,yPos) - if(#line+#words[n]