From 96c05cd53206465b79ebada3ed8e3f2bf0ea86c4 Mon Sep 17 00:00:00 2001 From: Dantali0n Date: Wed, 10 Jun 2015 20:48:05 +0200 Subject: [PATCH] Console window and output for windows --- src/CubicSDR.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index db696e6..1b1ee9c 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -1,7 +1,6 @@ #define OPENGL #include "CubicSDRDefs.h" - #include "wx/wxprec.h" #ifndef WX_PRECOMP @@ -21,6 +20,19 @@ IMPLEMENT_APP(CubicSDR) +// console output buffer for windows +#ifdef _WIN64_ +class outbuf : public std::streambuf { + public: + outbuf() { + setp(0, 0); + } + virtual int_type overflow(int_type c = traits_type::eof()) { + return fputc(c, stdout) == EOF ? traits_type::eof() : c; + } +}; +#endif + bool CubicSDR::OnInit() { #ifdef _OSX_APP_ CFBundleRef mainBundle = CFBundleGetMainBundle(); @@ -38,6 +50,17 @@ bool CubicSDR::OnInit() { return false; } + // console output for windows + #ifdef _WIN64_ + if (AllocConsole()) { + freopen("CONOUT$", "w", stdout); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); + } + outbuf ob; + std::streambuf *sb = std::cout.rdbuf(&ob); + std::cout.rdbuf(sb); + #endif + wxApp::SetAppName("CubicSDR"); config.load();