GClasses
GClasses::GPassiveConsole Class Reference

Detailed Description

This class provides a non-blocking method for reading characters from stdin. (If there are no characters ready in stdin, it immediately returns '\0'.) The constructor sets flags on the console so that it passes characters to the stream immediately (instead of when Enter is pressed), and so that it doesn't echo the keys (if desired), and it makes stdin non-blocking. The destructor puts all those things back the way they were.

#include <GApp.h>

Public Member Functions

 GPassiveConsole (bool echo)
 If echo is true, then keys pressed will be echoed to the screen. More...
 
 ~GPassiveConsole ()
 
char getChar ()
 Returns the char of the next key that was pressed. (This method does not block.) If no keys have been pressed, it returns the zero char. More...
 

Protected Attributes

struct termios m_old
 
int m_oldStreamFlags
 
int m_stdin
 

Constructor & Destructor Documentation

GClasses::GPassiveConsole::GPassiveConsole ( bool  echo)

If echo is true, then keys pressed will be echoed to the screen.

GClasses::GPassiveConsole::~GPassiveConsole ( )

Member Function Documentation

char GClasses::GPassiveConsole::getChar ( )

Returns the char of the next key that was pressed. (This method does not block.) If no keys have been pressed, it returns the zero char.

Member Data Documentation

struct termios GClasses::GPassiveConsole::m_old
protected
int GClasses::GPassiveConsole::m_oldStreamFlags
protected
int GClasses::GPassiveConsole::m_stdin
protected