From ab17e80fa5554e2a0d5950f940fe21bd879909c2 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Thu, 23 May 2024 21:19:28 +0200 Subject: [PATCH] fix(CountersSelectors): createWriteWithColor --- libs/ui/CountersSelector.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libs/ui/CountersSelector.lua b/libs/ui/CountersSelector.lua index be43e60..87ab1e1 100644 --- a/libs/ui/CountersSelector.lua +++ b/libs/ui/CountersSelector.lua @@ -6,20 +6,21 @@ end local function createWriteWithColor(textColor, backgroundColor, givenWin) local win = givenWin or term - local originalTextColor = nil - local originalBackgroundColor = nil - - if textColor then - originalTextColor = win.getTextColor() - win.setTextColor(textColor) - end - - if backgroundColor then - originalBackgroundColor = win.getBackgroundColor() - win.setBackgroundColor(backgroundColor) - end return function(str) + local originalTextColor = nil + local originalBackgroundColor = nil + + if textColor then + originalTextColor = win.getTextColor() + win.setTextColor(textColor) + end + + if backgroundColor then + originalBackgroundColor = win.getBackgroundColor() + win.setBackgroundColor(backgroundColor) + end + win.write(str) if originalTextColor then