updated foreground and background color variables to fgColor and bgColor

This commit is contained in:
Samkist
2022-05-18 22:16:39 -04:00
parent 27246b6b10
commit 240434422c
2 changed files with 101 additions and 101 deletions

File diff suppressed because one or more lines are too long

View File

@@ -223,14 +223,14 @@ local function basaltDrawHelper()
setFG(x, y, colorStr) setFG(x, y, colorStr)
end; end;
drawBackgroundBox = function(x, y, width, height, bgCol) drawBackgroundBox = function(x, y, width, height, bgColor)
for n = 1, height do for n = 1, height do
setBG(x, y + (n - 1), tHex[bgCol]:rep(width)) setBG(x, y + (n - 1), tHex[bgColor]:rep(width))
end end
end; end;
drawForegroundBox = function(x, y, width, height, fgCol) drawForegroundBox = function(x, y, width, height, fgColor)
for n = 1, height do for n = 1, height do
setFG(x, y + (n - 1), tHex[fgCol]:rep(width)) setFG(x, y + (n - 1), tHex[fgColor]:rep(width))
end end
end; end;
drawTextBox = function(x, y, width, height, symbol) drawTextBox = function(x, y, width, height, symbol)
@@ -238,12 +238,12 @@ local function basaltDrawHelper()
setText(x, y + (n - 1), symbol:rep(width)) setText(x, y + (n - 1), symbol:rep(width))
end end
end; end;
writeText = function(x, y, text, bgCol, fgCol) writeText = function(x, y, text, bgColor, fgColor)
bgCol = bgCol or terminal.getBackgroundColor() bgColor = bgColor or terminal.getBackgroundColor()
fgCol = fgCol or terminal.getTextColor() fgColor = fgColor or terminal.getTextColor()
setText(x, y, text) setText(x, y, text)
setBG(x, y, tHex[bgCol]:rep(text:len())) setBG(x, y, tHex[bgColor]:rep(text:len()))
setFG(x, y, tHex[fgCol]:rep(text:len())) setFG(x, y, tHex[fgColor]:rep(text:len()))
end; end;
update = function() update = function()
@@ -836,7 +836,7 @@ local function Program(name)
end end
local function internalBlit(sText, sTextColor, sBackgroundColor) local function internalBlit(sText, sTextColor, sBackgroundColor)
-- copy pasti strikes again (cc: window.lua) -- copy pasta strikes again (cc: window.lua)
local nStart = xCursor local nStart = xCursor
local nEnd = nStart + #sText - 1 local nEnd = nStart + #sText - 1
if yCursor >= 1 and yCursor <= height then if yCursor >= 1 and yCursor <= height then
@@ -1060,14 +1060,14 @@ local function Program(name)
visible = vis visible = vis
end; end;
drawBackgroundBox = function(_x, _y, _width, _height, bgCol) drawBackgroundBox = function(_x, _y, _width, _height, bgColor)
for n = 1, _height do for n = 1, _height do
setBG(_x, _y + (n - 1), tHex[bgCol]:rep(_width)) setBG(_x, _y + (n - 1), tHex[bgColor]:rep(_width))
end end
end; end;
drawForegroundBox = function(_x, _y, _width, _height, fgCol) drawForegroundBox = function(_x, _y, _width, _height, fgColor)
for n = 1, _height do for n = 1, _height do
setFG(_x, _y + (n - 1), tHex[fgCol]:rep(_width)) setFG(_x, _y + (n - 1), tHex[fgColor]:rep(_width))
end end
end; end;
drawTextBox = function(_x, _y, _width, _height, symbol) drawTextBox = function(_x, _y, _width, _height, symbol)
@@ -1076,12 +1076,12 @@ local function Program(name)
end end
end; end;
writeText = function(_x, _y, text, bgCol, fgCol) writeText = function(_x, _y, text, bgColor, fgColor)
bgCol = bgCol or bgColor bgColor = bgColor or bgColor
fgCol = fgCol or fgColor fgColor = fgColor or fgColor
setText(x, _y, text) setText(x, _y, text)
setBG(_x, _y, tHex[bgCol]:rep(text:len())) setBG(_x, _y, tHex[bgColor]:rep(text:len()))
setFG(_x, _y, tHex[fgCol]:rep(text:len())) setFG(_x, _y, tHex[fgColor]:rep(text:len()))
end; end;
basalt_update = function() basalt_update = function()
@@ -1158,25 +1158,25 @@ local function Program(name)
end end
end; end;
blit = function(text, fgcol, bgcol) blit = function(text, _fgColor, _bgColor)
if type(text) ~= "string" then if type(text) ~= "string" then
error("bad argument #1 (expected string, got " .. type(text) .. ")", 2) error("bad argument #1 (expected string, got " .. type(text) .. ")", 2)
end end
if type(fgcol) ~= "string" then if type(_fgColor) ~= "string" then
error("bad argument #2 (expected string, got " .. type(fgcol) .. ")", 2) error("bad argument #2 (expected string, got " .. type(_fgColor) .. ")", 2)
end end
if type(bgcol) ~= "string" then if type(_bgColor) ~= "string" then
error("bad argument #3 (expected string, got " .. type(bgcol) .. ")", 2) error("bad argument #3 (expected string, got " .. type(_bgColor) .. ")", 2)
end end
if #fgcol ~= #text or #bgcol ~= #text then if #_fgColor ~= #text or #_bgColor ~= #text then
error("Arguments must be the same length", 2) error("Arguments must be the same length", 2)
end end
if (visible) then if (visible) then
--setText(xCursor, yCursor, text) --setText(xCursor, yCursor, text)
--setBG(xCursor, yCursor, bgcol) --setBG(xCursor, yCursor, bgColor)
--setFG(xCursor, yCursor, fgcol) --setFG(xCursor, yCursor, fgColor)
--xCursor = xCursor+text:len() --xCursor = xCursor+text:len()
internalBlit(text, fgcol, bgcol) internalBlit(text, _fgColor, _bgColor)
end end
end end
@@ -1587,7 +1587,7 @@ local function Image(name)
end end
end end
local results, width, height, bgCol = { {}, {}, {} }, 0, #image + #image % 3, base.bgColor or colors.black local results, width, height, bgColor = { {}, {}, {} }, 0, #image + #image % 3, base.bgColor or colors.black
for i = 1, #image do for i = 1, #image do
if #image[i] > width then if #image[i] > width then
width = #image[i] width = #image[i]
@@ -1603,7 +1603,7 @@ local function Image(name)
for yy = 1, 3 do for yy = 1, 3 do
for xx = 1, 2 do for xx = 1, 2 do
pattern[#pattern + 1] = (image[y + yy] and image[y + yy][x + xx]) and (image[y + yy][x + xx] == 0 and bgCol or image[y + yy][x + xx]) or bgCol pattern[#pattern + 1] = (image[y + yy] and image[y + yy][x + xx]) and (image[y + yy][x + xx] == 0 and bgColor or image[y + yy][x + xx]) or bgCol
totals[pattern[#pattern]] = totals[pattern[#pattern]] and (totals[pattern[#pattern]] + 1) or 1 totals[pattern[#pattern]] = totals[pattern[#pattern]] and (totals[pattern[#pattern]] + 1) or 1
end end
end end
@@ -1858,8 +1858,8 @@ local function Input(name)
local wIndex = 1 local wIndex = 1
local defaultText = "" local defaultText = ""
local defaultBGCol local defaultbgCol
local defaultFGCol local defaultfgCol
local showingText = defaultText local showingText = defaultText
local internalValueChange = false local internalValueChange = false
@@ -1878,8 +1878,8 @@ local function Input(name)
setDefaultText = function(self, text, fCol, bCol) setDefaultText = function(self, text, fCol, bCol)
defaultText = text defaultText = text
defaultBGCol = bCol or defaultBGCol defaultbgColor = bCol or defaultbgCol
defaultFGCol = fCol or defaultFGCol defaultfgColor = fCol or defaultfgCol
if (self:isFocused()) then if (self:isFocused()) then
showingText = "" showingText = ""
else else
@@ -2054,8 +2054,8 @@ local function Input(name)
local text local text
if (val:len() <= 0) then if (val:len() <= 0) then
text = showingText text = showingText
bCol = defaultBGCol or bCol bCol = defaultbgColor or bCol
fCol = defaultFGCol or fCol fCol = defaultfgColor or fCol
end end
text = showingText text = showingText
@@ -2331,7 +2331,7 @@ local function Textfield(name)
mouseClickHandler = function(self, event, button, x, y) mouseClickHandler = function(self, event, button, x, y)
if (base.mouseClickHandler(self, event, button, x, y)) then if (base.mouseClickHandler(self, event, button, x, y)) then
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
local anchx, anchy = self:getAnchorPosition() local anchorX, anchorY = self:getAnchorPosition()
if (event == "mouse_click") then if (event == "mouse_click") then
if (lines[y - oby + hIndex] ~= nil) then if (lines[y - oby + hIndex] ~= nil) then
textX = x - obx + wIndex textX = x - obx + wIndex
@@ -2346,7 +2346,7 @@ local function Textfield(name)
end end
end end
if (self.parent ~= nil) then if (self.parent ~= nil) then
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) self.parent:setCursor(true, anchorX + textX - wIndex, anchorY + textY - hIndex)
end end
end end
end end
@@ -2364,7 +2364,7 @@ local function Textfield(name)
end end
end end
if (self.parent ~= nil) then if (self.parent ~= nil) then
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) self.parent:setCursor(true, anchorX + textX - wIndex, anchorY + textY - hIndex)
end end
end end
end end
@@ -2381,7 +2381,7 @@ local function Textfield(name)
if (self.parent ~= nil) then if (self.parent ~= nil) then
if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex) self.parent:setCursor(true, anchorX + textX - wIndex, anchorY + textY - hIndex)
else else
self.parent:setCursor(false) self.parent:setCursor(false)
end end
@@ -2441,8 +2441,8 @@ local function List(name)
return objectType return objectType
end; end;
addItem = function(self, text, bgCol, fgCol, ...) addItem = function(self, text, bgColor, fgColor, ...)
table.insert(list, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, { text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
if (#list == 1) then if (#list == 1) then
self:setValue(list[1]) self:setValue(list[1])
end end
@@ -2486,9 +2486,9 @@ local function List(name)
return #list return #list
end; end;
editItem = function(self, index, text, bgCol, fgCol, ...) editItem = function(self, index, text, bgColor, fgColor, ...)
table.remove(list, index) table.remove(list, index)
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, index, { text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
return self return self
end; end;
@@ -2497,9 +2497,9 @@ local function List(name)
return self return self
end; end;
setSelectedItem = function(self, bgCol, fgCol, active) setSelectedItem = function(self, bgColor, fgColor, active)
itemSelectedBG = bgCol or self.bgColor itemSelectedBG = bgColor or self.bgColor
itemSelectedFG = fgCol or self.fgColor itemSelectedFG = fgColor or self.fgColor
selectionColorActive = active selectionColorActive = active
return self return self
end; end;
@@ -2562,10 +2562,10 @@ local function List(name)
if (selectionColorActive) then if (selectionColorActive) then
self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.width, align), itemSelectedBG, itemSelectedFG) self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.width, align), itemSelectedBG, itemSelectedFG)
else else
self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.width, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.width, align), list[n + yOffset].bgColor, list[n + yOffset].fgColor)
end end
else else
self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.width, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) self.parent:writeText(obx, oby + n - 1, getTextHorizontalAlign(list[n + yOffset].text, self.width, align), list[n + yOffset].bgColor, list[n + yOffset].fgColor)
end end
end end
end end
@@ -2615,8 +2615,8 @@ local function Menubar(name)
return objectType return objectType
end; end;
addItem = function(self, text, bgCol, fgCol, ...) addItem = function(self, text, bgColor, fgColor, ...)
table.insert(list, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, { text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
if (#list == 1) then if (#list == 1) then
self:setValue(list[1]) self:setValue(list[1])
end end
@@ -2674,9 +2674,9 @@ local function Menubar(name)
return #list return #list
end; end;
editItem = function(self, index, text, bgCol, fgCol, ...) editItem = function(self, index, text, bgColor, fgColor, ...)
table.remove(list, index) table.remove(list, index)
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, index, { text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
return self return self
end; end;
@@ -2685,9 +2685,9 @@ local function Menubar(name)
return self return self
end; end;
setSelectedItem = function(self, bgCol, fgCol, active) setSelectedItem = function(self, bgColor, fgColor, active)
itemSelectedBG = bgCol or self.bgColor itemSelectedBG = bgColor or self.bgColor
itemSelectedFG = fgCol or self.fgColor itemSelectedFG = fgColor or self.fgColor
selectionColorActive = active selectionColorActive = active
return self return self
end; end;
@@ -2741,17 +2741,17 @@ local function Menubar(name)
for _, value in pairs(list) do for _, value in pairs(list) do
if (xPos + value.text:len() + space * 2 <= self.width) then if (xPos + value.text:len() + space * 2 <= self.width) then
if (value == self:getValue()) then if (value == self:getValue()) then
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), itemSelectedBG or value.bgCol, itemSelectedFG or value.fgCol) self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), itemSelectedBG or value.bgColor, itemSelectedFG or value.fgColor)
else else
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), value.bgCol, value.fgCol) self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), value.bgColor, value.fgColor)
end end
xPos = xPos + value.text:len() + space * 2 xPos = xPos + value.text:len() + space * 2
else else
if (xPos < self.width + itemOffset) then if (xPos < self.width + itemOffset) then
if (value == self:getValue()) then if (value == self:getValue()) then
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), itemSelectedBG or value.bgCol, itemSelectedFG or value.fgCol) self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), itemSelectedBG or value.bgColor, itemSelectedFG or value.fgColor)
else else
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), value.bgCol, value.fgCol) self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), value.bgColor, value.fgColor)
end end
xPos = xPos + value.text:len() + space * 2 xPos = xPos + value.text:len() + space * 2
end end
@@ -2801,8 +2801,8 @@ local function Dropdown(name)
return yOffset return yOffset
end; end;
addItem = function(self, text, bgCol, fgCol, ...) addItem = function(self, text, bgColor, fgColor, ...)
table.insert(list, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, { text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
return self return self
end; end;
@@ -2834,9 +2834,9 @@ local function Dropdown(name)
return #list return #list
end; end;
editItem = function(self, index, text, bgCol, fgCol, ...) editItem = function(self, index, text, bgColor, fgColor, ...)
table.remove(list, index) table.remove(list, index)
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, index, { text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
return self return self
end; end;
@@ -2845,9 +2845,9 @@ local function Dropdown(name)
return self return self
end; end;
setSelectedItem = function(self, bgCol, fgCol, active) setSelectedItem = function(self, bgColor, fgColor, active)
itemSelectedBG = bgCol or self.bgColor itemSelectedBG = bgColor or self.bgColor
itemSelectedFG = fgCol or self.fgColor itemSelectedFG = fgColor or self.fgColor
selectionColorActive = active selectionColorActive = active
return self return self
end; end;
@@ -2923,10 +2923,10 @@ local function Dropdown(name)
if (selectionColorActive) then if (selectionColorActive) then
self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), itemSelectedBG, itemSelectedFG) self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), itemSelectedBG, itemSelectedFG)
else else
self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), list[n + yOffset].bgColor, list[n + yOffset].fgColor)
end end
else else
self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), list[n + yOffset].bgCol, list[n + yOffset].fgCol) self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), list[n + yOffset].bgColor, list[n + yOffset].fgColor)
end end
end end
end end
@@ -2962,8 +2962,8 @@ local function Radio(name)
return objectType return objectType
end; end;
addItem = function(self, text, x, y, bgCol, fgCol, ...) addItem = function(self, text, x, y, bgColor, fgColor, ...)
table.insert(list, { x = x or 1, y = y or 1, text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, { x = x or 1, y = y or 1, text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
if (#list == 1) then if (#list == 1) then
self:setValue(list[1]) self:setValue(list[1])
end end
@@ -2998,9 +2998,9 @@ local function Radio(name)
return #list return #list
end; end;
editItem = function(self, index, text, x, y, bgCol, fgCol, ...) editItem = function(self, index, text, x, y, bgColor, fgColor, ...)
table.remove(list, index) table.remove(list, index)
table.insert(list, index, { x = x or 1, y = y or 1, text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } }) table.insert(list, index, { x = x or 1, y = y or 1, text = text, bgColor = bgColor or self.bgColor, fgColor = fgColor or self.fgColor, args = { ... } })
return self return self
end; end;
@@ -3009,9 +3009,9 @@ local function Radio(name)
return self return self
end; end;
setSelectedItem = function(self, bgCol, fgCol, boxBG, boxFG, active) setSelectedItem = function(self, bgColor, fgColor, boxBG, boxFG, active)
itemSelectedBG = bgCol or itemSelectedBG itemSelectedBG = bgColor or itemSelectedBG
itemSelectedFG = fgCol or itemSelectedFG itemSelectedFG = fgColor or itemSelectedFG
boxSelectedBG = boxBG or boxSelectedBG boxSelectedBG = boxBG or boxSelectedBG
boxSelectedFG = boxFG or boxSelectedFG boxSelectedFG = boxFG or boxSelectedFG
selectionColorActive = active selectionColorActive = active
@@ -3053,7 +3053,7 @@ local function Radio(name)
end end
else else
self.parent:drawBackgroundBox(value.x + obx - 1, value.y + oby - 1, 1, 1, self.bgColor) self.parent:drawBackgroundBox(value.x + obx - 1, value.y + oby - 1, 1, 1, self.bgColor)
self.parent:writeText(value.x + 2 + obx - 1, value.y + oby - 1, value.text, value.bgCol, value.fgCol) self.parent:writeText(value.x + 2 + obx - 1, value.y + oby - 1, value.text, value.bgColor, value.fgColor)
end end
end end
end end
@@ -3734,10 +3734,10 @@ local function Frame(name, parent)
return self return self
end; end;
setBar = function(self, text, bgCol, fgCol) setBar = function(self, text, bgColor, fgColor)
self.barText = text or "" self.barText = text or ""
self.barBackground = bgCol or self.barBackground self.barBackground = bgColor or self.barBackground
self.barTextcolor = fgCol or self.barTextcolor self.barTextcolor = fgColor or self.barTextcolor
self:setVisualChanged() self:setVisualChanged()
return self return self
end; end;
@@ -3875,47 +3875,47 @@ local function Frame(name, parent)
end end
end; end;
setBG = function(self, x, y, bgCol) setBG = function(self, x, y, bgColor)
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
if (y >= 1) and (y <= self.height) then if (y >= 1) and (y <= self.height) then
if (self.parent ~= nil) 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.width - x + 1)) self.parent:setBG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(bgColor, math.max(1 - x + 1, 1), self.width - x + 1))
else else
drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1)) drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgColor, math.max(1 - x + 1, 1), self.width - x + 1))
end end
end end
end; end;
setFG = function(self, x, y, fgCol) setFG = function(self, x, y, fgColor)
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
if (y >= 1) and (y <= self.height) then if (y >= 1) and (y <= self.height) then
if (self.parent ~= nil) 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.width - x + 1)) self.parent:setFG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(fgColor, math.max(1 - x + 1, 1), self.width - x + 1))
else else
drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1)) drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgColor, math.max(1 - x + 1, 1), self.width - x + 1))
end end
end end
end; end;
writeText = function(self, x, y, text, bgCol, fgCol) writeText = function(self, x, y, text, bgColor, fgColor)
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
if (y >= 1) and (y <= self.height) then if (y >= 1) and (y <= self.height) then
if (self.parent ~= nil) 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.width - 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.width - x + 1), bgColor, fgColor)
else else
drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol) drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgColor, fgColor)
end end
end end
end; end;
drawBackgroundBox = function(self, x, y, width, height, bgCol) drawBackgroundBox = function(self, x, y, width, height, _bgColor)
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
if (self.parent ~= nil) then 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), width, height, bgCol) self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, _bgColor)
else else
drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, bgCol) drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, _bgColor)
end end
end; end;
@@ -3930,14 +3930,14 @@ local function Frame(name, parent)
end end
end; end;
drawForegroundBox = function(self, x, y, width, height, fgCol) drawForegroundBox = function(self, x, y, width, height, fgColor)
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height)) height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width)) width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
if (self.parent ~= nil) then 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), width, height, fgCol) self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, fgColor)
else else
drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgCol) drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgColor)
end end
end; end;
@@ -3945,11 +3945,11 @@ local function Frame(name, parent)
if (self:getVisualChanged()) then if (self:getVisualChanged()) then
if (base.draw(self)) then if (base.draw(self)) then
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
local anchx, anchy = self:getAnchorPosition() local anchorX, anchorY = self:getAnchorPosition()
if (self.parent ~= nil) then if (self.parent ~= nil) then
self.parent:drawBackgroundBox(anchx, anchy, self.width, self.height, self.bgColor) self.parent:drawBackgroundBox(anchorX, anchorY, self.width, self.height, self.bgColor)
self.parent:drawForegroundBox(anchx, anchy, self.width, self.height, self.fgColor) self.parent:drawForegroundBox(anchorX, anchorY, self.width, self.height, self.fgColor)
self.parent:drawTextBox(anchx, anchy, self.width, self.height, " ") self.parent:drawTextBox(anchorX, anchorY, self.width, self.height, " ")
else else
drawHelper.drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor) drawHelper.drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
drawHelper.drawForegroundBox(obx, oby, self.width, self.height, self.fgColor) drawHelper.drawForegroundBox(obx, oby, self.width, self.height, self.fgColor)
@@ -3958,7 +3958,7 @@ local function Frame(name, parent)
parentTerminal.setCursorBlink(false) parentTerminal.setCursorBlink(false)
if (self.barActive) then if (self.barActive) then
if (self.parent ~= nil) then if (self.parent ~= nil) then
self.parent:writeText(anchx, anchy, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor) self.parent:writeText(anchorX, anchorY, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor)
else else
drawHelper.writeText(obx, oby, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor) drawHelper.writeText(obx, oby, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor)
end end