#include "emul_io_std.h" static int debug_level = 0; void emul_std_debug(int level) { debug_level = level; } static WINDOW *win; static SCREEN *scr[2]; SCREEN* emul_getScr(int i) { return scr[i]; } WINDOW* emul_getWin() { return win; } void emul_std_init() { scr[1] = newterm("xterm", stdout, stdin); endwin(); scr[0] = newterm("xterm", stdout, stdin); win = stdscr; scrollok(win, TRUE); refresh(); } void emul_std_end() { endwin(); } //void emul_out_std(char c) { // putchar(c); //} //void emul_out_std(char *str) { // printf("%s", str); //} void emul_out_std(const char *format, ...) { if ( debug_level != 0 ) printw("[Output] "); va_list va; va_start(va, format); vwprintw(win, format, va); refresh(); va_end(va); } //void emul_out_std_err(char c) { // printf("[Except] %c", c); //} //void emul_out_std_err(char *str) { // printf("[Except] %s", str); //} void emul_out_std_err(const char *format, ...) { if ( debug_level <= 1 ) return ; va_list va; va_start(va, format); printw("[Except] "); vwprintw(win, format, va); refresh(); va_end(va); } //void emul_out_std_debug(char c) { // printf("[Debug] %c", c); //} //void emul_out_std_debug(char *str) { // printf("[Debug] %str", str); //} void emul_out_std_debug(const char *format, ...) { if ( debug_level <= 0 ) return ; va_list va; va_start(va, format); printw("[Debug] "); vwprintw(win, format, va); refresh(); va_end(va); } char emul_cin_std() { return getchar(); }