I'm afraid there isn't "a" command for this. Just to deal with mouse-clicks you'd want a custom coroutine manager.
But the "simple" method (
relative to most any other method, at least) would be to make use of the window API, which provides you with buffered terminal objects that you can redirect your scripts to. Windows can be easily
moved and resized. The idea would be to use
two windows per script, one the parent of the other - the child would be full-sized at all times, and the parent you can move around and resize. Resizing a window to a smaller size causes it to discard any content that's being cropped out, but since resizing a
parent doesn't cause the
child to lose information, that ceases to be a problem (you simply
redraw the child whenever you enlarge the parent, and boom - the content's back).
Of course, a dedicated buffer object (one tailor-made for your purposes) would be more efficient in terms of speed, but the window API is very handy as a "one size fits all"-type solution.
Could you make an example? That'd be all I'd need to make my API, maybe like
an edit window, or if not, that's fine, I'll try to figure it out.
Keep in mind, the program will have to be able to resize.
Easy fix if your program puts pixels down according to the current terminals width and height
Something like this (I dont know if this will work but it should be something close to this):
programParent = window.create(term.current(),1,1,width you want,height you want)
programChild = window.create(programParent,1,1,w,h)
cornerX,cornerY = [width you want], [height you want]
topX,topY = 1,1
program = coroutine.create(loadfile([path of program you want here]))
term.redirect(programChild)
while true do
local event, p1, p2, p3 = os.pullEvent()
coroutine.resume(program,event,p1,p2,p3)
if(event == "mouse_click") then
type,X,Y = p1,p2,p3
if(X == cornerX and Y == cornerY) then
_,cornerX,cornerY = os.pullEvent("mouse_up")
programParent.reposition(topX,topY,cornerX,cornerY)
elseif(X >=topX and X <= cornerX and Y == topY) then
_, topX, topY = os.pullEvent("mouse_up")
programParent.reposition(topX,topY,cornerX,cornerY)
end
end
end
If you use this, please give me credit :)/>
Edited the code so coroutine doesn't have "events" be nil, it returns the event, p1,p2,p3 so that fixes SOMETHING. (In the many flaws that program probably has.)