Skip to content

Commit 5172a13

Browse files
committed
Global: fix outputColor doesn't work if module keys are disabled
1 parent 3ba8992 commit 5172a13

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/common/printing.c

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,50 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
1111
return;
1212

1313
//This is used as a magic value for hiding keys
14-
if(moduleArgs && ffStrbufEqualS(&moduleArgs->key, " "))
15-
return;
16-
17-
if(!instance.config.display.pipe)
14+
if (!(moduleArgs && ffStrbufEqualS(&moduleArgs->key, " ")))
1815
{
19-
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
20-
if (instance.config.display.brightColor)
21-
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
22-
23-
if(moduleArgs && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR) && moduleArgs->keyColor.length > 0)
24-
ffPrintColor(&moduleArgs->keyColor);
16+
if(!instance.config.display.pipe)
17+
{
18+
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
19+
if (instance.config.display.brightColor)
20+
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
21+
22+
if(moduleArgs && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR) && moduleArgs->keyColor.length > 0)
23+
ffPrintColor(&moduleArgs->keyColor);
24+
else
25+
ffPrintColor(&instance.config.display.colorKeys);
26+
}
27+
28+
//NULL check is required for modules with custom keys, e.g. disk with the folder path
29+
if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0)
30+
{
31+
fputs(moduleName, stdout);
32+
33+
if(moduleIndex > 0)
34+
printf(" %hhu", moduleIndex);
35+
}
2536
else
26-
ffPrintColor(&instance.config.display.colorKeys);
27-
}
28-
29-
//NULL check is required for modules with custom keys, e.g. disk with the folder path
30-
if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0)
31-
{
32-
fputs(moduleName, stdout);
33-
34-
if(moduleIndex > 0)
35-
printf(" %hhu", moduleIndex);
36-
}
37-
else
38-
{
39-
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
40-
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 1, ((FFformatarg[]){
41-
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex, "index"},
42-
}));
43-
ffStrbufWriteTo(&key, stdout);
37+
{
38+
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
39+
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 1, ((FFformatarg[]){
40+
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex, "index"},
41+
}));
42+
ffStrbufWriteTo(&key, stdout);
43+
}
44+
45+
if(!instance.config.display.pipe)
46+
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
47+
48+
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
49+
50+
if (!(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
51+
{
52+
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.display.keyWidth;
53+
if (keyWidth > 0)
54+
printf("\e[%uG", (unsigned) (keyWidth + instance.state.logoWidth));
55+
}
4456
}
4557

46-
if(!instance.config.display.pipe)
47-
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
48-
49-
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
50-
5158
if(!instance.config.display.pipe)
5259
{
5360
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
@@ -56,13 +63,6 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
5663
else if (instance.config.display.colorOutput.length)
5764
ffPrintColor(&instance.config.display.colorOutput);
5865
}
59-
60-
if (!(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
61-
{
62-
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.display.keyWidth;
63-
if (keyWidth > 0)
64-
printf("\e[%uG", (unsigned) (keyWidth + instance.state.logoWidth));
65-
}
6666
}
6767

6868
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments)

0 commit comments

Comments
 (0)