cc/winhlp.lua

25 lines
628 B
Lua
Raw Normal View History

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)
end
return {
translate=translate,
contains=contains,
alignRight=alignRight,
}