mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-08 06:00:08 +01:00
Refactored some variable namings to reflect image support
This commit is contained in:
+3
-12
@@ -1380,8 +1380,8 @@ void ffLogoSetMainColor(FFinstance* instance)
|
||||
{
|
||||
const FFlogo* logo = NULL;
|
||||
|
||||
if(instance->config.logoName.length > 0)
|
||||
logo = getBuiltinLogo(instance->config.logoName.chars);
|
||||
if(instance->config.logoSource.length > 0)
|
||||
logo = getBuiltinLogo(instance->config.logoSource.chars);
|
||||
|
||||
if(logo == NULL)
|
||||
logo = detectBuiltinLogo(instance);
|
||||
@@ -1412,18 +1412,9 @@ void ffLogoPrintUnknown(FFinstance* instance)
|
||||
printLogoStruct(instance, getLogoUnknown(), false);
|
||||
}
|
||||
|
||||
void ffLogoPrintBuiltin(FFinstance* instance)
|
||||
{
|
||||
const FFlogo* logo = getBuiltinLogo(instance->config.logoName.chars);
|
||||
if(logo == NULL)
|
||||
ffLogoPrintUnknown(instance);
|
||||
else
|
||||
printLogoStruct(instance, logo, true);
|
||||
}
|
||||
|
||||
bool ffLogoPrintBuiltinIfExists(FFinstance* instance)
|
||||
{
|
||||
const FFlogo* logo = getBuiltinLogo(instance->config.logoName.chars);
|
||||
const FFlogo* logo = getBuiltinLogo(instance->config.logoSource.chars);
|
||||
if(logo == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData*
|
||||
}
|
||||
|
||||
//+1, because we need to copy the null byte too
|
||||
imageData.ffCopyMagickString(imageInfoIn->filename, instance->config.logoName.chars, instance->config.logoName.length + 1);
|
||||
imageData.ffCopyMagickString(imageInfoIn->filename, instance->config.logoSource.chars, instance->config.logoSource.length + 1);
|
||||
|
||||
Image* originalImage = ffReadImage(imageInfoIn, imageData.exceptionInfo);
|
||||
ffDestroyImageInfo(imageInfoIn);
|
||||
@@ -363,7 +363,7 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type)
|
||||
ffStrbufAppendS(&requestData.cacheDir, "images");
|
||||
|
||||
ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX);
|
||||
if(realpath(instance->config.logoName.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL)
|
||||
if(realpath(instance->config.logoSource.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL)
|
||||
{
|
||||
//We can safely return here, because if realpath failed, we surely won't be able to read the file
|
||||
ffStrbufDestroy(&requestData.cacheDir);
|
||||
|
||||
+7
-4
@@ -150,7 +150,7 @@ static void logoPrintFile(FFinstance* instance, bool doColorReplacement)
|
||||
FFstrbuf content;
|
||||
ffStrbufInitA(&content, 2047);
|
||||
|
||||
if(ffAppendFileContent(instance->config.logoName.chars, &content))
|
||||
if(ffAppendFileContent(instance->config.logoSource.chars, &content))
|
||||
ffLogoPrint(instance, content.chars, doColorReplacement);
|
||||
else
|
||||
ffLogoPrintUnknown(instance);
|
||||
@@ -158,7 +158,7 @@ static void logoPrintFile(FFinstance* instance, bool doColorReplacement)
|
||||
|
||||
static void logoPrintDetected(FFinstance* instance)
|
||||
{
|
||||
if(instance->config.logoName.length > 0)
|
||||
if(instance->config.logoSource.length > 0)
|
||||
{
|
||||
if(
|
||||
!ffLogoPrintBuiltinIfExists(instance) &&
|
||||
@@ -180,10 +180,13 @@ void ffPrintLogo(FFinstance* instance)
|
||||
instance->config.logoType == FF_LOGO_TYPE_FILE ||
|
||||
instance->config.logoType == FF_LOGO_TYPE_RAW ||
|
||||
instance->config.logoType == FF_LOGO_TYPE_SIXEL
|
||||
) && instance->config.logoName.length == 0)
|
||||
) && instance->config.logoSource.length == 0)
|
||||
ffLogoPrintUnknown(instance);
|
||||
else if(instance->config.logoType == FF_LOGO_TYPE_BUILTIN)
|
||||
ffLogoPrintBuiltin(instance);
|
||||
{
|
||||
if(!ffLogoPrintBuiltinIfExists(instance))
|
||||
ffLogoPrintUnknown(instance);
|
||||
}
|
||||
else if(instance->config.logoType == FF_LOGO_TYPE_FILE)
|
||||
logoPrintFile(instance, true);
|
||||
else if(instance->config.logoType == FF_LOGO_TYPE_RAW)
|
||||
|
||||
@@ -12,7 +12,6 @@ void ffLogoPrint(FFinstance* instance, const char* data, bool doColorReplacement
|
||||
void ffLogoSetMainColor(FFinstance* instance);
|
||||
|
||||
void ffLogoPrintUnknown(FFinstance* instance);
|
||||
void ffLogoPrintBuiltin(FFinstance* instance);
|
||||
bool ffLogoPrintBuiltinIfExists(FFinstance* instance);
|
||||
void ffLogoPrintBuiltinDetected(FFinstance* instance);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user