From 4b7a38ebf060809fe3d3196cbd33c7ff61c09bd4 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Thu, 23 May 2024 22:46:24 +0200 Subject: [PATCH] feat(CountersSelectors): add pageup/pagedown/home/end shortcuts --- libs/ui/CountersSelector.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/ui/CountersSelector.lua b/libs/ui/CountersSelector.lua index a5c2ddf..1a6ed7a 100644 --- a/libs/ui/CountersSelector.lua +++ b/libs/ui/CountersSelector.lua @@ -208,7 +208,9 @@ local function CountersSelector(initialCountersMap, config) term.clear() local width, height = term.getSize() - local mainWin = window.create(term.current(), 1, 1 + topHeight, width, height - topHeight) + local mainHeight = height - topHeight + local nbOfElemsPerPage = mainHeight + local mainWin = window.create(term.current(), 1, 1 + topHeight, width, mainHeight) local titleWin = window.create(term.current(), 1, 1, width, 1 + topHeight) local shouldContinue = true @@ -222,6 +224,14 @@ local function CountersSelector(initialCountersMap, config) selectedCounter = math.max(1, selectedCounter - 1) elseif keyPressed == keys.down then selectedCounter = math.min(nbCounters, selectedCounter + 1) + elseif keyPressed == keys.home then + selectedCounter = 1 + elseif keyPressed == keys['end'] then + selectedCounter = nbCounters + elseif keyPressed == keys.pageUp then + selectedCounter = math.max(1, selectedCounter - nbOfElemsPerPage) + elseif keyPressed == keys.pageDown then + selectedCounter = max.max(nbCounters, selectedCounter + nbOfElemsPerPage) elseif keyPressed == keys.left and globalCounter > 0 then if decrementSelectedCounter(countersMap, selectedCounter) then globalCounter = globalCounter - 1