This commit is contained in:
Astronand committed 2025-09-30 12:20:47 -04:00
1 parent 1a92ff1bd2
commit 91bf28a728
65 files changed
+2587 -240

No files matched your search

+5 -80
View File
@@ -1,90 +1,13 @@
local screen = {}
function write(sText)
local w, h = term.getSize()
local x, y = term.getCursorPos()
local nLinesPrinted = 0
local function newLine()
if y + 1 <= h then
term.setCursorPos(1, y + 1)
else
term.setCursorPos(1, h)
term.scroll(1)
end
x, y = term.getCursorPos()
nLinesPrinted = nLinesPrinted + 1
end
sText = tostring(sText)
while #sText > 0 do
local whitespace = string.match(sText, "^[ \t]+")
if whitespace then
term.write(whitespace)
x, y = term.getCursorPos()
sText = string.sub(sText, #whitespace + 1)
end
local newline = string.match(sText, "^\n")
if newline then
newLine()
sText = string.sub(sText, 2)
end
local text = string.match(sText, "^[^ \t\n]+")
if text then
sText = string.sub(sText, #text + 1)
if #text > w then
while #text > 0 do
if x > w then
newLine()
end
term.write(text)
text = string.sub(text, w - x + 2)
x, y = term.getCursorPos()
end
else
if x + #text - 1 > w then
newLine()
end
term.write(text)
x, y = term.getCursorPos()
end
end
end
return nLinesPrinted
end
function print(...)
local nLinesPrinted = 0
local nLimit = select("#", ...)
for n = 1, nLimit do
local s = tostring(select(n, ...))
if n < nLimit then
s = s .. "\t"
end
nLinesPrinted = nLinesPrinted + write(s)
end
nLinesPrinted = nLinesPrinted + write("\n")
function screen.printInline(...)
term.write(table.concat({...}, " "))
end
function screen.print(...)
print(...)
end
function printInline(...)
local nLinesPrinted = 0
local nLimit = select("#", ...)
for n = 1, nLimit do
local s = tostring(select(n, ...))
nLinesPrinted = nLinesPrinted + write(s)
end
end
function screen.printInline(...)
printInline(...)
end
function screen.clear()
term.setCursorPos(1,1)
term.clear()
@@ -93,4 +16,6 @@ end
screen.id = "screen_1"
screen.__UDATA_ID = 1
newComponent("screen", screen)
function aceVM.components.screen(id)
aceVM.newComponent("screen", screen)
end