45 #ifndef XEMU_HAS_READLINE
46 #error "We need libreadline for this target/platform, but XEMU_HAS_READLINE is not defined. Maybe libreadline cannot be detected?"
48 #include <readline/readline.h>
49 #include <readline/history.h>
55 static int ok_for_monitor = 0;
56 static volatile int monitor_running = 0;
57 static SDL_Thread *mont = NULL;
68 static int console_monitor_thread (
void *ptr )
70 printf(
"Welcome to " WINDOW_TITLE " monitor. Use \"help\" for help" NL);
71 while (monitor_running) {
76 p = fgets(buffer,
sizeof buffer, stdin);
96 printf(
"MONITOR: thread is about to exit" NL);
108 mont = SDL_CreateThread(console_monitor_thread,
WINDOW_TITLE " monitor", NULL);
118 if (!monitor_running)
123 printf(
NL NL "*** PRESS ENTER TO EXIT ***" NL);
126 SDL_WaitThread(mont, &ret);
128 DEBUGPRINT(
"MONITOR: thread joined, status code is %d" NL, ret);
140 CONSOLE_SCREEN_BUFFER_INFO coninfo;
146 if (!AllocConsole()) {
152 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
153 coninfo.dwSize.Y = 1024;
155 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
157 lStdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
158 hConHandle = _open_osfhandle((INT_PTR)lStdHandle, _O_TEXT);
159 fp = _fdopen( hConHandle,
"w" );
161 setvbuf( stdout, NULL, _IONBF, 0 );
163 lStdHandle = GetStdHandle(STD_INPUT_HANDLE);
164 hConHandle = _open_osfhandle((INT_PTR)lStdHandle, _O_TEXT);
165 fp = _fdopen( hConHandle,
"r" );
167 setvbuf( stdin, NULL, _IONBF, 0 );
169 lStdHandle = GetStdHandle(STD_ERROR_HANDLE);
170 hConHandle = _open_osfhandle((INT_PTR)lStdHandle, _O_TEXT);
171 fp = _fdopen( hConHandle,
"w" );
173 setvbuf( stderr, NULL, _IONBF, 0 );
178 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_INTENSITY);
179 SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
180 SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT);