rlutil.h | |
Description | This file provides some useful utilities for console mode roguelike game development with C and C++. |
Copyright | © 2010 Tapio Vierros |
Licensing | See License |
Macros | |
RLUTIL_USE_ANSI | Define this to use ANSI escape sequences also on Windows (defaults to using WinAPI instead). |
RLUTIL_STRING_T | Define/typedef this to your preference to override rlutil’s string type. |
Functions | |
getch | Get character without waiting for Return to be pressed. |
kbhit | Determines if keyboard has been hit. |
gotoxy | Same as rlutil.locate. |
rlutil | In C++ all functions except getch, kbhit and gotoxy are arranged under namespace rlutil. |
Macros | |
Internal typedefs and macros | |
Enumerations | |
Color codes | |
Constants | |
ANSI color strings | |
Key codes for keyhit() | |
Functions | |
getkey | Reads a key press (blocking) and returns a key code. |
nb_getch | Non-blocking getch(). |
getANSIColor | Return ANSI color escape sequence for specified number 0-15. |
setColor | Change color specified by number (Windows / QBasic colors). |
cls | Clears screen and moves cursor home. |
locate | Sets the cursor position to 1-based x,y. |
hidecursor | Hides the cursor. |
showcursor | Shows the cursor. |
msleep | Waits given number of milliseconds before continuing. |
trows | Get the number of rows in the terminal window or -1 on error. |
tcols | Get the number of columns in the terminal window or -1 on error. |
anykey | Waits until a key is pressed. |
min | Returns the lesser of the two arguments. |
max | Returns the greater of the two arguments. |
CursorHider | RAII OOP wrapper for rlutil.hidecursor. |
See License
inline void gotoxy( int x, int y )
Same as rlutil.locate.
namespace rlutil
In C++ all functions except getch, kbhit and gotoxy are arranged under namespace rlutil. That is because some platforms have them defined outside of rlutil.
Macros | |
Internal typedefs and macros | |
Enumerations | |
Color codes | |
Constants | |
ANSI color strings | |
Key codes for keyhit() | |
Functions | |
getkey | Reads a key press (blocking) and returns a key code. |
nb_getch | Non-blocking getch(). |
getANSIColor | Return ANSI color escape sequence for specified number 0-15. |
setColor | Change color specified by number (Windows / QBasic colors). |
cls | Clears screen and moves cursor home. |
locate | Sets the cursor position to 1-based x,y. |
hidecursor | Hides the cursor. |
showcursor | Shows the cursor. |
msleep | Waits given number of milliseconds before continuing. |
trows | Get the number of rows in the terminal window or -1 on error. |
tcols | Get the number of columns in the terminal window or -1 on error. |
anykey | Waits until a key is pressed. |
min | Returns the lesser of the two arguments. |
max | Returns the greater of the two arguments. |
RLUTIL_STRING_T getANSIColor( const int c )
Return ANSI color escape sequence for specified number 0-15.
See Color Codes
inline void setColor( int c )
Change color specified by number (Windows / QBasic colors).
See Color Codes
struct CursorHider
RAII OOP wrapper for rlutil.hidecursor. Hides the cursor and shows it again when the object goes out of scope.
Get character without waiting for Return to be pressed.
int getch( void )
Determines if keyboard has been hit.
int kbhit( void )
Same as rlutil.locate.
inline void gotoxy( int x, int y )
Sets the cursor position to 1-based x,y.
void locate( int x, int y )
In C++ all functions except getch, kbhit and gotoxy are arranged under namespace rlutil.
namespace rlutil
Reads a key press (blocking) and returns a key code.
int getkey( void )
Non-blocking getch().
inline int nb_getch( void )
Return ANSI color escape sequence for specified number 0-15.
RLUTIL_STRING_T getANSIColor( const int c )
Change color specified by number (Windows / QBasic colors).
inline void setColor( int c )
Clears screen and moves cursor home.
inline void cls( void )
Hides the cursor.
inline void hidecursor( void )
Shows the cursor.
inline void showcursor( void )
Waits given number of milliseconds before continuing.
inline void msleep( unsigned int ms )
Get the number of rows in the terminal window or -1 on error.
int trows( void )
Get the number of columns in the terminal window or -1 on error.
int tcols( void )
Waits until a key is pressed.
inline void anykey( void )
Returns the lesser of the two arguments.
#ifdef __cplusplus template <class T> const T& min ( const T & a, const T & b )
Returns the greater of the two arguments.
#ifdef __cplusplus template <class T> const T& max ( const T & a, const T & b )
RAII OOP wrapper for rlutil.hidecursor.
struct CursorHider