Posted 15 December 2013 - 11:53 PM
I'm trying to redirect the terminal screen so that I can get it to display on the computer and a monitor at the same time, I got it working but there's one problem. My monitor is 8x5 blocks and it's designed to have a two-thick green border except at the bottom where it is one-thick. I'm trying not to get any characters to write on the border, and I managed to do so although… Special characters keep getting drawn on the right side of the monitor even though they shouldn't when I scroll to the left in the program "edit". Is there anything I can do to fix it?
This is the file name config:Edit: The only way I found is to redraw the pixel after writing to the screen, although this could cause screen flicker.
Edit 2: It only happens with magic characters and punctuation
Before:[attachment=1415:2013-12-16_05.00.01.png]
After:[attachment=1416:2013-12-16_05.01.09.png]
Thanks for the help, Ajt86
This is the file name config:
monitor = "monitor_4"
title = "Projection"
subtitle = "Projection of Computer"..os.getComputerID()
This is the main program file (the one you run):Spoiler
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")
Edit 2: It only happens with magic characters and punctuation
Before:[attachment=1415:2013-12-16_05.00.01.png]
After:[attachment=1416:2013-12-16_05.01.09.png]
Thanks for the help, Ajt86
Edited on 16 December 2013 - 06:36 AM