local tArgs = {...}
print("Width of screen:")
local width = tonumber(tArgs[1] or read())
print("Height of screen:")
local height = tonumber(tArgs[2] or read())
print("Filepath of the program you want to run:")
local filepath = tArgs[3] or read()
local win = window.create(term.current(),1,1,width,height)
local oterm = term.current()
local cor = coroutine.create(loadfile(filepath,_ENV))
term.redirect(win)
coroutine.resume(cor)
term.redirect(oterm)
while true do
    local e = {os.pullEvent()}
    if e[1] == "key" and lUtils.isHolding(keys.leftCtrl) and (e[2] == keys.up or e[2] == keys.down or e[2] == keys.left or e[2] == keys.right) then
        local x,y = win.getPosition()
        if e[2] == keys.up then
            y = y+1
        elseif e[2] == keys.down then
            y = y-1
        elseif e[2] == keys.left then
            x = x+1
        elseif e[2] == keys.right then
            x = x-1
        end
        local w,h = term.getSize()
        if x+(width-1) >= w and x <= 1 and y <= 1 and y+(height-1) >= h then
            win.reposition(x,y)
        end
    else
        if string.find(e[1],"mouse") then
            local x,y = win.getPosition()
            e[3] = e[3]-(x-1)
            e[4] = e[4]-(y-1)
        end
        term.redirect(win)
        coroutine.resume(cor,unpack(e))
        term.redirect(oterm)
    end
end
