os.loadAPI(shell.getRunningProgram().."/../config")
local monitor = peripheral.wrap(config.monitor)
local lastBgColor = colors.black
function getCursorPos()
return term.native.getCursorPos()
end
function getSize()
return term.native.getSize()
end
function scroll(qtn)
monitor.scroll(qtn)
term.native.scroll(qtn)
end
function clear()
local x, y = getCursorPos()
setCursorPos(1, 1)
local _, h = getSize()
for i = 1, h + 1 do
clearLine()
setCursorPos(1, i)
end
setCursorPos(x, y)
term.native.clear()
end
function clearLine()
local x, y = getCursorPos()
setCursorPos(1, y)
local w = getSize()
for i = 1, w do
monitor.write(" ")
end
setCursorPos(x, y)
term.native.clearLine()
end
function write(text)
local w = getSize()
local x, y = getCursorPos()
rtext = string.sub(text, 1, w - x + 1)
if x < 1 then
monitor.setCursorPos(1 + 2, y + 2)
rtext = string.sub(rtext, 2 - x, #rtext)
end
monitor.write(rtext)
term.native.write(text)
end
function setCursorPos(x, y)
local w, h = getSize()
local mx, my = x, y
if y < 1 or y > h then
my = h + 3
end
monitor.setCursorPos(mx + 2, my + 2)
term.native.setCursorPos(x, y)
end
function setCursorBlink(blink)
monitor.setCursorBlink(blink)
term.native.setCursorBlink(blink)
end
function isColor()
return monitor.isColor()
end
function setTextColor(color)
monitor.setTextColor(color)
term.native.setTextColor(color)
end
function setBackgroundColor(color)
monitor.setBackgroundColor(color)
term.native.setBackgroundColor(color)
lastBgColor = color
end
local redirect = {
getCursorPos = getCursorPos;
getSize = getSize;
scroll = scroll;
clear = clear;
clearLine = clearLine;
write = write;
setCursorPos = setCursorPos;
setCursorBlink = setCursorBlink;
isColor = isColor;
isColour = isColor;
setTextColor = setTextColor;
setBackgroundColor = setBackgroundColor;
setTextColour = setTextColor;
setBackgroundColour = setBackgroundColor;
}
monitor.setTextScale(1.5)
local width, height = monitor.getSize()
monitor.setTextColor(colors.white)
monitor.setBackgroundColor(colors.black)
monitor.clear()
monitor.setCursorPos(width/2 - #config.title/2 + #config.title%2, 1)
monitor.setBackgroundColor(colors.green)
monitor.clearLine()
monitor.write(config.title)
monitor.setCursorPos(width/2 - #config.subtitle/2 + #config.subtitle%2, 2)
monitor.clearLine()
monitor.write(config.subtitle)
local y = 3
while y < height do
monitor.setCursorPos(1, y)
monitor.write(" ")
monitor.setCursorPos(width - 1, y)
monitor.write(" ")
y = y + 1
end
monitor.setCursorPos(1, height)
monitor.clearLine()
redirect.setCursorPos(1, 1)
redirect.setBackgroundColor(colors.black)
shell.setDir("")
redirect.clear()
redirect.setCursorPos(1, 1)
redirect.setTextColor(colors.yellow)
redirect.write("CraftOS 1.5")
redirect.setCursorPos(1, 2)
redirect.setTextColor(colors.white)
term.redirect(redirect)
os.unloadAPI("config")