@@ -461,7 +461,7 @@ static bool updateLogoPath(void) {
461461 return true;
462462 }
463463
464- #if !FF_MODULE_DISABLE_MEDIA
464+ #if !FF_MODULE_DISABLE_MEDIA
465465 if (ffStrbufIgnCaseEqualS (& options -> source , "media-cover" )) {
466466 const FFMediaResult * media = ffDetectMedia (true);
467467 if (media -> cover .length == 0 ) {
@@ -470,7 +470,7 @@ static bool updateLogoPath(void) {
470470 ffStrbufSet (& options -> source , & media -> cover );
471471 return true;
472472 }
473- #endif
473+ #endif
474474
475475 FF_STRBUF_AUTO_DESTROY fullPath = ffStrbufCreateA (128 );
476476 if (ffPathExpandEnv (options -> source .chars , & fullPath ) && ffPathExists (fullPath .chars , FF_PATHTYPE_FILE )) {
@@ -639,7 +639,7 @@ void ffLogoPrint(void) {
639639 }
640640
641641 if (!ffStrbufEndsWithIgnCaseS (& options -> source , ".txt" )) {
642- #if !FF_MODULE_DISABLE_TERMINAL
642+ #if !FF_MODULE_DISABLE_TERMINAL
643643 const FFTerminalResult * terminal = ffDetectTerminal ();
644644
645645 bool supportsIterm2 = ffStrbufEqualS (& terminal -> prettyName , "iTerm" );
@@ -655,15 +655,15 @@ void ffLogoPrint(void) {
655655 ffStrbufIgnCaseEqualS (& terminal -> processName , "wezterm" ) ||
656656 ffStrbufIgnCaseEqualS (& terminal -> processName , "wayst" ) ||
657657 ffStrbufIgnCaseEqualS (& terminal -> processName , "ghostty" ) ||
658- #ifdef __APPLE__
658+ #ifdef __APPLE__
659659 ffStrbufIgnCaseEqualS (& terminal -> processName , "WarpTerminal" ) ||
660- #else
660+ #else
661661 ffStrbufIgnCaseEqualS (& terminal -> processName , "warp" ) ||
662- #endif
662+ #endif
663663 false;
664- #else
664+ #else
665665 bool supportsKitty = false;
666- #endif
666+ #endif
667667
668668 // Try to load the logo as an image. If it succeeds, print it and return.
669669 if (logoPrintImageIfExists (supportsKitty ? FF_LOGO_TYPE_IMAGE_KITTY : FF_LOGO_TYPE_IMAGE_CHAFA , false)) {
@@ -685,37 +685,39 @@ void ffLogoPrint(void) {
685685}
686686
687687void ffLogoPrintLine (void ) {
688- uint32_t printedLineWidth = 0 ;
689688 FFLogoLineCacheState * cache = & instance .state .logoLineCache ;
690689 FFOptionsLogo * logo = & instance .config .logo ;
691690
692- if (cache -> lines .length > 0 && (logo -> position == FF_LOGO_POSITION_LEFT || logo -> position == FF_LOGO_POSITION_RIGHT ) && cache -> nextLine < cache -> lines .length ) {
693- FFLogoCachedLine * line = FF_LIST_GET (FFLogoCachedLine , cache -> lines , cache -> nextLine );
691+ if (cache -> lines .length > 0 ) {
692+ // Line cache is enabled. Always move cursor with whitespaces to make lolcat happy
693+ if (cache -> nextLine < cache -> lines .length ) {
694+ // Print logo line and move cursor
695+ FFLogoCachedLine * line = FF_LIST_GET (FFLogoCachedLine , cache -> lines , cache -> nextLine );
694696
695- if (logo -> position == FF_LOGO_POSITION_RIGHT && line -> chars .length > 0 ) {
696- printf ("\033[9999999C\033[%uD" , cache -> rightOffset );
697- ffStrbufWriteTo (& line -> chars , stdout );
698- fputs ("\033[G" , stdout );
699- } else {
700- ffStrbufWriteTo (& line -> chars , stdout );
701- printedLineWidth = line -> width ;
702- }
697+ if (logo -> position == FF_LOGO_POSITION_RIGHT ) {
698+ printf ("\033[9999999C\033[%uD" , cache -> rightOffset );
699+ ffStrbufWriteTo (& line -> chars , stdout );
703700
704- ++ cache -> nextLine ;
705- }
701+ fputs ("\033[G" , stdout );
702+ } else {
703+ ffStrbufWriteTo (& line -> chars , stdout );
706704
707- if (instance .state .logoWidth > 0 ) {
708- if (instance .config .logo .position == FF_LOGO_POSITION_LEFT ) {
709- uint32_t remaining = instance .state .logoWidth ;
710- remaining = printedLineWidth < remaining ? remaining - printedLineWidth : 0 ;
711- ffPrintCharTimes (' ' , remaining );
712- } else {
713- printf ("\033[%uC" , instance .state .logoWidth );
705+ uint32_t remaining = instance .state .logoWidth ;
706+ remaining = line -> width < remaining ? remaining - line -> width : 0 ;
707+ ffPrintCharTimes (' ' , remaining );
708+ }
709+ ++ cache -> nextLine ;
710+ } else if (logo -> position == FF_LOGO_POSITION_LEFT ) {
711+ // Move cursor to the start position
712+ ffPrintCharTimes (' ' , instance .state .logoWidth );
714713 }
714+ } else if (instance .state .logoWidth > 0 ) {
715+ printf ("\033[%uC" , instance .state .logoWidth );
715716 }
716717
717- if (instance .state .dynamicInterval > 0 ) {
718+ if (instance .state .dynamicInterval > 0 && logo -> position == FF_LOGO_POSITION_LEFT ) {
718719 fputs ("\033[K" , stdout ); // Clear to the end of the line
720+ // Note that we don't clear the line when the logo is on the right, as it will also clear the logo itself
719721 }
720722
721723 ++ instance .state .keysHeight ;
0 commit comments