From: ehofman Date: Sat, 20 Mar 2004 22:38:13 +0000 (+0000) Subject: Frederic Bouvier: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=757ed2dfe7bbefdbb9318fcb4025b50900dabe81;p=simgear.git Frederic Bouvier: This patch is for windows only. It hides the console window until there is a message to print. It only support SG_LOG, that I think is the right way to display something in FG. --- diff --git a/simgear/debug/logstream.hxx b/simgear/debug/logstream.hxx index 12c2dfee..4546a5e1 100644 --- a/simgear/debug/logstream.hxx +++ b/simgear/debug/logstream.hxx @@ -28,6 +28,10 @@ #include +#ifdef _MSC_VER +# include +#endif + #ifdef SG_HAVE_STD_INCLUDES # include # include @@ -180,7 +184,23 @@ logbuf::set_log_state( sgDebugClass c, sgDebugPriority p ) inline logbuf::int_type logbuf::overflow( int c ) { +#ifdef _MSC_VER + static has_console = false; + if ( logging_enabled ) { + if ( !has_console ) { + AllocConsole(); + freopen("conin$", "r", stdin); + freopen("conout$", "w", stdout); + freopen("conout$", "w", stderr); + has_console = true; + } + sbuf->sputc(c); + } + else + return EOF == 0 ? 1: 0; +#else return logging_enabled ? sbuf->sputc(c) : (EOF == 0 ? 1: 0); +#endif } /**