From 9a54d92e9f1b6b300e63768112cb5ddc887c2763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 May 2025 10:33:33 +0800 Subject: [PATCH] Stat: use `ESC 7/8` instead of `CSI s/u` Fix Apple Terminal compatibility #1755 --- src/common/commandoption.c | 2 +- src/common/jsonconfig.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/commandoption.c b/src/common/commandoption.c index 01335a1ff..d91072928 100644 --- a/src/common/commandoption.c +++ b/src/common/commandoption.c @@ -134,7 +134,7 @@ void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc) int len = snprintf(str, sizeof str, "%.3fms", ms); if (thres > 0) snprintf(str, sizeof str, "\e[%sm%.3fms\e[m", (ms <= thres ? FF_COLOR_FG_GREEN : ms <= 2 * thres ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_RED), ms); - printf("\e[s\e[1A\e[9999999C\e[%dD%s\e[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load + printf("\e7\e[1A\e[9999999C\e[%dD%s\e8", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } } diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 5732e33b3..6170f31e5 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -224,7 +224,7 @@ static const char* printJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc) int len = snprintf(str, sizeof str, "%.3fms", ms); if (thres > 0) snprintf(str, sizeof str, "\e[%sm%.3fms\e[m", (ms <= thres ? FF_COLOR_FG_GREEN : ms <= 2 * thres ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_RED), ms); - printf("\e[s\e[1A\e[9999999C\e[%dD%s\e[u", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load + printf("\e7\e[1A\e[9999999C\e[%dD%s\e8", len, str); // Save; Up 1; Right 9999999; Left ; Print ; Load } }