mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
better result handling of calculation functions
This commit is contained in:
+21
-18
@@ -5,54 +5,57 @@
|
||||
|
||||
void ffPrintTheme(FFinstance* instance)
|
||||
{
|
||||
ffCalculatePlasmaAndGtk(instance);
|
||||
const FFPlasmaResult* plasma = ffCalculatePlasma(instance);
|
||||
const FFstrbuf* gtk2 = &ffCalculateGTK2(instance)->theme;
|
||||
const FFstrbuf* gtk3 = &ffCalculateGTK3(instance)->theme;
|
||||
const FFstrbuf* gtk4 = &ffCalculateGTK4(instance)->theme;
|
||||
|
||||
if(instance->state.plasma.widgetStyle.length == 0 && instance->state.plasma.colorScheme.length == 0 && instance->state.gtk2.theme.length == 0 && instance->state.gtk3.theme.length == 0 && instance->state.gtk4.theme.length == 0)
|
||||
if(plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, FF_THEME_NUM_FORMAT_ARGS, "No themes found");
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_CREATE(plasmaColorPretty);
|
||||
if(ffStrbufStartsWithIgnCase(&instance->state.plasma.colorScheme, &instance->state.plasma.widgetStyle))
|
||||
ffStrbufAppendNS(&plasmaColorPretty, instance->state.plasma.colorScheme.length - instance->state.plasma.widgetStyle.length, &instance->state.plasma.colorScheme.chars[instance->state.plasma.widgetStyle.length]);
|
||||
if(ffStrbufStartsWithIgnCase(&plasma->colorScheme, &plasma->widgetStyle))
|
||||
ffStrbufAppendNS(&plasmaColorPretty, plasma->colorScheme.length - plasma->widgetStyle.length, &plasma->colorScheme.chars[plasma->widgetStyle.length]);
|
||||
else
|
||||
ffStrbufAppend(&plasmaColorPretty, &instance->state.plasma.colorScheme);
|
||||
ffStrbufAppend(&plasmaColorPretty, &plasma->colorScheme);
|
||||
|
||||
ffStrbufTrim(&plasmaColorPretty, ' ');
|
||||
|
||||
FF_STRBUF_CREATE(gtkPretty);
|
||||
ffGetGtkPretty(>kPretty, &instance->state.gtk2.theme, &instance->state.gtk3.theme, &instance->state.gtk4.theme);
|
||||
ffGetGtkPretty(>kPretty, gtk2, gtk3, gtk4);
|
||||
|
||||
if(instance->config.themeFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey);
|
||||
|
||||
if(instance->state.plasma.widgetStyle.length > 0)
|
||||
if(plasma->widgetStyle.length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&instance->state.plasma.widgetStyle, stdout);
|
||||
ffStrbufWriteTo(&plasma->widgetStyle, stdout);
|
||||
|
||||
if(instance->state.plasma.colorScheme.length > 0)
|
||||
if(plasma->colorScheme.length > 0)
|
||||
{
|
||||
fputs(" (", stdout);
|
||||
|
||||
if(plasmaColorPretty.length > 0)
|
||||
ffStrbufWriteTo(&plasmaColorPretty, stdout);
|
||||
else
|
||||
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
|
||||
ffStrbufWriteTo(&plasma->colorScheme, stdout);
|
||||
|
||||
putchar(')');
|
||||
}
|
||||
}
|
||||
else if(instance->state.plasma.colorScheme.length > 0)
|
||||
else if(plasma->colorScheme.length > 0)
|
||||
{
|
||||
if(plasmaColorPretty.length > 0)
|
||||
ffStrbufWriteTo(&plasmaColorPretty, stdout);
|
||||
else
|
||||
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
|
||||
ffStrbufWriteTo(&plasma->colorScheme, stdout);
|
||||
}
|
||||
|
||||
if(instance->state.plasma.widgetStyle.length > 0 || instance->state.plasma.colorScheme.length > 0)
|
||||
if(plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0)
|
||||
{
|
||||
fputs(" [Plasma]", stdout);
|
||||
|
||||
@@ -65,12 +68,12 @@ void ffPrintTheme(FFinstance* instance)
|
||||
else
|
||||
{
|
||||
ffPrintFormatString(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, NULL, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.widgetStyle},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.colorScheme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma->widgetStyle},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma->colorScheme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &plasmaColorPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk2.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk3.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk4.theme},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, >kPretty}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user