cc/winhlp.lua
Ben e414f229db
Refactor, add listview to requests view
Update line by line and do full redraw only when necessary.
2024-06-02 00:52:58 +02:00

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