From 17b98007b4d33b5a23401f395c08f0a88b08dd66 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 21 Sep 2026 14:14:09 +0800 Subject: [PATCH] Logo (Image): improves compatibility for iTerm when printing gif logo --- CHANGELOG.md | 2 ++ src/common/io.h | 2 +- src/logo/image/image.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 712f3f321..1db5bce89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,8 @@ Bugfixes: * Fixed module format strings mishandling a value that carries more than one leading ANSI escape sequence: the second escape was taken for the start of the trailing reset, so `:`, `<`, `>` and `|` left the value untruncated instead of truncating it. * Fixed issues when running on big-endian platforms. * Fixed building on FreeBSD 16.0-CURRENT, where `` defines `memrchr` as a qualifier-preserving function-like macro. (General, FreeBSD) +* Worked around an iTerm bug where the image logo may be moved out of view. (Logo) +* Increased the terminal response wait time to 1s to improve compatibility with slower terminals. (General) * Some internal cleanups and optimizations. Logos: diff --git a/src/common/io.h b/src/common/io.h index c4a12fb3b..95f3ccc41 100644 --- a/src/common/io.h +++ b/src/common/io.h @@ -228,7 +228,7 @@ typedef enum FFPathType: uint8_t { [[gnu::nonnull(1, 2)]] bool ffPathExpandEnv(const char* in, FFstrbuf* out); -#define FF_IO_TERM_RESP_WAIT_MS 200 // #554 +#define FF_IO_TERM_RESP_WAIT_MS 1000 // Terminal may respond slowly, especially when printing large image/gif logos. Found on iTerm [[gnu::format(scanf, 3, 4), gnu::nonnull(1, 3)]] const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...); diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 33fefec9d..c81a2aae6 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -84,7 +84,9 @@ static bool printImageIterm(bool printError) { instance.state.logoWidth = X + options->paddingRight - 1; } instance.state.logoHeight = Y; - fputs("\e[H", stdout); + // Work around an iTerm bug. Without the leading whitespace the image logo may be moved out of view + // Found in iTerm 3.7.2 + fputs(" \e[H", stdout); } else if (options->position == FF_LOGO_POSITION_TOP) { instance.state.logoWidth = instance.state.logoHeight = 0; ffPrintCharTimes('\n', options->paddingRight);