From 3289e07a897d3d0995bbb0a5ba32f1e2d33ab0a3 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sun, 2 Jun 2024 16:49:53 +0200 Subject: [PATCH] Add window setHeight in winhlp --- orders.lua | 4 +--- winhlp.lua | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/orders.lua b/orders.lua index 98da008..b3c2a79 100644 --- a/orders.lua +++ b/orders.lua @@ -39,9 +39,7 @@ local function fetch(wait_for) end local function drawEntry(win, obj) - local winX, winY = win.getPosition() - local sizeX, sizeY = win.getSize() - win.reposition(winX, winY, sizeX, 2) + winhlp.setHeight(win, 2) win.setBackgroundColor(colors.black) win.setTextColor(colors.lightGray) win.write(obj.id) diff --git a/winhlp.lua b/winhlp.lua index 656db8b..d1e19e7 100644 --- a/winhlp.lua +++ b/winhlp.lua @@ -1,14 +1,20 @@ -local function translate(window, x, y) - local winX, winY = window.getPosition() +local function translate(win, x, y) + local winX, winY = win.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() +local function contains(win, x, y) + local winX, winY = win.getPosition() + local width, height = win.getSize() return x >= winX and y >= winY and x-winX < width and y-winY < height end +local function setHeight(win, height) + local winX, winY = win.getPosition() + local sizeX, sizeY = win.getSize() + win.reposition(winX, winY, sizeX, height) +end + local function alignRight(termlike, length) local tw, th = termlike.getSize() local x, y = termlike.getCursorPos() @@ -20,5 +26,6 @@ end return { translate=translate, contains=contains, + setHeight=setHeight, alignRight=alignRight, }