mirror of
https://github.com/LDDestroier/CC/
synced 2025-07-06 20:12:54 +00:00
Fixed stack overflow using windon't as baseTerm
This commit is contained in:
parent
7aa402b33e
commit
5cf8037599
31
windont.lua
31
windont.lua
@ -22,7 +22,7 @@ local windont = {
|
|||||||
config = {
|
config = {
|
||||||
defaultTextColor = "0", -- default text color (what " " corresponds to in term.blit's second argument)
|
defaultTextColor = "0", -- default text color (what " " corresponds to in term.blit's second argument)
|
||||||
defaultBackColor = "f", -- default background color (what " " corresponds to in term.blit's third argument)
|
defaultBackColor = "f", -- default background color (what " " corresponds to in term.blit's third argument)
|
||||||
clearScreen = false, -- if true, will clear the screen during render
|
clearScreen = true, -- if true, will clear the screen during render
|
||||||
},
|
},
|
||||||
info = {
|
info = {
|
||||||
BLIT_CALLS = 0, -- amount of term.blit calls during the last render
|
BLIT_CALLS = 0, -- amount of term.blit calls during the last render
|
||||||
@ -71,6 +71,10 @@ windont.render = function(...)
|
|||||||
baseTerms[windows[i].meta.baseTerm][i] = true
|
baseTerms[windows[i].meta.baseTerm][i] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if bT == output then
|
||||||
|
bT = output.meta.baseTerm
|
||||||
|
end
|
||||||
|
|
||||||
for bT, bT_list in pairs(baseTerms) do
|
for bT, bT_list in pairs(baseTerms) do
|
||||||
scr_x, scr_y = bT.getSize()
|
scr_x, scr_y = bT.getSize()
|
||||||
for y = 1, scr_y do
|
for y = 1, scr_y do
|
||||||
@ -199,7 +203,7 @@ windont.newWindow = function( x, y, width, height, misc )
|
|||||||
|
|
||||||
blink = true, -- cursor blink
|
blink = true, -- cursor blink
|
||||||
isColor = term.isColor(), -- if true, then it's an advanced computer
|
isColor = term.isColor(), -- if true, then it's an advanced computer
|
||||||
alwaysRender = false, -- render after every terminal operation
|
alwaysRender = true, -- render after every terminal operation
|
||||||
visible = true, -- if false, don't render ever
|
visible = true, -- if false, don't render ever
|
||||||
|
|
||||||
-- make a new buffer (optionally uses an existing buffer as a reference)
|
-- make a new buffer (optionally uses an existing buffer as a reference)
|
||||||
@ -240,9 +244,9 @@ windont.newWindow = function( x, y, width, height, misc )
|
|||||||
--local limit = math.max(0, meta.width - meta.cursorX + 1)
|
--local limit = math.max(0, meta.width - meta.cursorX + 1)
|
||||||
bT.setCursorPos(meta.x, meta.y + meta.cursorY - 1)
|
bT.setCursorPos(meta.x, meta.y + meta.cursorY - 1)
|
||||||
bT.blit(
|
bT.blit(
|
||||||
table.unpack(meta.buffer[1][meta.cursorY]),
|
table.concat(meta.buffer[1][meta.cursorY]),
|
||||||
table.unpack(meta.buffer[2][meta.cursorY]),
|
table.concat(meta.buffer[2][meta.cursorY]),
|
||||||
table.unpack(meta.buffer[3][meta.cursorY])
|
table.concat(meta.buffer[3][meta.cursorY])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -262,9 +266,9 @@ windont.newWindow = function( x, y, width, height, misc )
|
|||||||
--local limit = math.max(0, meta.width - meta.cursorX + 1)
|
--local limit = math.max(0, meta.width - meta.cursorX + 1)
|
||||||
bT.setCursorPos(meta.x, meta.y + meta.cursorY - 1)
|
bT.setCursorPos(meta.x, meta.y + meta.cursorY - 1)
|
||||||
bT.blit(
|
bT.blit(
|
||||||
table.unpack(meta.buffer[1][meta.cursorY]),
|
table.concat(meta.buffer[1][meta.cursorY]),
|
||||||
table.unpack(meta.buffer[2][meta.cursorY]),
|
table.concat(meta.buffer[2][meta.cursorY]),
|
||||||
table.unpack(meta.buffer[3][meta.cursorY])
|
table.concat(meta.buffer[3][meta.cursorY])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -274,6 +278,9 @@ windont.newWindow = function( x, y, width, height, misc )
|
|||||||
assert(type(y) == "number", "argument #2 must be number, got " .. type(y))
|
assert(type(y) == "number", "argument #2 must be number, got " .. type(y))
|
||||||
meta.cursorX, meta.cursorY = x, y
|
meta.cursorX, meta.cursorY = x, y
|
||||||
if meta.alwaysRender then
|
if meta.alwaysRender then
|
||||||
|
if bT == output then
|
||||||
|
bT = output.meta.baseTerm
|
||||||
|
end
|
||||||
bT.setCursorPos(meta.x + meta.cursorX - 1, meta.y + meta.cursorY - 1)
|
bT.setCursorPos(meta.x + meta.cursorX - 1, meta.y + meta.cursorY - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -317,6 +324,9 @@ windont.newWindow = function( x, y, width, height, misc )
|
|||||||
|
|
||||||
output.clear = function()
|
output.clear = function()
|
||||||
meta.buffer = meta.newBuffer(meta.width, meta.height, " ", meta.textColor, meta.backColor)
|
meta.buffer = meta.newBuffer(meta.width, meta.height, " ", meta.textColor, meta.backColor)
|
||||||
|
if meta.alwaysRender then
|
||||||
|
output.redraw()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
output.clearLine = function()
|
output.clearLine = function()
|
||||||
@ -385,7 +395,10 @@ windont.newWindow = function( x, y, width, height, misc )
|
|||||||
end
|
end
|
||||||
|
|
||||||
output.restoreCursor = function()
|
output.restoreCursor = function()
|
||||||
bT.setCursorPos(meta.x + meta.cursorX - 1, meta.y + meta.cursorY - 1)
|
bT.setCursorPos(
|
||||||
|
math.max(0, meta.x + meta.cursorX - 1),
|
||||||
|
math.max(0, meta.y + meta.cursorY - 1)
|
||||||
|
)
|
||||||
bT.setCursorBlink(meta.blink)
|
bT.setCursorBlink(meta.blink)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user