Logo: support "type": "command-raw"

Fix #1780
This commit is contained in:
李通洲
2025-06-02 11:46:11 +08:00
parent d94a41cc1b
commit 08ed14b42a
4 changed files with 39 additions and 6 deletions
+32 -6
View File
@@ -1,6 +1,7 @@
#include "logo/logo.h"
#include "common/io/io.h"
#include "common/printing.h"
#include "common/processing.h"
#include "detection/os/os.h"
#include "detection/terminalshell/terminalshell.h"
#include "util/textModifier.h"
@@ -455,14 +456,13 @@ static inline void logoPrintDetected(FFLogoSize size)
logoPrintStruct(logoGetBuiltinDetected(size));
}
static bool logoPrintData(bool doColorReplacement)
static bool logoPrintData(bool doColorReplacement, FFstrbuf* source)
{
FFOptionsLogo* options = &instance.config.logo;
if(options->source.length == 0)
if(source->length == 0)
return false;
logoApplyColors(logoGetBuiltinDetected(FF_LOGO_SIZE_NORMAL), doColorReplacement);
ffLogoPrintChars(options->source.chars, doColorReplacement);
ffLogoPrintChars(source->chars, doColorReplacement);
return true;
}
@@ -548,10 +548,36 @@ static bool logoTryKnownType(void)
return logoPrintBuiltinIfExists(&options->source, FF_LOGO_SIZE_SMALL);
if(options->type == FF_LOGO_TYPE_DATA)
return logoPrintData(true);
return logoPrintData(true, &options->source);
if(options->type == FF_LOGO_TYPE_DATA_RAW)
return logoPrintData(false);
return logoPrintData(false, &options->source);
if(options->type == FF_LOGO_TYPE_COMMAND_RAW)
{
FF_STRBUF_AUTO_DESTROY source = ffStrbufCreate();
FFCommandOptions* commandOptions = &instance.config.modules.command;
const char* error = ffProcessAppendStdOut(&source, commandOptions->param.length ? (char* const[]){
commandOptions->shell.chars,
commandOptions->param.chars,
options->source.chars,
NULL
} : (char* const[]){
commandOptions->shell.chars,
options->source.chars,
NULL
});
if (error)
{
if (instance.config.display.showErrors)
fprintf(stderr, "Logo: failed to execute command `%s`: %s\n", options->source.chars, error);
return false;
}
return logoPrintData(false, &source);
}
updateLogoPath(); //We sure have a file, resolve relative paths