gconio.h -- Incompatibility is over!
Introduction
gconio.h was written to be a replacement library for Borland C-specific conio.h functions for the GNU C Compiler. Later on, more code was added to make the library compatible with Microsoft Visual C. In the latest version, more functions and aliases have been added to make sure all code snippets from the C courses at the Erasmus Hogeschool Brussel work in both the GNU C Compiler and Microsoft Visual C.
About the Authors
Nearly all code in gconio.h was written by Wence Van der Meersch <wence AT i-vision DOT be> and Filip Duyck <filip AT factor9 DOT be>. Portions of the code added for Microsoft Visual C compatibility were written by Sebastien Boelpaep <sebastien@pi.be>, as outlined in the gconio.h source code.
License
gconio.h is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
gconio.h is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.
Download
gconio.h v0.5 can be downloaded here.
Installation
Copy the gconio.h file to your compiler's include directory (defaults: "C:\Program
Files\Microsoft Visual Studio\VC98\Include" for MSVC6, "/usr/include" for GCC)
and include using #include <gconio.h>
Function overview
- void box (int x, int y, int length,
int height, int type);
void kader (int x, int y, int length,
int height, int type);
Draws a box. x and
y are the coordinates
of the upper left corner, type
is the line style.
- void clrscr (void);
Clears the screen.
- void delay (unsigned long milliseconds);
Pauses the control flow.
- void delline (void);
Deletes all characters from the current location to the end of the current line, and then
returns to the first character of the line.
- void flushall (void); (only for GCC)
Flushes the input, output and error buffers.
- int get_screen_rows (void);
Returns the number of rows in the current console.
- int get_screen_columns (void);
Returns the number of columns in the current console.
- int getch (void); (only for GCC)
Reads a character from the keyboard buffer without echoing it
to the console.
- int getche (void);
(only for GCC)
Same as getch(), but prints
the character to the console.
- void gotoxy (int x, int y);
Changes the cursor position on the console.
- void lineh (int x, int y, int
length, int character);
void lijnh (int x, int y, int
length, int character);
Draws a horizontal line. Parameters are the same as box().
character is the
character to build the line with.
- void linev (int x, int y, int
length, int character);
void lijnv (int x, int y, int
length, int character);
Draws a vertical line. Parameters are the same as lineh().
- void setcursortype (int type);
(only for MSVC)
Changes the cursor type. Look in source code for type :)
- char *strlwr (char *text);
(only for GCC)
Converts a string to lowercase.
- char *strupr (char *text);
(only for GCC)
Converts a string to uppercase.
- void textbackground (int newcolor);
Sets the text background color. See notes.
- void textcolor (int newcolor);
Sets the text color. See notes.
- int wherex (void);
(only for MSVC)
Returns the x coordinate of the current position of the cursor in the console.
- int wherey (void);
(only for MSVC)
Returns the y coordinate of the current position of the cursor in the console.
Notes
- Topleftmost coordinate is always (0, 0).
- When using color functions, you must use the supplied color constants
(BLACK, BLUE, GREEN, CYAN, RED, MAGENTA,
BROWN, LIGHTGREY, DARKGREY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA,
YELLOW, WHITE).
- Some functions are labeled 'only for [compiler]'. This doesn't imply the
function is not available. Functions such as strupr(),
strlwr(), getch(),
getch(), ... are
already available in MSVC. gconio.h includes the necessairy .h files to use
them.
Copyright
gconio.h is (c) copyright 2002-2003 Wence Van der Meersch and Filip Duyck.