From 0f4f09c597f599c802d2d496c22e2d904f1b2d20 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Fri, 10 Sep 2021 20:09:01 -0500 Subject: [PATCH] GUI: Enable console to stdio on macOS --- common/Console.cpp | 6 +++--- common/Console.h | 2 +- pcsx2/gui/ConsoleLogger.cpp | 6 +++--- pcsx2/gui/MainFrame.cpp | 8 ++++---- pcsx2/gui/MainFrame.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/Console.cpp b/common/Console.cpp index f64f735d80..de0e50e571 100644 --- a/common/Console.cpp +++ b/common/Console.cpp @@ -99,7 +99,7 @@ const IConsoleWriter ConsoleWriter_Null = // Console_Stdout // -------------------------------------------------------------------------------------- -#if defined(__unix__) +#if defined(__POSIX__) static __fi const char* GetLinuxConsoleColor(ConsoleColors color) { switch (color) @@ -176,7 +176,7 @@ static void __concall ConsoleStdout_Newline() static void __concall ConsoleStdout_DoSetColor(ConsoleColors color) { -#if defined(__unix__) +#if defined(__POSIX__) fprintf(stdout_fp, "\033[0m%s", GetLinuxConsoleColor(color)); fflush(stdout_fp); #endif @@ -184,7 +184,7 @@ static void __concall ConsoleStdout_DoSetColor(ConsoleColors color) static void __concall ConsoleStdout_SetTitle(const wxString& title) { -#if defined(__unix__) +#if defined(__POSIX__) fputs("\033]0;", stdout_fp); fputs(title.utf8_str(), stdout_fp); fputs("\007", stdout_fp); diff --git a/common/Console.h b/common/Console.h index 18d25d7632..0a30f6c716 100644 --- a/common/Console.h +++ b/common/Console.h @@ -234,7 +234,7 @@ public: extern IConsoleWriter Console; -#if defined(__unix__) || defined(__APPLE__) +#if defined(__POSIX__) extern void Console_SetStdout(FILE* fp); #endif extern void Console_SetActiveHandler(const IConsoleWriter& writer, FILE* flushfp = NULL); diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index 44e169d037..7fe0ad5f6c 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -1071,11 +1071,11 @@ void Pcsx2App::ProgramLog_PostEvent( wxEvent& evt ) static void __concall ConsoleToFile_Newline() { -#if defined(__unix__) +#if defined(__POSIX__) if ((g_Conf) && (g_Conf->EmuOptions.ConsoleToStdio)) ConsoleWriter_Stdout.Newline(); #endif -#if defined(__unix__) +#if defined(__POSIX__) fputc( '\n', emuLog ); #else fputs( "\r\n", emuLog ); @@ -1084,7 +1084,7 @@ static void __concall ConsoleToFile_Newline() static void __concall ConsoleToFile_DoWrite( const wxString& fmt ) { -#if defined(__unix__) +#if defined(__POSIX__) if ((g_Conf) && (g_Conf->EmuOptions.ConsoleToStdio)) ConsoleWriter_Stdout.WriteRaw(fmt); #endif diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index cd5731cc42..cfdd4eb6f8 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -293,7 +293,7 @@ void MainEmuFrame::ConnectMenus() // Misc Bind(wxEVT_MENU, &MainEmuFrame::Menu_ShowConsole, this, MenuId_Console); -#if defined(__unix__) +#if defined(__POSIX__) Bind(wxEVT_MENU, &MainEmuFrame::Menu_ShowConsole_Stdio, this, MenuId_Console_Stdio); #endif @@ -475,7 +475,7 @@ void MainEmuFrame::CreateWindowsMenu() #endif m_menuWindow.Append(&m_MenuItem_Console); -#if defined(__unix__) +#if defined(__POSIX__) m_menuWindow.AppendSeparator(); m_menuWindow.Append(&m_MenuItem_Console_Stdio); #endif @@ -574,7 +574,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) , m_GameSettingsSubmenu(*new wxMenu()) , m_MenuItem_Console(*new wxMenuItem(&m_menuWindow, MenuId_Console, _("&Show Program Log"), wxEmptyString, wxITEM_CHECK)) -#if defined(__unix__) +#if defined(__POSIX__) , m_MenuItem_Console_Stdio(*new wxMenuItem(&m_menuWindow, MenuId_Console_Stdio, _("&Program Log to Stdio"), wxEmptyString, wxITEM_CHECK)) #endif @@ -830,7 +830,7 @@ void MainEmuFrame::ApplyConfigToGui(AppConfig& configToApply, int flags) #endif menubar.Check(MenuId_EnableHostFs, configToApply.EmuOptions.HostFs); menubar.Check(MenuId_Debug_CreateBlockdump, configToApply.EmuOptions.CdvdDumpBlocks); -#if defined(__unix__) +#if defined(__POSIX__) menubar.Check(MenuId_Console_Stdio, configToApply.EmuOptions.ConsoleToStdio); #endif diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index 6b0839e902..e7552f1335 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -85,7 +85,7 @@ protected: wxMenuItem* m_menuItem_RecentIsoMenu; wxMenuItem* m_menuItem_DriveListMenu; wxMenuItem& m_MenuItem_Console; -#if defined(__unix__) +#if defined(__POSIX__) wxMenuItem& m_MenuItem_Console_Stdio; #endif