10 Commits

Author SHA1 Message Date
Robert Jelic
075903f9a9 Small 1.6 fixes
- added basalt.forceRenderUpdate
- fixed dropdowns behaving wrong on monitors
2023-04-29 23:14:19 +02:00
Robert Jelic
d6931412c8 Updated textfield
- fixed paste-events by removing an outdated if-statement
2023-04-17 17:42:11 +02:00
Robert Jelic
73b43358ff Small palette fix 2023-03-11 20:10:06 +01:00
Robert Jelic
df7be99fdd Merge branch 'master' of https://github.com/Pyroxenium/Basalt 2023-02-20 16:28:24 +01:00
Robert Jelic
6f0ddd6bf6 Small fix
Small XML borderColor fix
2023-02-20 16:28:22 +01:00
Robert Jelic
a821abed1f Update Textfield.lua
- Removed buggy selection
- Fixed a small bug
2023-02-17 20:40:49 +01:00
Robert Jelic
50dce1c1e7 added :setSelectionColor()
added :setSelectionColor(backgroundCol, foregroundCol)
2023-01-23 21:52:20 +01:00
Robert Jelic
94fccf9211 Update process.lua 2023-01-08 10:04:00 +01:00
Robert Jelic
a4d0492d17 Update Program.lua 2023-01-08 10:03:39 +01:00
Robert Jelic
5ebb5fe436 Update Program.lua
Fixed args for programs
2023-01-08 10:02:50 +01:00
7 changed files with 46 additions and 34 deletions

View File

@@ -885,20 +885,20 @@ return function(name, parent, pTerm, basalt)
end end
end, end,
mouseHandler = function(self, button, x, y, _, side) mouseHandler = function(self, button, x, y, touch, side)
if(isGroupedMonitor)then if(isGroupedMonitor)then
if(termObject.calculateClick~=nil)then if(termObject.calculateClick~=nil)then
x, y = termObject.calculateClick(side, x, y) x, y = termObject.calculateClick(side, x, y)
end end
end end
if(base.mouseHandler(self, button, x, y))then if(base.mouseHandler(self, button, x, y, touch))then
if(events["mouse_click"]~=nil)then if(events["mouse_click"]~=nil)then
self:setCursor(false) self:setCursor(false)
for _, index in ipairs(eventZIndex["mouse_click"]) do for _, index in ipairs(eventZIndex["mouse_click"]) do
if (events["mouse_click"][index] ~= nil) then if (events["mouse_click"][index] ~= nil) then
for _, value in rpairs(events["mouse_click"][index]) do for _, value in rpairs(events["mouse_click"][index]) do
if (value.mouseHandler ~= nil) then if (value.mouseHandler ~= nil) then
if (value:mouseHandler(button, x, y)) then if (value:mouseHandler(button, x, y, touch)) then
return true return true
end end

View File

@@ -135,10 +135,10 @@ return function(name)
if(xmlValue("anchor", data)~=nil)then self:setAnchor(xmlValue("anchor", data)) end if(xmlValue("anchor", data)~=nil)then self:setAnchor(xmlValue("anchor", data)) end
if(xmlValue("shadowColor", data)~=nil)then self:setShadow(colors[xmlValue("shadowColor", data)]) end if(xmlValue("shadowColor", data)~=nil)then self:setShadow(colors[xmlValue("shadowColor", data)]) end
if(xmlValue("border", data)~=nil)then self:setBorder(colors[xmlValue("border", data)]) end if(xmlValue("border", data)~=nil)then self:setBorder(colors[xmlValue("border", data)]) end
if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = xmlValue("borderLeft", data) end if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = colors[xmlValue("borderLeft", data)] end
if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = xmlValue("borderTop", data) end if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = colors[xmlValue("borderTop", data)] end
if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = xmlValue("borderRight", data) end if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = colors[xmlValue("borderRight", data)] end
if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = xmlValue("borderBottom", data) end if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = colors[xmlValue("borderBottom", data)] end
if(xmlValue("borderColor", data)~=nil)then self:setBorder(colors[xmlValue("borderColor", data)]) end if(xmlValue("borderColor", data)~=nil)then self:setBorder(colors[xmlValue("borderColor", data)]) end
if(xmlValue("ignoreOffset", data)~=nil)then if(xmlValue("ignoreOffset", data))then self:ignoreOffset(true) end end if(xmlValue("ignoreOffset", data)~=nil)then if(xmlValue("ignoreOffset", data))then self:ignoreOffset(true) end end
if(xmlValue("onClick", data)~=nil)then self:generateXMLEventFunction(self.onClick, xmlValue("onClick", data)) end if(xmlValue("onClick", data)~=nil)then self:generateXMLEventFunction(self.onClick, xmlValue("onClick", data)) end

View File

@@ -17,7 +17,6 @@ function process:new(path, window, newEnv, ...)
local env = setmetatable(newEnv, {__index=_ENV}) local env = setmetatable(newEnv, {__index=_ENV})
env.shell = shell env.shell = shell
env.basaltProgram=true env.basaltProgram=true
env.arg = {[0]=path, table.unpack(args)}
env.require, env.package = newPackage(env, fs.getDir(pPath)) env.require, env.package = newPackage(env, fs.getDir(pPath))
if(fs.exists(pPath))then if(fs.exists(pPath))then
local file = fs.open(pPath, "r") local file = fs.open(pPath, "r")
@@ -25,7 +24,7 @@ function process:new(path, window, newEnv, ...)
file.close() file.close()
local program = load(content, path, "bt", env) local program = load(content, path, "bt", env)
if(program~=nil)then if(program~=nil)then
return program() return program(table.unpack(args))
end end
end end
end) end)
@@ -82,4 +81,4 @@ function process:start()
coroutine.resume(self.coroutine) coroutine.resume(self.coroutine)
end end
return process return process

View File

@@ -436,6 +436,10 @@ basalt = {
projectDirectory = dir projectDirectory = dir
end, end,
forceRenderUpdate = function()
drawFrames()
end,
debug = function(...) debug = function(...)
local args = { ... } local args = { ... }
if(mainFrame==nil)then print(...) return end if(mainFrame==nil)then print(...) return end

View File

@@ -124,7 +124,7 @@ return function(name)
return dropdownW, dropdownH return dropdownW, dropdownH
end, end,
mouseHandler = function(self, button, x, y) mouseHandler = function(self, button, x, y, touch)
if (isOpened) then if (isOpened) then
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition()) local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
if(button==1)then if(button==1)then
@@ -135,6 +135,9 @@ return function(name)
self:setValue(list[n + yOffset]) self:setValue(list[n + yOffset])
self:updateDraw() self:updateDraw()
local val = self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", dir, x, y) local val = self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", dir, x, y)
if(touch)then
self:mouseUpHandler(button, x, y)
end
if(val==false)then return val end if(val==false)then return val end
return true return true
end end

View File

@@ -23,17 +23,17 @@ return function(name)
local p = {} local p = {}
for k,v in pairs(colors)do for k,v in pairs(colors)do
if(type(v)=="number")then if(type(v)=="number")then
p[k] = {term.nativePaletteColor(v)} p[v] = {term.nativePaletteColor(v)}
end end
end end
if(originalImage.palette~=nil)then if(originalImage.palette~=nil)then
for k,v in pairs(originalImage.palette)do for k,v in pairs(originalImage.palette)do
p[k] = tonumber(v) p[2^k] = v
end end
end end
if(originalImage[id]~=nil)and(originalImage[id].palette~=nil)then if(originalImage[id]~=nil)and(originalImage[id].palette~=nil)then
for k,v in pairs(originalImage[id].palette)do for k,v in pairs(originalImage[id].palette)do
p[k] = tonumber(v) p[2^k] = v
end end
end end
return p return p

View File

@@ -10,7 +10,7 @@ return function(name)
local objectType = "Textfield" local objectType = "Textfield"
local hIndex, wIndex, textX, textY = 1, 1, 1, 1 local hIndex, wIndex, textX, textY = 1, 1, 1, 1
local lines = { " " } local lines = { "" }
local bgLines = { "" } local bgLines = { "" }
local fgLines = { "" } local fgLines = { "" }
local keyWords = { } local keyWords = { }
@@ -216,7 +216,7 @@ return function(name)
end; end;
clear = function(self) clear = function(self)
lines = {" "} lines = {""}
bgLines = {""} bgLines = {""}
fgLines = {""} fgLines = {""}
startSelX,endSelX,startSelY,endSelY = nil,nil,nil,nil startSelX,endSelX,startSelY,endSelY = nil,nil,nil,nil
@@ -299,7 +299,7 @@ return function(name)
table.remove(bgLines, index or #bgLines) table.remove(bgLines, index or #bgLines)
table.remove(fgLines, index or #fgLines) table.remove(fgLines, index or #fgLines)
else else
lines = {" "} lines = {""}
bgLines = {""} bgLines = {""}
fgLines = {""} fgLines = {""}
end end
@@ -666,25 +666,30 @@ return function(name)
end, end,
eventHandler = function(self, event, paste, p2, p3, p4) eventHandler = function(self, event, paste, p2, p3, p4)
if(base.eventHandler(self, event, paste, p2, p3, p4))then base.eventHandler(self, event, paste, p2, p3, p4)
if(event=="paste")then if(event=="paste")then
if(self:isFocused())then if(self:isFocused())then
local w, h = self:getSize() local w, h = self:getSize()
lines[textY] = lines[textY]:sub(1, textX - 1) .. paste .. lines[textY]:sub(textX, lines[textY]:len()) lines[textY] = lines[textY]:sub(1, textX - 1) .. paste .. lines[textY]:sub(textX, lines[textY]:len())
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. tHex[self.fgColor]:rep(paste:len()) .. fgLines[textY]:sub(textX, fgLines[textY]:len()) fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. tHex[self.fgColor]:rep(paste:len()) .. fgLines[textY]:sub(textX, fgLines[textY]:len())
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. tHex[self.bgColor]:rep(paste:len()) .. bgLines[textY]:sub(textX, bgLines[textY]:len()) bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. tHex[self.bgColor]:rep(paste:len()) .. bgLines[textY]:sub(textX, bgLines[textY]:len())
textX = textX + paste:len() textX = textX + paste:len()
if (textX >= w + wIndex) then if (textX >= w + wIndex) then
wIndex = (textX+1)-w wIndex = (textX+1)-w
end
local anchx, anchy = self:getAnchorPosition()
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
updateColors(self)
self:updateDraw()
end end
local anchx, anchy = self:getAnchorPosition()
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
updateColors(self)
self:updateDraw()
end end
end end
end, end,
setSelectionColor = function(self, bg, fg)
selectionBG = bg or selectionBG
selectionFG = fg or selectionFG
return self
end,
draw = function(self) draw = function(self)
if (base.draw(self)) then if (base.draw(self)) then
@@ -714,6 +719,7 @@ return function(name)
self.parent:setBG(obx, oby + n - 1, bg) self.parent:setBG(obx, oby + n - 1, bg)
self.parent:setFG(obx, oby + n - 1, fg) self.parent:setFG(obx, oby + n - 1, fg)
end end
--[[
if(startSelX~=nil)and(endSelX~=nil)and(startSelY~=nil)and(endSelY~=nil)then if(startSelX~=nil)and(endSelX~=nil)and(startSelY~=nil)and(endSelY~=nil)then
local sx,ex,sy,ey = getSelectionCoordinates(self) local sx,ex,sy,ey = getSelectionCoordinates(self)
for n=sy,ey do for n=sy,ey do
@@ -731,7 +737,7 @@ return function(name)
self.parent:setBG(obx + xOffset, oby + n - 1, rep(tHex[selectionBG], line)) self.parent:setBG(obx + xOffset, oby + n - 1, rep(tHex[selectionBG], line))
self.parent:setFG(obx + xOffset, oby + n - 1, rep(tHex[selectionFG], line)) self.parent:setFG(obx + xOffset, oby + n - 1, rep(tHex[selectionFG], line))
end end
end end]]
if(self:isFocused())then if(self:isFocused())then
local anchx, anchy = self:getAnchorPosition() local anchx, anchy = self:getAnchorPosition()
--self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor) --self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
@@ -756,4 +762,4 @@ return function(name)
} }
return setmetatable(object, base) return setmetatable(object, base)
end end