int PL_w32_wrap_ansi_console(void) { HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); HANDLE hError = GetStdHandle(STD_ERROR_HANDLE); CONSOLE_SCREEN_BUFFER_INFO info; if ( hIn == INVALID_HANDLE_VALUE || hOut == INVALID_HANDLE_VALUE || hError == INVALID_HANDLE_VALUE || !GetConsoleScreenBufferInfo(hOut, &info) ) return FALSE; saved_functions = Sinput->functions; con_functions = *Sinput->functions; con_functions.read = Sread_win32_console; con_functions.write = write_ansi; con_functions.close = close_ansi; con_functions.control = control_ansi; con_functions.seek = NULL; wrap_console(hIn, Sinput, &con_functions); wrap_console(hOut, Soutput, &con_functions); wrap_console(hError, Serror, &con_functions); init_output(Soutput->handle, &info); init_output(Serror->handle, &info); PL_set_prolog_flag("tty_control", PL_BOOL, TRUE); return TRUE; }
static void set_quit_events (struct console *con, Lisp_Object key) { /* Make sure to run Fcharacter_to_event() *BEFORE* setting QUIT_CHAR, so that nothing is changed when invalid values trigger an error! */ con->quit_event = Fcharacter_to_event (key, Qnil, wrap_console (con), Qnil); con->quit_char = key; con->critical_quit_event = Fcopy_event (con->quit_event, Qnil); upshift_event (con->critical_quit_event); }