diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 0b354c5a1..fb231eab0 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -67,7 +67,7 @@ # Logo type option: # Sets the logo type to use. -# Must be auto, builtin, file, raw, sixel, kitty or chafa. +# Must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty or chafa. # Default is auto. #--logo-type auto diff --git a/src/data/help.txt b/src/data/help.txt index 1cebf5748..cd0c36168 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -25,7 +25,7 @@ General options: Logo options: -l,--logo : set the logo to use. The type is specified by --logo-type. If default: the name of a builtin logo or a path to a file - --logo-type : set the type of the logo given. Must be auto, builtin, file, raw, sixel, kitty or chafa. + --logo-type : set the type of the logo given. Must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty or chafa. --logo-width : set the width of the logo (in characters), if it is an image --logo-height : set the height of the logo (in characters), if it is an image --logo-color-[1-9] : overwrite a color in the logo @@ -33,11 +33,13 @@ Logo options: --logo-padding-left : set the padding on the left of the logo --logo-padding-right : set the padding on the right of the logo --logo-print-remaining : weather to print the remaining logo, if it has more lines than modules to display + --file : short for --logo-type file --logo + --file-raw : short for --logo-type file-raw --logo + --data : short for --logo-type data --logo + --data-raw : short for --logo-type data-raw --logo --sixel : short for --logo-type sixel --logo --kitty : short for --logo-type kitty --logo --chafa : short for --logo-type chafa --logo - --file : short for --logo-type file --logo - --raw : short for --logo-type raw --logo Display options: -s,--structure : sets the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available. diff --git a/src/fastfetch.c b/src/fastfetch.c index ffbc964a9..3f7f9f829 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -50,13 +50,13 @@ static void constructAndPrintCommandHelpFormat(const char* name, const char* def static inline void printCommandHelp(const char* command) { if(command == NULL) - fputs(FASTFETCH_DATATEXT_HELP, stdout); + puts(FASTFETCH_DATATEXT_HELP); else if(strcasecmp(command, "c") == 0 || strcasecmp(command, "color") == 0) - fputs(FASTFETCH_DATATEXT_HELP_COLOR, stdout); + puts(FASTFETCH_DATATEXT_HELP_COLOR); else if(strcasecmp(command, "format") == 0) - fputs(FASTFETCH_DATATEXT_HELP_FORMAT, stdout); + puts(FASTFETCH_DATATEXT_HELP_FORMAT); else if(strcasecmp(command, "load-config") == 0 || strcasecmp(command, "loadconfig") == 0 || strcasecmp(command, "config") == 0) - fputs(FASTFETCH_DATATEXT_HELP_CONFIG, stdout); + puts(FASTFETCH_DATATEXT_HELP_CONFIG); else if(strcasecmp(command, "os-format") == 0) { constructAndPrintCommandHelpFormat("os", "{3} {12}", 12, @@ -945,10 +945,12 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con "auto", FF_LOGO_TYPE_AUTO, "builtin", FF_LOGO_TYPE_BUILTIN, "file", FF_LOGO_TYPE_FILE, - "raw", FF_LOGO_TYPE_RAW, - "sixel", FF_LOGO_TYPE_SIXEL, - "kitty", FF_LOGO_TYPE_KITTY, - "chafa", FF_LOGO_TYPE_CHAFA, + "file-raw", FF_LOGO_TYPE_FILE_RAW, + "data", FF_LOGO_TYPE_DATA, + "data-raw", FF_LOGO_TYPE_DATA_RAW, + "sixel", FF_LOGO_TYPE_IMAGE_SIXEL, + "kitty", FF_LOGO_TYPE_IMAGE_KITTY, + "chafa", FF_LOGO_TYPE_IMAGE_CHAFA, NULL ); } @@ -985,30 +987,40 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else goto error; } - else if(strcasecmp(key, "--sixel") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_SIXEL; - } - else if(strcasecmp(key, "--kitty") == 0) - { - optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_KITTY; - } else if(strcasecmp(key, "--file") == 0) { optionParseString(key, value, &instance->config.logo.source); instance->config.logo.type = FF_LOGO_TYPE_FILE; } - else if(strcasecmp(key, "--raw") == 0) + else if(strcasecmp(key, "--file-raw") == 0) { optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_RAW; + instance->config.logo.type = FF_LOGO_TYPE_FILE_RAW; + } + else if(strcasecmp(key, "--data") == 0) + { + optionParseString(key, value, &instance->config.logo.source); + instance->config.logo.type = FF_LOGO_TYPE_DATA; + } + else if(strcasecmp(key, "--data-raw") == 0) + { + optionParseString(key, value, &instance->config.logo.source); + instance->config.logo.type = FF_LOGO_TYPE_DATA_RAW; + } + else if(strcasecmp(key, "--sixel") == 0) + { + optionParseString(key, value, &instance->config.logo.source); + instance->config.logo.type = FF_LOGO_TYPE_IMAGE_SIXEL; + } + else if(strcasecmp(key, "--kitty") == 0) + { + optionParseString(key, value, &instance->config.logo.source); + instance->config.logo.type = FF_LOGO_TYPE_IMAGE_KITTY; } else if(strcasecmp(key, "--chafa") == 0) { optionParseString(key, value, &instance->config.logo.source); - instance->config.logo.type = FF_LOGO_TYPE_CHAFA; + instance->config.logo.type = FF_LOGO_TYPE_IMAGE_CHAFA; } /////////////////// diff --git a/src/fastfetch.h b/src/fastfetch.h index 96dd4a445..36bb4131a 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -30,13 +30,15 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; } typedef enum FFLogoType { - FF_LOGO_TYPE_AUTO, //If something is given, first try builtin, then file. Otherwise detect logo - FF_LOGO_TYPE_BUILTIN, //Builtin ascii art. - FF_LOGO_TYPE_FILE, //Raw text file, printed as is. - FF_LOGO_TYPE_RAW, //Raw text file, printed with color codes replacement. - FF_LOGO_TYPE_SIXEL, //Image file, printed as sixel codes. - FF_LOGO_TYPE_KITTY, //Image file, printed as kitty graphics protocol - FF_LOGO_TYPE_CHAFA //Image file, printed as ascii art using libchafa + FF_LOGO_TYPE_AUTO, //if something is given, first try builtin, then file. Otherwise detect logo + FF_LOGO_TYPE_BUILTIN, //builtin ascii art + FF_LOGO_TYPE_FILE, //text file, printed with color code replacement + FF_LOGO_TYPE_FILE_RAW, //text file, printed as is + FF_LOGO_TYPE_DATA, //text data, printed with color code replacement + FF_LOGO_TYPE_DATA_RAW, //text data, printed as is + FF_LOGO_TYPE_IMAGE_SIXEL, //image file, printed as sixel codes. + FF_LOGO_TYPE_IMAGE_KITTY, //image file, printed as kitty graphics protocol + FF_LOGO_TYPE_IMAGE_CHAFA, //image file, printed as ascii art using libchafa } FFLogoType; typedef enum FFBinaryPrefixType diff --git a/src/logo/image/image.c b/src/logo/image/image.c index d927735ad..1acf09b84 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -114,7 +114,7 @@ static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestDat instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logo.paddingLeft + instance->config.logo.paddingRight; instance->state.logoHeight = requestData->logoCharacterHeight; - if(requestData->type == FF_LOGO_TYPE_KITTY) + if(requestData->type == FF_LOGO_TYPE_IMAGE_KITTY) instance->state.logoHeight -= 1; //Write cache files @@ -346,15 +346,15 @@ FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData* } bool printSuccessful = false; - if(requestData->type == FF_LOGO_TYPE_CHAFA) + if(requestData->type == FF_LOGO_TYPE_IMAGE_CHAFA) { #ifdef FF_HAVE_CHAFA printSuccessful = printImageChafa(instance, requestData, &imageData); #endif } - else if(requestData->type == FF_LOGO_TYPE_KITTY) + else if(requestData->type == FF_LOGO_TYPE_IMAGE_KITTY) printSuccessful = printImageKitty(instance, requestData, &imageData); - else if(requestData->type == FF_LOGO_TYPE_SIXEL) + else if(requestData->type == FF_LOGO_TYPE_IMAGE_SIXEL) printSuccessful = printImageSixel(instance, requestData, &imageData); ffDestroyImageInfo(imageData.imageInfo); @@ -407,7 +407,7 @@ static bool printCachedChars(FFinstance* instance, FFLogoRequestData* requestDat FFstrbuf content; ffStrbufInitA(&content, 32768); - if(requestData->type == FF_LOGO_TYPE_CHAFA) + if(requestData->type == FF_LOGO_TYPE_IMAGE_CHAFA) readCachedStrbuf(requestData, &content, FF_CACHE_FILE_CHAFA); if(content.length == 0) @@ -440,13 +440,13 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat } int fd = -1; - if(requestData->type == FF_LOGO_TYPE_KITTY) + if(requestData->type == FF_LOGO_TYPE_IMAGE_KITTY) { fd = getCacheFD(requestData, FF_CACHE_FILE_KITTY_COMPRESSED); if(fd == -1) fd = getCacheFD(requestData, FF_CACHE_FILE_KITTY_UNCOMPRESSED); } - else if(requestData->type == FF_LOGO_TYPE_SIXEL) + else if(requestData->type == FF_LOGO_TYPE_IMAGE_SIXEL) fd = getCacheFD(requestData, FF_CACHE_FILE_SIXEL); if(fd == -1) @@ -473,7 +473,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat static bool printCached(FFinstance* instance, FFLogoRequestData* requestData) { - if(requestData->type == FF_LOGO_TYPE_CHAFA) + if(requestData->type == FF_LOGO_TYPE_IMAGE_CHAFA) return printCachedChars(instance, requestData); else return printCachedPixel(instance, requestData); @@ -517,7 +517,7 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type) requestData.characterPixelHeight = 1; if( - (type != FF_LOGO_TYPE_CHAFA || instance->config.logo.width == 0 || instance->config.logo.height == 0) && + (type != FF_LOGO_TYPE_IMAGE_CHAFA || instance->config.logo.width == 0 || instance->config.logo.height == 0) && !getCharacterPixelDimensions(&requestData) ) return false; diff --git a/src/logo/logo.c b/src/logo/logo.c index 6abb1b083..3c48e0854 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -266,6 +266,11 @@ static inline void logoPrintDetected(FFinstance* instance) logoPrintStruct(instance, logoGetBuiltinDetected(instance)); } +static void logoPrintData(FFinstance* instance, bool doColorReplacement) { + ffLogoPrintChars(instance, instance->config.logo.source.chars, doColorReplacement); + logoApplyColorsDetected(instance); +} + static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement) { FFstrbuf content; @@ -294,14 +299,18 @@ static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logo) static void logoPrintKnownType(FFinstance* instance) { - bool successfull; + bool successfull = true; if(instance->config.logo.type == FF_LOGO_TYPE_BUILTIN) successfull = logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars); else if(instance->config.logo.type == FF_LOGO_TYPE_FILE) successfull = logoPrintFileIfExists(instance, true); - else if(instance->config.logo.type == FF_LOGO_TYPE_RAW) + else if(instance->config.logo.type == FF_LOGO_TYPE_FILE_RAW) successfull = logoPrintFileIfExists(instance, false); + else if(instance->config.logo.type == FF_LOGO_TYPE_DATA) + logoPrintData(instance, true); + else if(instance->config.logo.type == FF_LOGO_TYPE_DATA_RAW) + logoPrintData(instance, false); else //image successfull = logoPrintImageIfExists(instance, instance->config.logo.type); @@ -349,7 +358,7 @@ void ffLogoPrint(FFinstance* instance) ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "wayst") == 0; //Try to load the logo as an image. If it succeeds, print it and return. - if(logoPrintImageIfExists(instance, supportsKitty ? FF_LOGO_TYPE_KITTY : FF_LOGO_TYPE_CHAFA)) + if(logoPrintImageIfExists(instance, supportsKitty ? FF_LOGO_TYPE_IMAGE_KITTY : FF_LOGO_TYPE_IMAGE_CHAFA)) return; //Try to load the logo as a file. If it succeeds, print it and return.