34 static void initWindowsColors()
42 winInkColors[
scrBlue ] = FOREGROUND_BLUE;
43 winInkColors[
scrRed ] = FOREGROUND_RED;
44 winInkColors[
scrMagenta ] = FOREGROUND_BLUE | FOREGROUND_RED;
45 winInkColors[
scrGreen ] = FOREGROUND_GREEN;
46 winInkColors[
scrCyan ] = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
47 winInkColors[
scrYellow ] = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
48 winInkColors[
scrWhite ] = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
52 winPaperColors[
scrBlue ] = BACKGROUND_BLUE;
53 winPaperColors[
scrRed ] = BACKGROUND_RED;
54 winPaperColors[
scrMagenta ] = BACKGROUND_BLUE | BACKGROUND_RED;
55 winPaperColors[
scrGreen ] = BACKGROUND_GREEN;
56 winPaperColors[
scrCyan ] = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
57 winPaperColors[
scrYellow ] = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
58 winPaperColors[
scrWhite ] = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED;
63 static const short int MaxCmdBuffer = 32;
65 static const char * CSI =
"\33[";
66 static const char * CmdClearScreen =
"2J";
67 static char cmd[MaxCmdBuffer];
75 static const short int UnixLastLine = 25;
76 static const short int UnixLastColumn = 80;
79 static void initUnixColors()
85 sprintf( cmdUnixInkColors[
scrBlack ],
"%s%s", CSI,
"30m" );
86 sprintf( cmdUnixInkColors[
scrBlue ],
"%s%s", CSI,
"34m" );
87 sprintf( cmdUnixInkColors[
scrRed ],
"%s%s", CSI,
"31m" );
88 sprintf( cmdUnixInkColors[
scrMagenta ],
"%s%s", CSI,
"35m" );
89 sprintf( cmdUnixInkColors[
scrGreen ],
"%s%s", CSI,
"32m" );
90 sprintf( cmdUnixInkColors[
scrCyan ],
"%s%s", CSI,
"36m" );
91 sprintf( cmdUnixInkColors[
scrYellow ],
"%s%s", CSI,
"93m" );
92 sprintf( cmdUnixInkColors[
scrWhite ],
"%s%s", CSI,
"37m" );
95 sprintf( cmdUnixPaperColors[
scrBlack ],
"%s%s", CSI,
"40m" );
96 sprintf( cmdUnixPaperColors[
scrBlue ],
"%s%s", CSI,
"44m" );
97 sprintf( cmdUnixPaperColors[
scrRed ],
"%s%s", CSI,
"41m" );
98 sprintf( cmdUnixPaperColors[
scrMagenta ],
"%s%s", CSI,
"45m" );
99 sprintf( cmdUnixPaperColors[
scrGreen ],
"%s%s", CSI,
"42m" );
100 sprintf( cmdUnixPaperColors[
scrCyan ],
"%s%s", CSI,
"46m" );
101 sprintf( cmdUnixPaperColors[
scrYellow ],
"%s%s", CSI,
"103m" );
102 sprintf( cmdUnixPaperColors[
scrWhite ],
"%s%s", CSI,
"47m" );
108 static bool inited =
false;
110 static inline void scrInit()
132 COORD pos = { 0, 0 };
134 HANDLE hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
135 CONSOLE_SCREEN_BUFFER_INFO csbi;
138 if( hStdOut != INVALID_HANDLE_VALUE
139 && GetConsoleScreenBufferInfo( hStdOut, &csbi ) )
141 dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
143 FillConsoleOutputCharacter(
151 FillConsoleOutputAttribute(
153 winPaperColors[ libAttrs.
paper ] | winInkColors[ libAttrs.
ink ],
161 strcat( cmd, CmdClearScreen );
173 libAttrs.
ink = colors.
ink;
176 SetConsoleTextAttribute(
177 GetStdHandle( STD_OUTPUT_HANDLE ),
178 winPaperColors[ libAttrs.
paper ] | winInkColors[ libAttrs.
ink ]
182 cmdUnixInkColors[ colors.
ink ],
183 cmdUnixPaperColors[ colors.
paper ]
213 SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), pos );
215 printf(
"%s%d;%dH", CSI, fila + 1, columna + 1 );
227 CONSOLE_SCREEN_BUFFER_INFO infoPantalla;
228 GetConsoleScreenBufferInfo(
229 GetStdHandle( STD_OUTPUT_HANDLE ), &infoPantalla
232 pos.
row = infoPantalla.srWindow.Bottom + 1;
233 pos.
column = infoPantalla.srWindow.Right + 1;
235 pos.
row = UnixLastLine;
236 pos.
column = UnixLastColumn;
266 CONSOLE_SCREEN_BUFFER_INFO infoPantalla;
267 GetConsoleScreenBufferInfo(
268 GetStdHandle( STD_OUTPUT_HANDLE ),
272 toret.
row = infoPantalla.dwCursorPosition.Y;
273 toret.
column = infoPantalla.dwCursorPosition.X;
287 CONSOLE_CURSOR_INFO info;
290 info.bVisible = (BOOL) see;
291 SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &info );
293 printf(
"%s?25%c", CSI, see ?
'h' :
'l' );