2024-06-01 16:08:57 +00:00
|
|
|
local function translate(window, x, y)
|
|
|
|
local winX, winY = window.getPosition()
|
|
|
|
return x-winX+1, y-winY+1
|
|
|
|
end
|
|
|
|
|
|
|
|
local function contains(window, x, y)
|
|
|
|
local winX, winY = window.getPosition()
|
|
|
|
local width, height = window.getSize()
|
|
|
|
return x >= winX and y >= winY and x-winX < width and y-winY < height
|
|
|
|
end
|
|
|
|
|
2024-06-01 22:52:58 +00:00
|
|
|
local function alignRight(termlike, length)
|
|
|
|
local tw,th = termlike.getSize()
|
|
|
|
local x,y = termlike.getCursorPos()
|
|
|
|
termlike.setCursorPos(math.min(x, tw-length+1))
|
|
|
|
return math.max(0, tw-length-x)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2024-06-01 16:08:57 +00:00
|
|
|
return {
|
|
|
|
translate=translate,
|
|
|
|
contains=contains,
|
2024-06-01 22:52:58 +00:00
|
|
|
alignRight=alignRight,
|
2024-06-01 16:08:57 +00:00
|
|
|
}
|