From ab7a10870d7347056d86eed03f6aca62aaf4d083 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 3 Feb 2021 13:46:19 +0000 Subject: winansi: change default 'skip ANSI emulation' setting Change the default 'skip ANSI emulation' setting which is used when the environment variable BB_SKIP_ANSI_EMULATION is unset. Previously it was 0 (always emulate) now it's 2 (detect whether or not the terminal supports ANSI escape sequences and behave accordingly). The default value is also now a build-time option. --- Config.in | 17 +++++++++++++++++ configs/mingw32_defconfig | 3 ++- configs/mingw64_defconfig | 3 ++- win32/winansi.c | 16 +++------------- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Config.in b/Config.in index 2d1e9bc8b..6d91ad248 100644 --- a/Config.in +++ b/Config.in @@ -455,6 +455,23 @@ config FEATURE_EURO requires the OEM code page to be 858. If the OEM code page of the console is 850 when BusyBox starts it's changed to 858. +config SKIP_ANSI_EMULATION_DEFAULT + int "Default setting for ANSI escape sequences" + default 2 + range 0 2 + depends on PLATFORM_MINGW32 + help + Control how ANSI escape sequences are handled. Possible values + are: + + 0 Always emulate escape sequences. + 1 Always emit escape sequences. + 2 Emit escape sequences if the terminal supports them, otherwise + emulate them. + + Setting the environment variable BB_SKIP_ANSI_EMULATION overrides + this default. + config FEATURE_EXTRA_FILE_DATA bool "Read additional file metadata (2.1 kb)" default y diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index f95f71607..51b27f366 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.34.0.git -# Thu Jan 14 12:07:38 2021 +# Wed Feb 3 13:41:09 2021 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -52,6 +52,7 @@ CONFIG_FEATURE_ICON=y # CONFIG_FEATURE_ICON_STERM is not set CONFIG_FEATURE_ICON_ALL=y CONFIG_FEATURE_EURO=y +CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 CONFIG_FEATURE_EXTRA_FILE_DATA=y CONFIG_FEATURE_READLINK2=y diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index cf0e3ec8e..a8cb75215 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.34.0.git -# Thu Jan 14 12:07:38 2021 +# Wed Feb 3 13:41:09 2021 # CONFIG_HAVE_DOT_CONFIG=y # CONFIG_PLATFORM_POSIX is not set @@ -52,6 +52,7 @@ CONFIG_FEATURE_ICON=y # CONFIG_FEATURE_ICON_STERM is not set CONFIG_FEATURE_ICON_ALL=y CONFIG_FEATURE_EURO=y +CONFIG_SKIP_ANSI_EMULATION_DEFAULT=2 CONFIG_FEATURE_EXTRA_FILE_DATA=y CONFIG_FEATURE_READLINK2=y diff --git a/win32/winansi.c b/win32/winansi.c index 3767e7534..59292efc3 100644 --- a/win32/winansi.c +++ b/win32/winansi.c @@ -68,19 +68,9 @@ int skip_ansi_emulation(int reset) if (skip < 0 || reset) { const char *var = getenv(bb_skip_ansi_emulation); - skip = var != NULL; - if (skip) { - switch (xatou(var)) { - case 1: - break; - case 2: - skip = 2; - break; - default: - skip = 0; - break; - } - } + skip = var == NULL ? CONFIG_SKIP_ANSI_EMULATION_DEFAULT : atoi(var); + if (skip < 0 || skip > 2) + skip = 0; if (is_console(STDOUT_FILENO)) { HANDLE h = get_console(); -- cgit v1.2.3-55-g6feb