local function translate(win, x, y) local winX, winY = win.getPosition() return x-winX+1, y-winY+1 end local function contains(win, x, y) local winX, winY = win.getPosition() local width, height = win.getSize() return x >= winX and y >= winY and x-winX < width and y-winY < height end local function setHeight(win, height) local winX, winY = win.getPosition() local sizeX, sizeY = win.getSize() win.reposition(winX, winY, sizeX, height) end local function alignRight(termlike, length) local tw, th = termlike.getSize() local x, y = termlike.getCursorPos() termlike.setCursorPos(math.min(x, tw-length+1), y) return math.max(0, tw-length-x+1) end return { translate=translate, contains=contains, setHeight=setHeight, alignRight=alignRight, }