- // econio.cpp Définitions des fonctions
-
- #include <econio.h>
-
- static WORD bgcolor = BLACK;
- static WORD fgcolor = WHITE << 4;
- #define STDOUT GetStdHandle(STD_OUTPUT_HANDLE)
-
- void gotoxy( int x, int y ) // Place le curseur en x,y
- {
- COORD dwCursorPosition = { x, y };
- SetConsoleCursorPosition (STDOUT, dwCursorPosition);
- }
-
- int wherex( void ) // Renvoie la valeur de x
- {
- CONSOLE_SCREEN_BUFFER_INFO coninfo;
- GetConsoleScreenBufferInfo (STDOUT, &coninfo);
- return coninfo.dwCursorPosition.X;
- }
-
- int wherey( void ) // Renvoie la valeur de y
- {
- CONSOLE_SCREEN_BUFFER_INFO coninfo;
- GetConsoleScreenBufferInfo (STDOUT, &coninfo);
- return coninfo.dwCursorPosition.Y;
- }
-
- void textbackground( int newcolor ) // Change la couleur du texte
- {
- fgcolor = newcolor;
- SetConsoleTextAttribute (STDOUT, fgcolor | bgcolor);
- }
-
- void textcolor( int newcolor )
- {
- bgcolor = newcolor << 4;
- SetConsoleTextAttribute (STDOUT, fgcolor | bgcolor);
- }
-
- void setcursortype( int cur ) // type de curseur
- {
- BOOL visible = cur != NOCURSOR;
- CONSOLE_CURSOR_INFO CursorInfo = { cur, visible };
- SetConsoleCursorInfo (STDOUT, &CursorInfo);
- }
-
- void clrscr ( void ) // efface l'écran
- {
- HANDLE hstdout = STDOUT;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- if (GetConsoleScreenBufferInfo (hstdout, &csbi))
- {
- COORD coordScreen = { 0, 0 };
- DWORD cCharsWritten;
- DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
- FillConsoleOutputCharacter (hstdout, ' ', dwConSize, coordScreen, &cCharsWritten);
- FillConsoleOutputAttribute (hstdout, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
- SetConsoleCursorPosition (hstdout, coordScreen);
- }
- }
-
-
- // econio. h par Eric Teetz ( prototypes des fonctions )
-
- #ifndef ECONIO_H
- #define ECONIO_H
-
- #include <windows.h>
- #include <conio.h>
- enum CURSOR {
- NORMALCURSOR = 0,
- NOCURSOR = 100,
- SOLIDCURSOR = 20,
- };
-
- enum COLORS {
- BLACK = 0,
- BLUE = FOREGROUND_BLUE,
- GREEN = FOREGROUND_GREEN,
- CYAN = FOREGROUND_GREEN | FOREGROUND_BLUE,
- RED = FOREGROUND_RED,
- MAGENTA = FOREGROUND_RED | FOREGROUND_BLUE,
- BROWN = FOREGROUND_RED | FOREGROUND_GREEN,
- LIGHTGRAY = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
- DARKGRAY = FOREGROUND_INTENSITY,
- LIGHTBLUE = FOREGROUND_BLUE | FOREGROUND_INTENSITY,
- LIGHTGREEN = FOREGROUND_GREEN | FOREGROUND_INTENSITY,
- LIGHTCYAN = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
- LIGHTRED = FOREGROUND_RED | FOREGROUND_INTENSITY,
- LIGHTMAGENTA = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
- YELLOW = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY,
- WHITE = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
- };
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- void clrscr( void );
- void textbackground( int newcolor );
- void textcolor( int newcolor );
- void setcursortype( int cur );
- void gotoxy( int x, int y );
- int wherex( void );
- int wherey( void );
-
- #ifdef __cplusplus
- }
- #endif
- #endif /* ECONIO_H */
// econio.cpp Définitions des fonctions
#include <econio.h>
static WORD bgcolor = BLACK;
static WORD fgcolor = WHITE << 4;
#define STDOUT GetStdHandle(STD_OUTPUT_HANDLE)
void gotoxy( int x, int y ) // Place le curseur en x,y
{
COORD dwCursorPosition = { x, y };
SetConsoleCursorPosition (STDOUT, dwCursorPosition);
}
int wherex( void ) // Renvoie la valeur de x
{
CONSOLE_SCREEN_BUFFER_INFO coninfo;
GetConsoleScreenBufferInfo (STDOUT, &coninfo);
return coninfo.dwCursorPosition.X;
}
int wherey( void ) // Renvoie la valeur de y
{
CONSOLE_SCREEN_BUFFER_INFO coninfo;
GetConsoleScreenBufferInfo (STDOUT, &coninfo);
return coninfo.dwCursorPosition.Y;
}
void textbackground( int newcolor ) // Change la couleur du texte
{
fgcolor = newcolor;
SetConsoleTextAttribute (STDOUT, fgcolor | bgcolor);
}
void textcolor( int newcolor )
{
bgcolor = newcolor << 4;
SetConsoleTextAttribute (STDOUT, fgcolor | bgcolor);
}
void setcursortype( int cur ) // type de curseur
{
BOOL visible = cur != NOCURSOR;
CONSOLE_CURSOR_INFO CursorInfo = { cur, visible };
SetConsoleCursorInfo (STDOUT, &CursorInfo);
}
void clrscr ( void ) // efface l'écran
{
HANDLE hstdout = STDOUT;
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo (hstdout, &csbi))
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter (hstdout, ' ', dwConSize, coordScreen, &cCharsWritten);
FillConsoleOutputAttribute (hstdout, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition (hstdout, coordScreen);
}
}
// econio. h par Eric Teetz ( prototypes des fonctions )
#ifndef ECONIO_H
#define ECONIO_H
#include <windows.h>
#include <conio.h>
enum CURSOR {
NORMALCURSOR = 0,
NOCURSOR = 100,
SOLIDCURSOR = 20,
};
enum COLORS {
BLACK = 0,
BLUE = FOREGROUND_BLUE,
GREEN = FOREGROUND_GREEN,
CYAN = FOREGROUND_GREEN | FOREGROUND_BLUE,
RED = FOREGROUND_RED,
MAGENTA = FOREGROUND_RED | FOREGROUND_BLUE,
BROWN = FOREGROUND_RED | FOREGROUND_GREEN,
LIGHTGRAY = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
DARKGRAY = FOREGROUND_INTENSITY,
LIGHTBLUE = FOREGROUND_BLUE | FOREGROUND_INTENSITY,
LIGHTGREEN = FOREGROUND_GREEN | FOREGROUND_INTENSITY,
LIGHTCYAN = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
LIGHTRED = FOREGROUND_RED | FOREGROUND_INTENSITY,
LIGHTMAGENTA = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
YELLOW = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY,
WHITE = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
};
#ifdef __cplusplus
extern "C" {
#endif
void clrscr( void );
void textbackground( int newcolor );
void textcolor( int newcolor );
void setcursortype( int cur );
void gotoxy( int x, int y );
int wherex( void );
int wherey( void );
#ifdef __cplusplus
}
#endif
#endif /* ECONIO_H */