mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 12:16:30 +01:00
Use shared windows-console setup code
This commit is contained in:
parent
25bd4b8ec7
commit
f386d1334a
1 changed files with 1 additions and 63 deletions
|
|
@ -43,6 +43,7 @@
|
||||||
#include "pbd/failed_constructor.h"
|
#include "pbd/failed_constructor.h"
|
||||||
#include "pbd/pathexpand.h"
|
#include "pbd/pathexpand.h"
|
||||||
#include "pbd/pthread_utils.h"
|
#include "pbd/pthread_utils.h"
|
||||||
|
#include "pbd/win_console.h"
|
||||||
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
|
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
|
||||||
#include "pbd/boost_debug.h"
|
#include "pbd/boost_debug.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -186,71 +187,10 @@ sigpipe_handler (int /*signal*/)
|
||||||
|
|
||||||
#if (!defined COMPILER_MSVC && defined PLATFORM_WINDOWS)
|
#if (!defined COMPILER_MSVC && defined PLATFORM_WINDOWS)
|
||||||
|
|
||||||
static FILE* pStdOut = 0;
|
|
||||||
static FILE* pStdErr = 0;
|
|
||||||
static BOOL bConsole;
|
|
||||||
static HANDLE hStdOut;
|
|
||||||
|
|
||||||
static bool
|
|
||||||
IsAConsolePort (HANDLE handle)
|
|
||||||
{
|
|
||||||
DWORD mode;
|
|
||||||
return (GetConsoleMode(handle, &mode) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
console_madness_begin ()
|
|
||||||
{
|
|
||||||
bConsole = AttachConsole(ATTACH_PARENT_PROCESS);
|
|
||||||
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
|
|
||||||
/* re-attach to the console so we can see 'printf()' output etc.
|
|
||||||
* for MSVC see gtk2_ardour/msvc/winmain.cc
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((bConsole) && (IsAConsolePort(hStdOut))) {
|
|
||||||
pStdOut = freopen( "CONOUT$", "w", stdout );
|
|
||||||
pStdErr = freopen( "CONOUT$", "w", stderr );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
console_madness_end ()
|
|
||||||
{
|
|
||||||
if (pStdOut) {
|
|
||||||
fclose (pStdOut);
|
|
||||||
}
|
|
||||||
if (pStdErr) {
|
|
||||||
fclose (pStdErr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bConsole) {
|
|
||||||
// Detach and free the console from our application
|
|
||||||
INPUT_RECORD input_record;
|
|
||||||
|
|
||||||
input_record.EventType = KEY_EVENT;
|
|
||||||
input_record.Event.KeyEvent.bKeyDown = TRUE;
|
|
||||||
input_record.Event.KeyEvent.dwControlKeyState = 0;
|
|
||||||
input_record.Event.KeyEvent.uChar.UnicodeChar = VK_RETURN;
|
|
||||||
input_record.Event.KeyEvent.wRepeatCount = 1;
|
|
||||||
input_record.Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
|
|
||||||
input_record.Event.KeyEvent.wVirtualScanCode = MapVirtualKey( VK_RETURN, 0 );
|
|
||||||
|
|
||||||
DWORD written = 0;
|
|
||||||
WriteConsoleInput( GetStdHandle( STD_INPUT_HANDLE ), &input_record, 1, &written );
|
|
||||||
|
|
||||||
FreeConsole();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void command_line_parse_error (int *argc, char** argv[]) {}
|
static void command_line_parse_error (int *argc, char** argv[]) {}
|
||||||
|
|
||||||
#elif (defined(COMPILER_MSVC) && defined(NDEBUG) && !defined(RDC_BUILD))
|
#elif (defined(COMPILER_MSVC) && defined(NDEBUG) && !defined(RDC_BUILD))
|
||||||
|
|
||||||
// these are not used here. for MSVC see gtk2_ardour/msvc/winmain.cc
|
|
||||||
static void console_madness_begin () {}
|
|
||||||
static void console_madness_end () {}
|
|
||||||
|
|
||||||
static void command_line_parse_error (int *argc, char** argv[]) {
|
static void command_line_parse_error (int *argc, char** argv[]) {
|
||||||
// Since we don't ordinarily have access to stdout and stderr with
|
// Since we don't ordinarily have access to stdout and stderr with
|
||||||
// an MSVC app, let the user know we encountered a parsing error.
|
// an MSVC app, let the user know we encountered a parsing error.
|
||||||
|
|
@ -263,8 +203,6 @@ static void command_line_parse_error (int *argc, char** argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static void console_madness_begin () {}
|
|
||||||
static void console_madness_end () {}
|
|
||||||
static void command_line_parse_error (int *argc, char** argv[]) {}
|
static void command_line_parse_error (int *argc, char** argv[]) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue