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,
mouseHandler = function(self, button, x, y, _, side)
mouseHandler = function(self, button, x, y, touch, side)
if(isGroupedMonitor)then
if(termObject.calculateClick~=nil)then
x, y = termObject.calculateClick(side, x, y)
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
self:setCursor(false)
for _, index in ipairs(eventZIndex["mouse_click"]) do
if (events["mouse_click"][index] ~= nil) then
for _, value in rpairs(events["mouse_click"][index]) do
if (value.mouseHandler ~= nil) then
if (value:mouseHandler(button, x, y)) then
if (value:mouseHandler(button, x, y, touch)) then
return true
end

View File

@@ -135,10 +135,10 @@ return function(name)
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("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("borderTop", data)~=nil)then borderColors["top"] = xmlValue("borderTop", data) end
if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = xmlValue("borderRight", data) end
if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = xmlValue("borderBottom", data) end
if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = colors[xmlValue("borderLeft", data)] end
if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = colors[xmlValue("borderTop", data)] end
if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = colors[xmlValue("borderRight", 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("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

View File

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

View File

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

View File

@@ -124,7 +124,7 @@ return function(name)
return dropdownW, dropdownH
end,
mouseHandler = function(self, button, x, y)
mouseHandler = function(self, button, x, y, touch)
if (isOpened) then
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
if(button==1)then
@@ -135,6 +135,9 @@ return function(name)
self:setValue(list[n + yOffset])
self:updateDraw()
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
return true
end

View File

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

View File

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