From 757ed2dfe7bbefdbb9318fcb4025b50900dabe81 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sat, 20 Mar 2004 22:38:13 +0000 Subject: [PATCH] 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. --- simgear/debug/logstream.hxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 } /** -- 2.39.5