[PATCH 1/3] log: allow color highlighting in Cygwin's mintty
Configure will detect the availability of the Windows' console functions and set HAVE_SETCONSOLETEXTATTRIBUTE. Meaning av_log will use those functions to control colours. When ffmpeg is run in Cygwin's mintty terminal emulator it will not use colour highlighting in this case. Mintty responds to the usual escape code colours (it even supports 256 colours). Windows' cmd.exe does not. Fortunately it seems that Cygwin's emulation layer now translates the basic 16 colours into Windows' Console command functions. That means that we can have av_log use the standard colour commands and let ffmpeg print colours in both mintty and cmd. --- libavutil/log.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/log.c b/libavutil/log.c index 4cceffc..32e1ba7 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -50,7 +50,7 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static int av_log_level = AV_LOG_INFO; static int flags; -#if HAVE_SETCONSOLETEXTATTRIBUTE +#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE #include <windows.h> static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = { [AV_LOG_PANIC /8] = 12, @@ -115,7 +115,7 @@ static int use_color = -1; static void check_color_terminal(void) { -#if HAVE_SETCONSOLETEXTATTRIBUTE +#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE CONSOLE_SCREEN_BUFFER_INFO con_info; con = GetStdHandle(STD_ERROR_HANDLE); use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && @@ -146,7 +146,7 @@ static void colored_fputs(int level, int tint, const char *str) if (use_color < 0) check_color_terminal(); -#if HAVE_SETCONSOLETEXTATTRIBUTE +#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE if (use_color && level != AV_LOG_INFO/8) SetConsoleTextAttribute(con, background | color[level]); fputs(str, stderr); -- 1.7.9
On Fri, Apr 04, 2014 at 12:45:29AM +0200, James Darnley wrote:
Configure will detect the availability of the Windows' console functions and set HAVE_SETCONSOLETEXTATTRIBUTE. Meaning av_log will use those functions to control colours. When ffmpeg is run in Cygwin's mintty terminal emulator it will not use colour highlighting in this case.
Mintty responds to the usual escape code colours (it even supports 256 colours). Windows' cmd.exe does not. Fortunately it seems that Cygwin's emulation layer now translates the basic 16 colours into Windows' Console command functions.
That means that we can have av_log use the standard colour commands and let ffmpeg print colours in both mintty and cmd. --- libavutil/log.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
applied i suggest to factorize the proprocessor conditions though so the same check isnt repeated multiple times, risking that they become mismatching each other at some point in th efuture [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The misfortune of the wise is better than the prosperity of the fool. -- Epicurus
participants (2)
-
James Darnley -
Michael Niedermayer