X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fconsole.h;fp=source%2Fio%2Fconsole.h;h=3c0bb71ff3826d23467172a8e86c28f565ae1088;hp=0000000000000000000000000000000000000000;hb=6e0fd758970bcb5bad5e3f2454b694cc4d7b4b66;hpb=b97d4e9f86e90254ab9edef7ee62a910f6333c78 diff --git a/source/io/console.h b/source/io/console.h new file mode 100644 index 0000000..3c0bb71 --- /dev/null +++ b/source/io/console.h @@ -0,0 +1,56 @@ +#ifndef MSP_IO_CONSOLE_H_ +#define MSP_IO_CONSOLE_H_ + +#include "base.h" + +namespace Msp { +namespace IO { + +/** +Provides access to standard input, output and error streams. This class can't +be instantiated directly - use one of the cin, cout and cerr references +instead. +*/ +class Console: public Base +{ +private: + Handle handle; + + Console(unsigned); +public: + ~Console(); + + virtual void set_block(bool); + + /** If local echo is enabled, characters will appear on the console as they + are typed. Can only be used on an input Console. */ + void set_local_echo(bool); + + /** If line buffering is enabled, input will only be available when a + newline is encountered. On some systems, this may also enable line editing. + Can only be used on an input Console. + */ + void set_line_buffer(bool); + + /** Retrieves the size of the Console. Can only be used on an output + Console. */ + void get_size(unsigned &rows, unsigned &cols); + +protected: + virtual unsigned do_write(const char *, unsigned); + virtual unsigned do_read(char *, unsigned); + +public: + virtual Handle get_event_handle(); + + static Console &instance(unsigned); +}; + +extern Console &cin; +extern Console &cout; +extern Console &cerr; + +} // namespace IO +} // namespace Msp + +#endif