cc/winhlp.lua

25 lines
623 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))
return math.max(0, tw-length-x)
end
return {
translate=translate,
contains=contains,
alignRight=alignRight,
}