Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
075903f9a9 | ||
|
|
d6931412c8 | ||
|
|
73b43358ff | ||
|
|
df7be99fdd | ||
|
|
6f0ddd6bf6 | ||
|
|
a821abed1f | ||
|
|
50dce1c1e7 | ||
|
|
94fccf9211 | ||
|
|
a4d0492d17 | ||
|
|
5ebb5fe436 |
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user