feat(CountersSelectors): add 'delete' shortcut + change 'm'

This commit is contained in:
Guillaume ARM 2024-05-23 22:38:29 +02:00
parent 642604da9d
commit 64176024f3

View File

@ -161,21 +161,25 @@ local function decrementSelectedCounter(countersMap, selectedCounter)
return false return false
end end
local function switchMinMaxSelectedCounter(countersMap, selectedCounter, maxPossibleCount) local function switchToMaxSelectedCounter(countersMap, selectedCounter, maxPossibleCount)
local counterPayload = countersMap[selectedCounter] local counterPayload = countersMap[selectedCounter]
if counterPayload and counterPayload.count then if counterPayload and counterPayload.count then
if counterPayload.count > 0 then countersMap[selectedCounter] = {
countersMap[selectedCounter] = { count = maxPossibleCount,
count = 0, name = counterPayload.name
name = counterPayload.name }
} end
else end
countersMap[selectedCounter] = {
count = maxPossibleCount, local function switchToMinSelectedCounter(countersMap, selectedCounter)
name = counterPayload.name local counterPayload = countersMap[selectedCounter]
}
end if counterPayload and counterPayload.count then
countersMap[selectedCounter] = {
count = 0,
name = counterPayload.name
}
end end
end end
@ -227,7 +231,10 @@ local function CountersSelector(initialCountersMap, config)
globalCounter = globalCounter + 1 globalCounter = globalCounter + 1
end end
elseif keyPressed == keys.m then elseif keyPressed == keys.m then
switchMinMaxSelectedCounter(countersMap, selectedCounter, counterMax - globalCounter) switchToMaxSelectedCounter(countersMap, selectedCounter, counterMax - globalCounter)
globalCounter = getTotalCount(countersMap)
elseif keyPressed == keys.delete then
switchToMinSelectedCounter(countersMap, selectedCounter)
globalCounter = getTotalCount(countersMap) globalCounter = getTotalCount(countersMap)
elseif keyPressed == keys.r then elseif keyPressed == keys.r then
countersMap = resetAllCounters(countersMap) countersMap = resetAllCounters(countersMap)