mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 20:20:30 +00:00
Don't unnecessarily scroll in edit run wrapper (#1195)
This commit is contained in:
parent
1a87175ae7
commit
f5b89982de
@ -55,19 +55,22 @@ term.redirect(current)
|
|||||||
term.setTextColor(term.isColour() and colours.yellow or colours.white)
|
term.setTextColor(term.isColour() and colours.yellow or colours.white)
|
||||||
term.setBackgroundColor(colours.black)
|
term.setBackgroundColor(colours.black)
|
||||||
term.setCursorBlink(false)
|
term.setCursorBlink(false)
|
||||||
local _, y = term.getCursorPos()
|
|
||||||
local _, h = term.getSize()
|
|
||||||
if not ok then
|
if not ok then
|
||||||
printError(err)
|
printError(err)
|
||||||
end
|
end
|
||||||
if ok and y >= h then
|
|
||||||
term.scroll(1)
|
local message = "Press any key to continue."
|
||||||
|
if ok then message = "Program finished. " .. message end
|
||||||
|
local _, y = term.getCursorPos()
|
||||||
|
local w, h = term.getSize()
|
||||||
|
local wrapped = require("cc.strings").wrap(message, w)
|
||||||
|
|
||||||
|
local start_y = h - #wrapped + 1
|
||||||
|
if y >= start_y then term.scroll(y - start_y + 1) end
|
||||||
|
for i = 1, #wrapped do
|
||||||
|
term.setCursorPos(1, start_y + i - 1)
|
||||||
|
term.write(wrapped[i])
|
||||||
end
|
end
|
||||||
term.setCursorPos(1, h)
|
|
||||||
if ok then
|
|
||||||
write("Program finished. ")
|
|
||||||
end
|
|
||||||
write("Press any key to continue")
|
|
||||||
os.pullEvent('key')
|
os.pullEvent('key')
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user