mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Refactored some variable namings to reflect image support
This commit is contained in:
+1
-1
@@ -104,7 +104,7 @@ static void initState(FFstate* state)
|
||||
|
||||
static void defaultConfig(FFinstance* instance)
|
||||
{
|
||||
ffStrbufInit(&instance->config.logoName);
|
||||
ffStrbufInit(&instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_AUTO;
|
||||
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
|
||||
ffStrbufInit(&instance->config.logoColors[i]);
|
||||
|
||||
@@ -30,6 +30,8 @@ Logo options:
|
||||
--logo-print-remaining <?value>: weather to print the remaining logo, if it has more lines than modules to display
|
||||
--sixel <file>: short for --logo-type sixel --logo <file>
|
||||
--kitty <file>: short for --logo-type kitty --logo <file>
|
||||
--file <file>: short for --logo-type file --logo <file>
|
||||
--raw <file>: short for --logo-type raw --logo <file>
|
||||
|
||||
Display options:
|
||||
-s,--structure <structure>: sets the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
|
||||
|
||||
+13
-3
@@ -714,7 +714,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
////////////////
|
||||
|
||||
else if(strcasecmp(key, "-l") == 0 || strcasecmp(key, "--logo") == 0)
|
||||
optionParseString(key, value, &instance->config.logoName);
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
else if(strcasecmp(key, "--logo-type") == 0)
|
||||
{
|
||||
if(value == NULL)
|
||||
@@ -771,14 +771,24 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
instance->config.logoPrintRemaining = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--sixel") == 0)
|
||||
{
|
||||
optionParseString(key, value, &instance->config.logoName);
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_SIXEL;
|
||||
}
|
||||
else if(strcasecmp(key, "--kitty") == 0)
|
||||
{
|
||||
optionParseString(key, value, &instance->config.logoName);
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_KITTY;
|
||||
}
|
||||
else if(strcasecmp(key, "--file") == 0)
|
||||
{
|
||||
optionCheckString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_FILE;
|
||||
}
|
||||
else if(strcasecmp(key, "--raw") == 0)
|
||||
{
|
||||
optionParseString(key, value, &instance->config.logoSource);
|
||||
instance->config.logoType = FF_LOGO_TYPE_RAW;
|
||||
}
|
||||
|
||||
///////////////////
|
||||
//Display options//
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ typedef enum FFLogoType
|
||||
|
||||
typedef struct FFconfig
|
||||
{
|
||||
FFstrbuf logoName;
|
||||
FFstrbuf logoSource;
|
||||
FFLogoType logoType;
|
||||
FFstrbuf logoColors[FASTFETCH_LOGO_MAX_COLORS];
|
||||
uint32_t logoWidth;
|
||||
|
||||
+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