Skip to content

Commit ffcddf3

Browse files
committed
Logo: improve builtin logo printing for piping and buffering
Fixes #2065
1 parent 22c92c7 commit ffcddf3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/logo/logo.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,22 +733,23 @@ void ffLogoPrintRemaining(void)
733733
void ffLogoBuiltinPrint(void)
734734
{
735735
FFOptionsLogo* options = &instance.config.logo;
736+
options->position = FF_LOGO_POSITION_TOP;
737+
options->paddingRight = 2; // empty line after logo printing
738+
FF_STRBUF_AUTO_DESTROY buf = ffStrbufCreate();
736739

737740
for(uint8_t ch = 0; ch < 26; ++ch)
738741
{
739742
for(const FFlogo* logo = ffLogoBuiltins[ch]; *logo->names; ++logo)
740743
{
741-
printf("\033[%sm%s:\033[0m\n", logo->colors[0], logo->names[0]);
744+
if (instance.config.display.pipe)
745+
ffStrbufSetF(&buf, "%s:\n", logo->names[0]);
746+
else
747+
ffStrbufSetF(&buf, "\e[%sm%s:\e[0m\n", logo->colors[0], logo->names[0]);
748+
ffWriteFDBuffer(FFUnixFD2NativeFD(STDOUT_FILENO), &buf);
742749
logoPrintStruct(logo);
743-
ffLogoPrintRemaining();
744750

745-
//reset everything
746-
instance.state.logoHeight = 0;
747-
instance.state.keysHeight = 0;
748751
for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++)
749752
ffStrbufClear(&options->colors[i]);
750-
751-
putchar('\n');
752753
}
753754
}
754755
}

0 commit comments

Comments
 (0)