diff --git a/conio.h b/conio.h index 8c66d3a..dce8af2 100644 --- a/conio.h +++ b/conio.h @@ -53,30 +53,30 @@ #endif /* Esc[2JEsc[1;1H - Clear screen and move cursor to 1,1 (upper left) pos. */ -#define clrscr() fputs ("\033[2J\033[1;1H", stdout) +#define clrscr() fputs ("\033[2J\033[1;1H", stderr) /* Esc[K - Erases from the current cursor position to the end of the current line. */ -#define clreol() fputs ("\033[K", stdout) +#define clreol() fputs ("\033[K", stderr) /* Esc[2K - Erases the entire current line. */ -#define delline() fputs ("\033[2K", stdout) +#define delline() fputs ("\033[2K", stderr) /* Esc[Line;ColumnH - Moves the cursor to the specified position (coordinates) */ -#define gotoxy(x,y) printf("\033[%d;%dH", y, x) +#define gotoxy(x,y) fprintf(stderr, "\033[%d;%dH", y, x) /* Esc[?25l (lower case L) - Hide Cursor */ -#define hidecursor() fputs ("\033[?25l", stdout) +#define hidecursor() fputs ("\033[?25l", stderr) /* Esc[?25h (lower case H) - Show Cursor */ -#define showcursor() fputs ("\033[?25h", stdout) +#define showcursor() fputs ("\033[?25h", stderr) -/* Esc[Value;...;Valuem - Set Graphics Mode */ -#define __set_gm(attr,color,val) \ - if (!color) \ - printf("\033[%dm", attr); \ +/* Esc[Value;...;Valuem - Set Graphics Mode (attr, color, val) */ +#define __set_gm(a,c,v) \ + if (!c) \ + fprintf(stderr, "\033[%dm", a); \ else \ - printf("\033[%d;%dm", color & 0x10 ? 1 : 0, (color & 0xF) + val) + fprintf(stderr, "\033[%d;%dm", c & 0x10 ? 1 : 0, (c & 0xF) + v) #define textattr(attr) __set_gm(attr, 0, 0) #define textcolor(color) __set_gm(RESETATTR, color, 30) #define textbackground(color) __set_gm(RESETATTR, color, 40) #define printheader(fp, line, nl) \ - fprintf(fp ?: stdout, "%s\033[7m%s%*s\033[0m\n", nl ? "\n" : "",\ + fprintf(fp ?: stderr, "%s\033[7m%s%*s\033[0m\n", nl ? "\n" : "",\ line, SCREEN_WIDTH - (int)strlen(line), "") #endif /* CONIO_H_ */