mirror of
https://github.com/LDDestroier/CC/
synced 2025-07-07 12:32:56 +00:00
Fixed clearLine, weird bug with CPlat
This commit is contained in:
parent
416579ae69
commit
7343dc719d
@ -361,7 +361,6 @@ lddterm.newWindow = function(width, height, x, y, meta)
|
|||||||
text = tostring(text)
|
text = tostring(text)
|
||||||
local cx = math.floor(window.cursor[1])
|
local cx = math.floor(window.cursor[1])
|
||||||
local cy = math.floor(window.cursor[2])
|
local cy = math.floor(window.cursor[2])
|
||||||
text = text:sub(math.max(0, -cx - 1))
|
|
||||||
for i = 1, #text do
|
for i = 1, #text 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
|
||||||
window.buffer[1][cy][cx] = text:sub(i,i)
|
window.buffer[1][cy][cx] = text:sub(i,i)
|
||||||
@ -388,7 +387,6 @@ lddterm.newWindow = function(width, height, x, y, meta)
|
|||||||
assert(char ~= nil, "expected string 'char'")
|
assert(char ~= nil, "expected string 'char'")
|
||||||
local cx = math.floor(window.cursor[1])
|
local cx = math.floor(window.cursor[1])
|
||||||
local cy = math.floor(window.cursor[2])
|
local cy = math.floor(window.cursor[2])
|
||||||
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
|
||||||
window.buffer[1][cy][cx] = char:sub(i,i)
|
window.buffer[1][cy][cx] = char:sub(i,i)
|
||||||
@ -423,16 +421,18 @@ lddterm.newWindow = function(width, height, x, y, meta)
|
|||||||
cy = math.floor(cy or window.cursor[2])
|
cy = math.floor(cy or window.cursor[2])
|
||||||
char = type(char) == "string" and char or " "
|
char = type(char) == "string" and char or " "
|
||||||
local cx = 1
|
local cx = 1
|
||||||
for x = 1, window.width do
|
if window.buffer[1][cy or window.cursor[2]] then
|
||||||
if char then
|
for x = 1, window.width do
|
||||||
cx = (x % #char) + 1
|
if char then
|
||||||
|
cx = (x % #char) + 1
|
||||||
|
end
|
||||||
|
window.buffer[1][cy or window.cursor[2]][x] = char and char:sub(cx, cx) or window.clearChar
|
||||||
|
window.buffer[2][cy or window.cursor[2]][x] = window.colors[1]
|
||||||
|
window.buffer[3][cy or window.cursor[2]][x] = window.colors[2]
|
||||||
|
end
|
||||||
|
if lddterm.alwaysRender then
|
||||||
|
lddterm.render(lddterm.transformation, lddterm.drawFunction)
|
||||||
end
|
end
|
||||||
window.buffer[1][cy or window.cursor[2]][x] = char and char:sub(cx, cx) or window.clearChar
|
|
||||||
window.buffer[2][cy or window.cursor[2]][x] = window.colors[1]
|
|
||||||
window.buffer[3][cy or window.cursor[2]][x] = window.colors[2]
|
|
||||||
end
|
|
||||||
if lddterm.alwaysRender then
|
|
||||||
lddterm.render(lddterm.transformation, lddterm.drawFunction)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
window.handle.getSize = function()
|
window.handle.getSize = function()
|
||||||
@ -974,11 +974,7 @@ local main = function()
|
|||||||
end
|
end
|
||||||
os.queueEvent = function(evt, ...)
|
os.queueEvent = function(evt, ...)
|
||||||
if type(evt) == "string" then
|
if type(evt) == "string" then
|
||||||
if instances[y][x].paused then
|
instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...}
|
||||||
instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...}
|
|
||||||
else
|
|
||||||
oldFuncReplace.os.queueEvent(evt, ...)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
error("bad argument #1 (number expected, got " .. type(evt) .. ")", 2)
|
error("bad argument #1 (number expected, got " .. type(evt) .. ")", 2)
|
||||||
end
|
end
|
||||||
@ -992,6 +988,21 @@ local main = function()
|
|||||||
local banTimerEvent, evt
|
local banTimerEvent, evt
|
||||||
local doRedraw = false
|
local doRedraw = false
|
||||||
|
|
||||||
|
local checkIfExtraEvents = function()
|
||||||
|
for y = gridMinY, gridHeight do
|
||||||
|
if instances[y] then
|
||||||
|
for x = gridMinX, gridWidth do
|
||||||
|
if instances[y][x] then
|
||||||
|
if #instances[y][x].extraEvents ~= 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
while isRunning do
|
while isRunning do
|
||||||
gridWidth, gridHeight, gridMinX, gridMinY = getMapSize()
|
gridWidth, gridHeight, gridMinX, gridMinY = getMapSize()
|
||||||
doRedraw = false
|
doRedraw = false
|
||||||
@ -1008,6 +1019,7 @@ local main = function()
|
|||||||
enteringCommand = true
|
enteringCommand = true
|
||||||
doDrawWorkspaceIndicator = false
|
doDrawWorkspaceIndicator = false
|
||||||
banTimerEvent = true
|
banTimerEvent = true
|
||||||
|
doRedraw = true
|
||||||
else
|
else
|
||||||
if evt[2] == tID then
|
if evt[2] == tID then
|
||||||
doRedraw = true
|
doRedraw = true
|
||||||
@ -1198,20 +1210,17 @@ local main = function()
|
|||||||
for x = gridMinX, gridWidth do
|
for x = gridMinX, gridWidth do
|
||||||
if instances[y][x] then
|
if instances[y][x] then
|
||||||
|
|
||||||
|
setInstanceSpecificFunctions(x, y)
|
||||||
|
previousTerm = term.redirect(instances[y][x].window.handle)
|
||||||
|
|
||||||
if justStarted or (checkIfCanRun(evt, x, y) and not (banTimerEvent and evt[1] == "timer")) then
|
if justStarted or (checkIfCanRun(evt, x, y) and not (banTimerEvent and evt[1] == "timer")) then
|
||||||
previousTerm = term.redirect(instances[y][x].window.handle)
|
|
||||||
setInstanceSpecificFunctions(x, y)
|
|
||||||
cSuccess, instances[y][x].eventFilter = coroutine.resume(instances[y][x].co, table.unpack(evt))
|
cSuccess, instances[y][x].eventFilter = coroutine.resume(instances[y][x].co, table.unpack(evt))
|
||||||
term.redirect(previousTerm)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if #instances[y][x].extraEvents ~= 0 then
|
if #instances[y][x].extraEvents ~= 0 and not instances[y][x].paused then
|
||||||
for i = 1, #instances[y][x].extraEvents do
|
for i = 1, #instances[y][x].extraEvents do
|
||||||
if checkIfCanRun(instances[y][x].extraEvents[i], x, y) then
|
if checkIfCanRun(instances[y][x].extraEvents[i], x, y) then
|
||||||
previousTerm = term.redirect(instances[y][x].window.handle)
|
|
||||||
setInstanceSpecificFunctions(x, y)
|
|
||||||
cSuccess, instances[y][x].eventFilter = coroutine.resume(instances[y][x].co, table.unpack(instances[y][x].extraEvents[i]))
|
cSuccess, instances[y][x].eventFilter = coroutine.resume(instances[y][x].co, table.unpack(instances[y][x].extraEvents[i]))
|
||||||
term.redirect(previousTerm)
|
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -1219,6 +1228,8 @@ local main = function()
|
|||||||
instances[y][x].extraEvents = {}
|
instances[y][x].extraEvents = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
term.redirect(previousTerm)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user