Console window and output for windows

This commit is contained in:
Dantali0n 2015-06-10 20:48:05 +02:00
parent 951a1ee9c6
commit 96c05cd532

View File

@ -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();