From 3f67fac4fa94e54ae3977bca589a314c48febbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 4 Sep 2024 10:50:46 +0800 Subject: [PATCH] TerminalTheme: support Windows --- src/detection/terminaltheme/terminaltheme.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/detection/terminaltheme/terminaltheme.c b/src/detection/terminaltheme/terminaltheme.c index 192864bb3..67d4549bb 100644 --- a/src/detection/terminaltheme/terminaltheme.c +++ b/src/detection/terminaltheme/terminaltheme.c @@ -8,7 +8,8 @@ static bool detectByEscapeCode(FFTerminalThemeResult* result) { int command = 0; - if (ffGetTerminalResponse("\e]10;?\e\\", "\e]%d;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 "\e\\", &command, &result->fg.r, &result->fg.g, &result->fg.b) == NULL) + // Windows Terminal doesn't report `\e` for some reason + if (ffGetTerminalResponse("\e]10;?\e\\", "%*[^0-9]%d;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 "\e\\", &command, &result->fg.r, &result->fg.g, &result->fg.b) == NULL) { if (command != 10) return false; @@ -18,7 +19,7 @@ static bool detectByEscapeCode(FFTerminalThemeResult* result) else return false; - if (ffGetTerminalResponse("\e]11;?\e\\", "\e]%d;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 "\e\\", &command, &result->bg.r, &result->bg.g, &result->bg.b) == NULL) + if (ffGetTerminalResponse("\e]11;?\e\\", "%*[^0-9]%d;rgb:%" SCNx16 "/%" SCNx16 "/%" SCNx16 "\e\\", &command, &result->bg.r, &result->bg.g, &result->bg.b) == NULL) { if (command != 11) return false;