This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mrpoopy345's profile picture

Setting The Cursor Postion

Started by mrpoopy345, 27 October 2013 - 08:50 AM
mrpoopy345 #1
Posted 27 October 2013 - 09:50 AM
OK I am making a mini OS and I need to know how to set the DEFAULT cursor postion.
I have a box on the left of the screen, and i want the place where you input commands to be way over at 27, 2.
I know this can be done because they do it in SkyOS.
But how??????
LBPHacker #2
Posted 27 October 2013 - 10:08 AM
You have to overwrite the term API and pass it to the shell and all the programs you want to appear next to the box on the left.
local termWithMargin = {}
local boxWidth = 10
for key, value in pairs(term) do termWithMargin[key] = value end
function termWithMargin.setCursorPos(posX, posY)
    return term.setCursorPos(posX + boxWidth, posY)
end
function termWithMargin.getSize(posX, posY)
    local width, height = term.getSize()
    return width - boxWidth, height
end
os.run({term = termWithMargin}, "rom/programs/shell")
For term.scroll though, which is inevitably going to be called, you'll have to set up some kind of buffer which records everything output by term.write, and you'll have to make termWithMargin.scroll so it scrolls that buffer. It's kinda hacky, I know, but as far as I know, this is the easiest way to do this.