mirror of
https://github.com/LDDestroier/CC/
synced 2025-07-07 04:22:55 +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)
|
||||
local cx = math.floor(window.cursor[1])
|
||||
local cy = math.floor(window.cursor[2])
|
||||
text = text:sub(math.max(0, -cx - 1))
|
||||
for i = 1, #text do
|
||||
if cx >= 1 and cx <= window.width and cy >= 1 and cy <= window.height then
|
||||
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'")
|
||||
local cx = math.floor(window.cursor[1])
|
||||
local cy = math.floor(window.cursor[2])
|
||||
char = char:sub(math.max(0, -cx - 1))
|
||||
for i = 1, #char do
|
||||
if cx >= 1 and cx <= window.width and cy >= 1 and cy <= window.height then
|
||||
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])
|
||||
char = type(char) == "string" and char or " "
|
||||
local cx = 1
|
||||
for x = 1, window.width do
|
||||
if char then
|
||||
cx = (x % #char) + 1
|
||||
if window.buffer[1][cy or window.cursor[2]] then
|
||||
for x = 1, window.width do
|
||||
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
|
||||
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.handle.getSize = function()
|
||||
@ -974,11 +974,7 @@ local main = function()
|
||||
end
|
||||
os.queueEvent = function(evt, ...)
|
||||
if type(evt) == "string" then
|
||||
if instances[y][x].paused then
|
||||
instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...}
|
||||
else
|
||||
oldFuncReplace.os.queueEvent(evt, ...)
|
||||
end
|
||||
instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...}
|
||||
else
|
||||
error("bad argument #1 (number expected, got " .. type(evt) .. ")", 2)
|
||||
end
|
||||
@ -992,6 +988,21 @@ local main = function()
|
||||
local banTimerEvent, evt
|
||||
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
|
||||
gridWidth, gridHeight, gridMinX, gridMinY = getMapSize()
|
||||
doRedraw = false
|
||||
@ -1008,6 +1019,7 @@ local main = function()
|
||||
enteringCommand = true
|
||||
doDrawWorkspaceIndicator = false
|
||||
banTimerEvent = true
|
||||
doRedraw = true
|
||||
else
|
||||
if evt[2] == tID then
|
||||
doRedraw = true
|
||||
@ -1198,20 +1210,17 @@ local main = function()
|
||||
for x = gridMinX, gridWidth do
|
||||
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
|
||||
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))
|
||||
term.redirect(previousTerm)
|
||||
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
|
||||
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]))
|
||||
term.redirect(previousTerm)
|
||||
else
|
||||
break
|
||||
end
|
||||
@ -1219,6 +1228,8 @@ local main = function()
|
||||
instances[y][x].extraEvents = {}
|
||||
end
|
||||
|
||||
term.redirect(previousTerm)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user