cc/winhlp.lua
2024-06-02 03:16:18 +02:00

25 lines
630 B
Lua

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
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,
alignRight=alignRight,
}