Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- HAX0R'S Easy Windowing API
- local fccv = os.version()
- local ver = fccv:sub(fccv:len()-2, fccv:len())
- local queue = {}
- if tonumber(ver) < 1.6 then
- error("Incompatbile with CC 1.5 and below!")
- end
- function makeWindow(name, x, y, width, height, program)
- local x = window.create(term.native(), x, y, width, true)
- for a=1, #queue do
- if queue[a]["name"] == name then
- error("A window with the name '"..name.."' already exists!")
- end
- table.insert( {
- ["name"] = name,
- ["queue"] = {},
- ["redirect"] = x
- } )
- for i=1, #queue do
- if queue[i]["name"] == name then
- table.insert(queue[i]["queue"], program)
- end
- end
- return true
- end
- function addProgram(winName, program)
- for i=1, #queue do
- if queue[i]["name"] == name then
- table.insert(queue[i]["queue"], program)
- end
- end
- end
- function runQueue(name)
- for a=1, #queue do
- if queue[a]["name"] == name then
- for b=1, #queue[a]["queue"] do
- term.redirect(queue[a]["redirect"])
- os.run({}, queue[a]["queue"][b])
- term.redirect(term.native())
- end
- end
- end
- end
- function moveWindow(name, x, y)
- for a=1, #queue do
- if queue[a]["name"] == name then
- queue[a]["redirect"].reposition(x, y)
- end
- end
- end
- function getPosition(name)
- for a=1, #queue do
- if queue[a]["name"] == name then
- local w, h = queue[a]["redirect"].getPosition()
- return w, h
- end
- end
- return nil
- end
- function resizeWindow(name, w, h)
- for a=1, #queue do
- if queue[a]["name"] == name then
- local x, y = getPosition(name)
- queue[a]["redirect"].reposition(x, y, w, h)
- end
- end
- end
Add Comment
Please, Sign In to add comment