1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-02-09 07:30:02 +00:00

Fixed term.blit bug

This commit is contained in:
LDDestroier 2019-06-23 15:43:08 -04:00 committed by GitHub
parent cfb18f9dcc
commit 55a0d33f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -427,7 +427,7 @@ lddterm.newWindow = function(width, height, x, y, meta)
lddterm.render(lddterm.transformation, lddterm.drawFunction) lddterm.render(lddterm.transformation, lddterm.drawFunction)
end end
end end
window.handle.blit = function(char, textCol, backCol, x, y) window.handle.blit = function(char, textCol, backCol)
if type(char) == "number" then if type(char) == "number" then
char = tostring(char) char = tostring(char)
end end
@ -438,8 +438,8 @@ lddterm.newWindow = function(width, height, x, y, meta)
backCol = tostring(backCol) backCol = tostring(backCol)
end end
assert(char ~= nil, "expected string 'char'") assert(char ~= nil, "expected string 'char'")
local cx = math.floor(tonumber(x) or window.cursor[1]) local cx = math.floor(window.cursor[1])
local cy = math.floor(tonumber(y) or window.cursor[2]) local cy = math.floor(window.cursor[2])
char = char:sub(math.max(0, -cx - 1)) char = char:sub(math.max(0, -cx - 1))
for i = 1, #char do for i = 1, #char do
if cx >= 1 and cx <= window.width and cy >= 1 and cy <= window.height then if cx >= 1 and cx <= window.width and cy >= 1 and cy <= window.height then
@ -454,7 +454,7 @@ lddterm.newWindow = function(width, height, x, y, meta)
lddterm.render(lddterm.transformation, lddterm.drawFunction) lddterm.render(lddterm.transformation, lddterm.drawFunction)
end end
end end
window.handle.print = function(text, x, y) window.handle.print = function(text)
text = text and tostring(text) text = text and tostring(text)
window.handle.write(text, x, y, true) window.handle.write(text, x, y, true)
window.cursor[1] = 1 window.cursor[1] = 1
@ -691,7 +691,7 @@ local newInstance = function(x, y, program, initialStart)
instance.paused = false instance.paused = false
term.setCursorBlink(false) term.setCursorBlink(false)
if not instance.program or type(instance.program) == "string" then if not instance.program or type(instance.program) == "string" then
pcall(load(function() shell.run(instance.program) end, nil, nil, instance.env)) setfenv(function() pcall(shell.run, instance.program) end, instance.env)()
elseif type(instance.program) == "function" then elseif type(instance.program) == "function" then
pcall(function() load(instance.program, nil, nil, instance.env) end) pcall(function() load(instance.program, nil, nil, instance.env) end)
end end
@ -1048,9 +1048,6 @@ local main = function()
error("bad argument #1 (number expected, got " .. type(evt) .. ")", 2) error("bad argument #1 (number expected, got " .. type(evt) .. ")", 2)
end end
end end
-- term.native = function()
-- return instances[y][x].window.handle
-- end
end end
-- timer for instance timers and window scrolling -- timer for instance timers and window scrolling
@ -1247,7 +1244,6 @@ local main = function()
oldFuncReplace.os.time = os.time oldFuncReplace.os.time = os.time
end end
oldFuncReplace.os.queueEvent = os.queueEvent oldFuncReplace.os.queueEvent = os.queueEvent
-- term.native = oldFuncReplace.term.native
for y = gridMinY, gridHeight do for y = gridMinY, gridHeight do
if instances[y] then if instances[y] then
@ -1287,7 +1283,6 @@ local main = function()
os.time = oldFuncReplace.os.time os.time = oldFuncReplace.os.time
end end
os.queueEvent = oldFuncReplace.os.queueEvent os.queueEvent = oldFuncReplace.os.queueEvent
-- term.native = oldFuncReplace.term.termNative
end end