[MPlayer-dev-eng] [PATCH] Runtime colorful and/or module name output control
- Date: Tue, 1 Apr 2008 17:27:10 +0800
- From: "Zuxy Meng" <zuxy.meng@xxxxxxxxx>
- Subject: [MPlayer-dev-eng] [PATCH] Runtime colorful and/or module name output control
Hi,
The attached patch enables runtime control over colorful and/or module
names output, instead of a configure time parameter. Color and module
names are orthogonal features now; you can enable either or both.
--
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
Index: configure
===================================================================
--- configure £¨°æ±¾ 26311£©
+++ configure £¨¹¤×÷¸±±¾£©
@@ -411,7 +411,6 @@
\$LINGUAS is also honored) [en]
(Available: $LANGUAGES all)
--with-install=PATH path to a custom install program
- --enable-color-console enable color console output (UNSUPPORTED) [disable]
Advanced options:
--enable-mmx enable MMX [autodetect]
@@ -1118,8 +1117,6 @@
--disable-ass) _ass=no ;;
--enable-rpath) _rpath=yes ;;
--disable-rpath) _rpath=no ;;
- --enable-color-console) _color_console=yes ;;
- --disable-color-console) _color_console=no ;;
--enable-fribidi) _fribidi=yes ;;
--disable-fribidi) _fribidi=no ;;
Index: mp_msg.c
===================================================================
--- mp_msg.c £¨°æ±¾ 26311£©
+++ mp_msg.c £¨¹¤×÷¸±±¾£©
@@ -30,6 +30,8 @@
int mp_msg_levels[MSGT_MAX]; // verbose level of this module. initialized to -2
int mp_msg_level_all = MSGL_STATUS;
int verbose = 0;
+int mp_msg_color = 0;
+int mp_msg_mod = 0;
#ifdef USE_ICONV
char *mp_msg_charset = NULL;
static char *old_charset = NULL;
@@ -89,6 +91,7 @@
void mp_msg(int mod, int lev, const char *format, ... ){
va_list va;
char tmp[MSGSIZE_MAX];
+ FILE *stream= (lev) <= MSGL_WARN ? stderr : stdout;
if (!mp_msg_test(mod, lev)) return; // do not display
va_start(va, format);
@@ -133,7 +136,6 @@
}
#endif
-#ifdef MSG_USE_COLORS
/* that's only a silly color test */
#ifdef MP_ANNOY_ME
{ int c;
@@ -197,18 +199,19 @@
int c=v_colors[lev];
int c2=(mod+1)%15+1;
static int header=1;
- FILE *stream= (lev) <= MSGL_WARN ? stderr : stdout;
- if(header){
- fprintf(stream, "\033[%d;3%dm%9s\033[0;37m: ",c2>>3,c2&7, mod_text[mod]);
+ if(mp_msg_mod && header){
+ if (mp_msg_color)
+ fprintf(stream, "\033[%d;3%dm", c2>>3, c2&7);
+ fprintf(stream, "%9s", mod_text[mod]);
+ if (mp_msg_color)
+ fprintf(stream, "\033[0;37m");
+ fprintf(stream, ": ");
}
- fprintf(stream, "\033[%d;3%dm",c>>3,c&7);
+ if (mp_msg_color)
+ fprintf(stream, "\033[%d;3%dm",c>>3,c&7);
header= tmp[strlen(tmp)-1] == '\n'
||tmp[strlen(tmp)-1] == '\r';
}
-#endif
- if (lev <= MSGL_WARN){
- fprintf(stderr, "%s", tmp);fflush(stderr);
- } else {
- printf("%s", tmp);fflush(stdout);
- }
+ fprintf(stream, "%s", tmp);
+ fflush(stream);
}
Index: cfg-common.h
===================================================================
--- cfg-common.h £¨°æ±¾ 26311£©
+++ cfg-common.h £¨¹¤×÷¸±±¾£©
@@ -9,6 +9,8 @@
{"really-quiet", &verbose, CONF_TYPE_FLAG, CONF_GLOBAL, 0, -10, NULL},
{"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL},
{"msglevel", msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+ {"msgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
+ {"msgmod", &mp_msg_mod, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
#ifdef USE_ICONV
{"msgcharset", &mp_msg_charset, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
#endif
@@ -344,6 +346,8 @@
#include "config.h"
extern char *mp_msg_charset;
+extern int mp_msg_color;
+extern int mp_msg_mod;
// codec/filter opts: (defined at libmpcodecs/vd.c)
extern float screen_size_xy;
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng