Skip to content

Commit 2e98dd7

Browse files
Move ffPrintLogoAndKey to printing.c
1 parent 9d6d2ca commit 2e98dd7

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

src/common/printing.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
#include "fastfetch.h"
22

3+
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
4+
{
5+
ffPrintLogoLine(instance);
6+
7+
if(!instance->config.pipe)
8+
{
9+
fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
10+
11+
//If the main color is not set (e.g. none logo), this would reset in \033[m, which resets everything,
12+
//including the wanted bolt from above. So we only print it, if the main color is at least one char.
13+
if(instance->config.mainColor.length > 0)
14+
ffPrintColor(&instance->config.mainColor);
15+
}
16+
17+
if(customKeyFormat == NULL || customKeyFormat->length == 0)
18+
{
19+
fputs(moduleName, stdout);
20+
21+
if(moduleIndex > 0)
22+
printf(" %hhu", moduleIndex);
23+
}
24+
else
25+
{
26+
FFstrbuf key;
27+
ffStrbufInit(&key);
28+
ffParseFormatString(&key, customKeyFormat, NULL, 1, (FFformatarg[]){
29+
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
30+
});
31+
ffStrbufWriteTo(&key, stdout);
32+
ffStrbufDestroy(&key);
33+
}
34+
35+
if(!instance->config.pipe)
36+
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
37+
38+
ffStrbufWriteTo(&instance->config.separator, stdout);
39+
40+
if(!instance->config.pipe)
41+
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
42+
}
43+
344
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numFormatArgs, const char* message, ...)
445
{
546
if(!instance->config.showErrors)

src/fastfetch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ void ffSuppressIO(bool suppress); // Not thread safe!
456456
void ffGetTerminalResponse(const char* request, const char* format, ...);
457457

458458
//common/printing.c
459+
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
459460
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numFormatArgs, const char* message, ...);
460461
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments);
461462
void ffPrintColor(const FFstrbuf* colorValue);
@@ -528,7 +529,6 @@ void ffPrintLogo(FFinstance* instance);
528529
void ffPrintRemainingLogo(FFinstance* instance);
529530

530531
void ffPrintLogoLine(FFinstance* instance);
531-
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
532532

533533
void ffPrintBuiltinLogos(FFinstance* instance);
534534
void ffListBuiltinLogos();

src/logo/logo.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -249,44 +249,3 @@ void ffPrintRemainingLogo(FFinstance* instance)
249249
putchar('\n');
250250
}
251251
}
252-
253-
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
254-
{
255-
ffPrintLogoLine(instance);
256-
257-
if(!instance->config.pipe)
258-
{
259-
fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
260-
261-
//If the main color is not set (e.g. none logo), this would reset in \0333[m, which resets everything,
262-
//including the wanted bolt from above. So we only print it, if the main color is at least one char.
263-
if(instance->config.mainColor.length > 0)
264-
ffPrintColor(&instance->config.mainColor);
265-
}
266-
267-
if(customKeyFormat == NULL || customKeyFormat->length == 0)
268-
{
269-
fputs(moduleName, stdout);
270-
271-
if(moduleIndex > 0)
272-
printf(" %hhu", moduleIndex);
273-
}
274-
else
275-
{
276-
FFstrbuf key;
277-
ffStrbufInit(&key);
278-
ffParseFormatString(&key, customKeyFormat, NULL, 1, (FFformatarg[]){
279-
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
280-
});
281-
ffStrbufWriteTo(&key, stdout);
282-
ffStrbufDestroy(&key);
283-
}
284-
285-
if(!instance->config.pipe)
286-
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
287-
288-
ffStrbufWriteTo(&instance->config.separator, stdout);
289-
290-
if(!instance->config.pipe)
291-
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
292-
}

0 commit comments

Comments
 (0)