diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 8ae04408a..a64a3d5e5 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -842,6 +842,13 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) bool ffLogoPrintImageIfExists(FFLogoType type, bool printError) { + if(instance.config.display.pipe) + { + if(printError) + fputs("Logo: Image logo is not supported in pipe mode\n", stderr); + return false; + } + if(!ffPathExists(instance.config.logo.source.chars, FF_PATHTYPE_FILE)) { if(printError) diff --git a/src/logo/logo.c b/src/logo/logo.c index d9af22a90..97015d237 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -70,7 +70,7 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement) instance.state.logoHeight = options->paddingTop; //Use logoColor[0] as the default color - if(doColorReplacement) + if(doColorReplacement && !instance.config.display.pipe) ffStrbufAppendF(&result, "\e[%sm", options->colors[0].chars); while(*data != '\0') @@ -143,19 +143,27 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement) continue; } - //Map the number to an array index, so that '1' -> 0, '2' -> 1, etc. - int index = ((int) *data) - 49; - - //If the index is valid, print the color. Otherwise continue as normal - if(index < 0 || index >= FASTFETCH_LOGO_MAX_COLORS) + if(!instance.config.display.pipe) { - ffStrbufAppendC(&result, '$'); - ++currentlineLength; - //Don't continue here, we want to print the current char as unicode + //Map the number to an array index, so that '1' -> 0, '2' -> 1, etc. + int index = ((int) *data) - 49; + + //If the index is valid, print the color. Otherwise continue as normal + if(index < 0 || index >= FASTFETCH_LOGO_MAX_COLORS) + { + ffStrbufAppendC(&result, '$'); + ++currentlineLength; + //Don't continue here, we want to print the current char as unicode + } + else + { + ffStrbufAppendF(&result, "\e[%sm", options->colors[index].chars); + ++data; + continue; + } } else { - ffStrbufAppendF(&result, "\e[%sm", options->colors[index].chars); ++data; continue; } @@ -188,7 +196,8 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement) } } - ffStrbufAppendS(&result, FASTFETCH_TEXT_MODIFIER_RESET); + if(!instance.config.display.pipe) + ffStrbufAppendS(&result, FASTFETCH_TEXT_MODIFIER_RESET); if(!options->separate) { @@ -460,10 +469,10 @@ static void logoPrintKnownType(void) void ffLogoPrint(void) { - //In pipe mode, we don't have a logo or padding. + //When generate JSON result, we don't have a logo or padding. //We also don't need to set main color, because it won't be printed anyway. //So we can return quickly here. - if(instance.config.display.pipe || instance.state.resultDoc) + if(instance.state.resultDoc) { instance.state.logoHeight = 0; instance.state.logoWidth = 0; diff --git a/src/options/display.h b/src/options/display.h index a56a224e7..eb3a7c68c 100644 --- a/src/options/display.h +++ b/src/options/display.h @@ -27,7 +27,7 @@ typedef struct FFOptionsDisplay FFstrbuf keyValueSeparator; bool stat; - bool pipe; //disables logo and all escape sequences + bool pipe; //disables all escape sequences bool showErrors; bool disableLinewrap; bool hideCursor;